diff --git a/ibllib/__init__.py b/ibllib/__init__.py index 2cbd2f779..770ead37d 100644 --- a/ibllib/__init__.py +++ b/ibllib/__init__.py @@ -2,7 +2,7 @@ import logging import warnings -__version__ = '2.28' +__version__ = '2.28.1' warnings.filterwarnings('always', category=DeprecationWarning, module='ibllib') # if this becomes a full-blown library we should let the logging configuration to the discretion of the dev diff --git a/ibllib/io/extractors/extractor_types.json b/ibllib/io/extractors/extractor_types.json index e69e65270..71eea2bcf 100644 --- a/ibllib/io/extractors/extractor_types.json +++ b/ibllib/io/extractors/extractor_types.json @@ -17,5 +17,6 @@ "_habituationChoiceWorld": "habituation", "_trainingChoiceWorld": "training", "ephysMockChoiceWorld": "mock_ephys", - "ephys_certification": "sync_ephys" + "ephys_certification": "sync_ephys", + "trainingPhaseChoiceWorld": "training" } diff --git a/ibllib/io/raw_data_loaders.py b/ibllib/io/raw_data_loaders.py index 3adfd3127..6f165479b 100644 --- a/ibllib/io/raw_data_loaders.py +++ b/ibllib/io/raw_data_loaders.py @@ -736,16 +736,6 @@ def _groom_wheel_data_ge5(data, label='file ', path=''): return data -def save_bool(save, dataset_type): - if isinstance(save, bool): - out = save - elif isinstance(save, list): - out = (dataset_type in save) or (Path(dataset_type).stem in save) - if out: - _logger.debug('extracting' + dataset_type) - return out - - def sync_trials_robust(t0, t1, diff_threshold=0.001, drift_threshold_ppm=200, max_shift=5, return_index=False): """ @@ -945,7 +935,7 @@ def patch_settings(session_path, collection='raw_behavior_data', if not settings: raise IOError('Settings file not found') - filename = PureWindowsPath(settings['SETTINGS_FILE_PATH']).name + filename = PureWindowsPath(settings.get('SETTINGS_FILE_PATH', '_iblrig_taskSettings.raw.json')).name file_path = Path(session_path).joinpath(collection, filename) if subject: @@ -955,7 +945,8 @@ def patch_settings(session_path, collection='raw_behavior_data', for k in settings.keys(): if isinstance(settings[k], str): settings[k] = settings[k].replace(f'\\Subjects\\{old_subject}', f'\\Subjects\\{subject}') - settings['SESSION_NAME'] = '\\'.join([subject, *settings['SESSION_NAME'].split('\\')[1:]]) + if 'SESSION_NAME' in settings: + settings['SESSION_NAME'] = '\\'.join([subject, *settings['SESSION_NAME'].split('\\')[1:]]) settings.pop('PYBPOD_SUBJECT_EXTRA', None) # Get rid of Alyx subject info if date: @@ -970,6 +961,10 @@ def patch_settings(session_path, collection='raw_behavior_data', f'\\{settings["SUBJECT_NAME"]}\\{date}' ) settings['SESSION_DATETIME'] = date + settings['SESSION_DATETIME'][10:] + if 'SESSION_END_TIME' in settings: + settings['SESSION_END_TIME'] = date + settings['SESSION_END_TIME'][10:] + if 'SESSION_START_TIME' in settings: + settings['SESSION_START_TIME'] = date + settings['SESSION_START_TIME'][10:] if number: # Patch session number diff --git a/ibllib/io/session_params.py b/ibllib/io/session_params.py index 300a5d6e3..174cf16a4 100644 --- a/ibllib/io/session_params.py +++ b/ibllib/io/session_params.py @@ -30,6 +30,7 @@ from copy import deepcopy from one.converters import ConversionMixin +from iblutil.util import flatten from packaging import version import ibllib.pipes.misc as misc @@ -391,15 +392,15 @@ def get_collections(sess_params, flat=False): sess_params : dict The loaded experiment description map. flat : bool (False) - If True, return a flat list of unique collections, otherwise return a map of device/sync/task + If True, return a flat set of collections, otherwise return a map of device/sync/task Returns ------- dict[str, str] A map of device/sync/task and the corresponding collection name. - list[str] - A flat list of unique collection names. + set[str] + A set of unique collection names. Notes ----- @@ -423,16 +424,7 @@ def iter_dict(d): iter_dict(v) iter_dict(sess_params) - if flat: - cflat = [] - for k, v in collection_map.items(): - if isinstance(v, list): - cflat.extend(v) - else: - cflat.append(v) - return list(set(cflat)) - else: - return collection_map + return set(flatten(collection_map.values())) if flat else collection_map def get_video_compressed(sess_params): diff --git a/ibllib/pipes/video_tasks.py b/ibllib/pipes/video_tasks.py index 7f501a065..d9a312808 100644 --- a/ibllib/pipes/video_tasks.py +++ b/ibllib/pipes/video_tasks.py @@ -467,7 +467,7 @@ class EphysPostDLC(base_tasks.VideoTask): level = 3 force = True - def __int__(self, *args, **kwargs): + def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.trials_collection = kwargs.get('trials_collection', 'alf') diff --git a/ibllib/tests/test_io.py b/ibllib/tests/test_io.py index 7bc75951f..eff04c862 100644 --- a/ibllib/tests/test_io.py +++ b/ibllib/tests/test_io.py @@ -166,11 +166,15 @@ def test_load_encoder_trial_info(self): self.session = Path(__file__).parent.joinpath('extractors', 'data', 'session_biased_ge5') data = raw.load_encoder_trial_info(self.session) self.assertTrue(data is not None) + self.assertIsNone(raw.load_encoder_trial_info(self.session.with_name('empty'))) + self.assertIsNone(raw.load_encoder_trial_info(None)) def test_load_camera_ssv_times(self): session = Path(__file__).parent.joinpath('extractors', 'data', 'session_ephys') with self.assertRaises(ValueError): raw.load_camera_ssv_times(session, 'tail') + with self.assertRaises(FileNotFoundError): + raw.load_camera_ssv_times(session.with_name('foobar'), 'body') bonsai, camera = raw.load_camera_ssv_times(session, 'body') self.assertTrue(bonsai.size == camera.size == 6001) self.assertEqual(bonsai.dtype.str, ' 400 (from start) can be found for which easy trial performance > 0.9 +#### 2.28.1 +- Typo in ibllib.pipes.video_tasks.EphysPostDLC class +- ibllib.io.raw_data_loaders.patch_settings works with iblrigv8 settings files + ## Release Notes 2.27 ### features