Skip to content

Commit

Permalink
add the extractors description in the acquisition description file
Browse files Browse the repository at this point in the history
  • Loading branch information
oliche committed Jul 24, 2023
1 parent 788ba17 commit e05cf20
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 42 deletions.
2 changes: 1 addition & 1 deletion iblrig/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "8.6.1"
__version__ = "8.7.0"
13 changes: 10 additions & 3 deletions iblrig/base_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class BaseSession(ABC):
protocol_name = None
base_parameters_file = None
is_mock = False
extractor_tasks = None

def __init__(self, subject=None, task_parameter_file=None, file_hardware_settings=None,
hardware_settings=None, file_iblrig_settings=None, iblrig_settings=None,
Expand Down Expand Up @@ -119,7 +120,7 @@ def __init__(self, subject=None, task_parameter_file=None, file_hardware_setting
# Prepare the experiment description dictionary
self.experiment_description = self.make_experiment_description_dict(
self.protocol_name, self.paths.TASK_COLLECTION,
procedures, projects, self.hardware_settings, stub)
procedures, projects, self.hardware_settings, stub, extractors=self.extractor_tasks)

def _init_paths(self, append: bool = False):
"""
Expand Down Expand Up @@ -191,8 +192,9 @@ def _setup_loggers(self, level='INFO', file=None):
self.logger = logger

@staticmethod
def make_experiment_description_dict(task_protocol: str, task_collection: str, procedures: list = None, projects: list = None,
hardware_settings: dict = None, stub: Path = None):
def make_experiment_description_dict(task_protocol: str, task_collection: str, procedures: list = None,
projects: list = None, hardware_settings: dict = None,
stub: Path = None, extractors: list = None):
"""
Construct an experiment description dictionary.
Expand All @@ -210,6 +212,8 @@ def make_experiment_description_dict(task_protocol: str, task_collection: str, p
An optional dict of hardware devices, loaded from the hardware_settings.yaml file.
stub : dict
An optional experiment description stub to update.
extractors: list
An optional list of extractor names for the task.
Returns
-------
Expand Down Expand Up @@ -238,6 +242,9 @@ def make_experiment_description_dict(task_protocol: str, task_collection: str, p
'bpod': {'collection': task_collection, 'acquisition_software': 'pybpod', 'extension': '.jsonable'}}
# Add task
task = {task_protocol: {'collection': task_collection, 'sync_label': 'bpod'}}
if extractors:
assert isinstance(extractors, list), 'extractors parameter must be a list of strings'
task[task_protocol].update({'extractors': extractors})
if 'tasks' not in description:
description['tasks'] = [task]
else:
Expand Down
5 changes: 5 additions & 0 deletions iblrig/test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def test_graphviz(self) -> None:
pdf_out = Path(inspect.getfile(self.task.__class__)).parent.joinpath('state_machine_graph')
self.task.get_graphviz_task(output_file=pdf_out, view=False)

def test_acquisition_description(self) -> None:
# This makes sure that the task has a defined set of extractors
description_task = self.task.experiment_description['tasks'][0][self.task.protocol_name]
self.assertEqual(description_task['extractors'], self.task.extractor_tasks)


class TestIntegrationFullRuns(BaseTestCases.CommonTestTask):
"""
Expand Down
11 changes: 0 additions & 11 deletions iblrig/test/tasks/test_imaging_choice_world.py

This file was deleted.

8 changes: 6 additions & 2 deletions iblrig/test/tasks/test_training_choice_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ def test_acquisition_description(self):
'cameras': {'left': {'collection': 'raw_video_data', 'sync_label': 'audio'}},
'microphone': {'microphone': {'collection': 'raw_task_data_00', 'sync_label': 'audio'}},
},
'tasks': [
{'_iblrig_tasks_trainingChoiceWorld': {'collection': 'raw_task_data_00', 'sync_label': 'bpod'}}],
'tasks': [{
'_iblrig_tasks_trainingChoiceWorld': {
'collection': 'raw_task_data_00',
'sync_label': 'bpod',
'extractors': ['TrialRegisterRaw', 'TrainingTrials', 'TrainingStatus']}}
],
}
for k in ed:
assert ad[k] == ed[k], f"Failed on {k}"
6 changes: 5 additions & 1 deletion iblrig/test/test_base_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ def test_valve_mixin(self):


class TestExperimentDescription(unittest.TestCase):
"""Test creation of experiment description dictionary."""
"""
Test creation of experiment description dictionary
Note: another part of testing is done in test/base.py, where the specific extractor classes
are passed on to the acquisition description and tested for each task.
"""

def setUp(self) -> None:
self.stub = {
Expand Down
Empty file.
20 changes: 0 additions & 20 deletions iblrig_tasks/_iblrig_tasks_ImagingChoiceWorld/task.py

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions iblrig_tasks/_iblrig_tasks_advancedChoiceWorld/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class Session(ActiveChoiceWorldSession):
protocol_name = "_iblrig_tasks_advancedChoiceWorld"
extractor_tasks = ['TrialRegisterRaw', 'TrainingTrials', 'TrainingStatus']

def next_trial(self):
# update counters
Expand Down
2 changes: 1 addition & 1 deletion iblrig_tasks/_iblrig_tasks_biasedChoiceWorld/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class Session(BiasedChoiceWorldSession):
pass
extractor_tasks = ['TrialRegisterRaw', 'BiasedTrials', 'TrainingStatus']


if __name__ == "__main__": # pragma: no cover
Expand Down
1 change: 1 addition & 0 deletions iblrig_tasks/_iblrig_tasks_ephysChoiceWorld/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class Session(BiasedChoiceWorldSession):
protocol_name = "_iblrig_tasks_ephysChoiceWorld"
extractor_tasks = ['TrialRegisterRaw', 'BiasedTrials', 'TrainingStatus']

def __init__(self, *args, session_template_id=0, delay_secs=0, **kwargs):
super(Session, self).__init__(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion iblrig_tasks/_iblrig_tasks_habituationChoiceWorld/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class Session(HabituationChoiceWorldSession):
pass
extractor_tasks = ['TrialRegisterRaw', 'HabituationTrials']


if __name__ == "__main__": # pragma: no cover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class Session(BiasedChoiceWorldSession):
protocol_name = "_iblrig_tasks_neuromodulatorChoiceWorld"
extractor_tasks = ['TrialRegisterRaw', 'TrialsTableNeuromodulator', 'TrainingStatus']

def __init__(self, *args, **kwargs):
super(Session, self).__init__(*args, **kwargs)
Expand Down
1 change: 1 addition & 0 deletions iblrig_tasks/_iblrig_tasks_passiveChoiceWorld/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class Session(ChoiceWorldSession):
protocol_name = "_iblrig_tasks_passiveChoiceWorld"
extractor_tasks = ['PassiveRegisterRaw', 'PassiveChoiceWorld']

def __init__(self, **kwargs):
super(ChoiceWorldSession, self).__init__(**kwargs)
Expand Down
1 change: 1 addition & 0 deletions iblrig_tasks/_iblrig_tasks_trainingChoiceWorld/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


class Session(TrainingChoiceWorldSession):
extractor_tasks = ['TrialRegisterRaw', 'TrainingTrials', 'TrainingStatus']

@staticmethod
def extra_parser():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class Session(TrainingChoiceWorldSession):
protocol_name = "_iblrig_tasks_trainingPhaseChoiceWorld"
extractor_tasks = ['TrialRegisterRaw', 'TrainingTrials', 'TrainingStatus']

def __init__(self, *args, **kwargs):
super(Session, self).__init__(*args, **kwargs)
Expand Down

0 comments on commit e05cf20

Please sign in to comment.