Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calibration task refactor #330

Merged
merged 15 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bcipy/display/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ class Display(ABC):
stimuli_colors: List[str] = None
stimuli_timing: List[float] = None
task = None
info_text: List[Any] = None
first_stim_time: float = None

@abstractmethod
def do_inquiry(self) -> List[float]:
def do_inquiry(self) -> List[Tuple[str, float]]:
"""Do inquiry.

Animates an inquiry of stimuli and returns a list of stimuli trigger timing.
Expand Down
4 changes: 2 additions & 2 deletions bcipy/display/paradigm/matrix/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ def __init__(self,
self.should_prompt_target = should_prompt_target

self.logger.info(
f"Symbol positions ({display_container.units} units):\n{self._stim_positions}"
f"Symbol positions ({display_container.units} units):\n{self.stim_positions}"
)
self.logger.info(f"Matrix center position: {display_container.center}")

@property
def _stim_positions(self) -> Dict[str, Tuple[float, float]]:
def stim_positions(self) -> Dict[str, Tuple[float, float]]:
"""Returns a dict with the position for each stim"""
assert self.stim_registry, "stim_registry not yet initialized"
return {
Expand Down
21 changes: 8 additions & 13 deletions bcipy/display/paradigm/rsvp/display.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import logging
import os.path as path
from typing import Optional, List, Tuple
from typing import List, Optional, Tuple

from psychopy import core, visual, event
from psychopy import core, event, visual

from bcipy.helpers.clock import Clock
from bcipy.helpers.task import get_key_press
from bcipy.helpers.symbols import SPACE_CHAR
from bcipy.display import (
BCIPY_LOGO_PATH,
Display,
InformationProperties,
PreviewInquiryProperties,
StimuliProperties
)
from bcipy.display import (BCIPY_LOGO_PATH, Display, InformationProperties,
PreviewInquiryProperties, StimuliProperties)
from bcipy.display.components.task_bar import TaskBar
from bcipy.helpers.clock import Clock
from bcipy.helpers.stimuli import resize_image
from bcipy.helpers.symbols import SPACE_CHAR
from bcipy.helpers.system_utils import get_screen_info
from bcipy.helpers.task import get_key_press
from bcipy.helpers.triggers import TriggerCallback, _calibration_trigger


Expand Down Expand Up @@ -131,7 +126,7 @@ def schedule_to(self,
self.stimuli_timing = timing or []
self.stimuli_colors = colors or []

def do_inquiry(self, preview_calibration: bool = False) -> List[float]:
def do_inquiry(self, preview_calibration: bool = False) -> List[Tuple[str, float]]:
"""Do inquiry.

Animates an inquiry of flashing letters to achieve RSVP.
Expand Down
10 changes: 10 additions & 0 deletions bcipy/helpers/stimuli.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ class InquirySchedule(NamedTuple):
durations: Union[List[List[float]], List[float]]
colors: Union[List[List[str]], List[str]]

def inquiries(self) -> Iterator[Tuple]:
"""Generator that iterates through each Inquiry. Yields tuples of
(stim, duration, color)."""
count = len(self.stimuli)
index = 0
while index < count:
yield (self.stimuli[index], self.durations[index],
self.colors[index])
index += 1


class Reshaper(ABC):

Expand Down
Loading
Loading