Skip to content

Commit e8d5186

Browse files
authored
Merge pull request #330 from CAMBI-tech/calib-task-refactor
Calibration task refactor
2 parents 69dfe48 + 4ebbb7c commit e8d5186

File tree

12 files changed

+927
-1060
lines changed

12 files changed

+927
-1060
lines changed

bcipy/display/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ class Display(ABC):
2323
stimuli_colors: List[str] = None
2424
stimuli_timing: List[float] = None
2525
task = None
26+
info_text: List[Any] = None
27+
first_stim_time: float = None
2628

2729
@abstractmethod
28-
def do_inquiry(self) -> List[float]:
30+
def do_inquiry(self) -> List[Tuple[str, float]]:
2931
"""Do inquiry.
3032
3133
Animates an inquiry of stimuli and returns a list of stimuli trigger timing.

bcipy/display/paradigm/matrix/display.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ def __init__(self,
115115
self.should_prompt_target = should_prompt_target
116116

117117
self.logger.info(
118-
f"Symbol positions ({display_container.units} units):\n{self._stim_positions}"
118+
f"Symbol positions ({display_container.units} units):\n{self.stim_positions}"
119119
)
120120
self.logger.info(f"Matrix center position: {display_container.center}")
121121

122122
@property
123-
def _stim_positions(self) -> Dict[str, Tuple[float, float]]:
123+
def stim_positions(self) -> Dict[str, Tuple[float, float]]:
124124
"""Returns a dict with the position for each stim"""
125125
assert self.stim_registry, "stim_registry not yet initialized"
126126
return {

bcipy/display/paradigm/rsvp/display.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
import logging
22
import os.path as path
3-
from typing import Optional, List, Tuple
3+
from typing import List, Optional, Tuple
44

5-
from psychopy import core, visual, event
5+
from psychopy import core, event, visual
66

7-
from bcipy.helpers.clock import Clock
8-
from bcipy.helpers.task import get_key_press
9-
from bcipy.helpers.symbols import SPACE_CHAR
10-
from bcipy.display import (
11-
BCIPY_LOGO_PATH,
12-
Display,
13-
InformationProperties,
14-
PreviewInquiryProperties,
15-
StimuliProperties
16-
)
7+
from bcipy.display import (BCIPY_LOGO_PATH, Display, InformationProperties,
8+
PreviewInquiryProperties, StimuliProperties)
179
from bcipy.display.components.task_bar import TaskBar
10+
from bcipy.helpers.clock import Clock
1811
from bcipy.helpers.stimuli import resize_image
12+
from bcipy.helpers.symbols import SPACE_CHAR
1913
from bcipy.helpers.system_utils import get_screen_info
14+
from bcipy.helpers.task import get_key_press
2015
from bcipy.helpers.triggers import TriggerCallback, _calibration_trigger
2116

2217

@@ -131,7 +126,7 @@ def schedule_to(self,
131126
self.stimuli_timing = timing or []
132127
self.stimuli_colors = colors or []
133128

134-
def do_inquiry(self, preview_calibration: bool = False) -> List[float]:
129+
def do_inquiry(self, preview_calibration: bool = False) -> List[Tuple[str, float]]:
135130
"""Do inquiry.
136131
137132
Animates an inquiry of flashing letters to achieve RSVP.

bcipy/helpers/stimuli.py

+10
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ class InquirySchedule(NamedTuple):
8989
durations: Union[List[List[float]], List[float]]
9090
colors: Union[List[List[str]], List[str]]
9191

92+
def inquiries(self) -> Iterator[Tuple]:
93+
"""Generator that iterates through each Inquiry. Yields tuples of
94+
(stim, duration, color)."""
95+
count = len(self.stimuli)
96+
index = 0
97+
while index < count:
98+
yield (self.stimuli[index], self.durations[index],
99+
self.colors[index])
100+
index += 1
101+
92102

93103
class Reshaper(ABC):
94104

0 commit comments

Comments
 (0)