diff --git a/ibllib/io/extractors/training_wheel.py b/ibllib/io/extractors/training_wheel.py index 53d0ed76b..db311d098 100644 --- a/ibllib/io/extractors/training_wheel.py +++ b/ibllib/io/extractors/training_wheel.py @@ -4,6 +4,7 @@ import numpy as np from scipy import interpolate +from ibllib.dsp.utils import sync_timestamps from ibllib.io.extractors import training_trials from ibllib.io.extractors.base import BaseBpodTrialsExtractor, run_extractor_classes import ibllib.io.raw_data_loaders as raw @@ -73,6 +74,12 @@ def sync_rotary_encoder(session_path, bpod_data=None, re_events=None): else: bp, re = raw.sync_trials_robust(bpod['closed_loop'], rote['closed_loop'], diff_threshold=DIFF_THRESHOLD, max_shift=5) + # we dont' want to change the extractor, but in rare cases the following method may save the day + if len(bp) == 0: + _, _, ib, ir = sync_timestamps(bpod['closed_loop'], rote['closed_loop'], return_indices=True) + bp = bpod['closed_loop'][ib] + re = rote['closed_loop'][ir] + indko = np.array([]) # raise ValueError("Can't sync bpod and rotary encoder: non-contiguous sync pulses") # remove faulty indices due to missing or bad syncs diff --git a/ibllib/pipes/tasks.py b/ibllib/pipes/tasks.py index 787b7e449..6496b5500 100644 --- a/ibllib/pipes/tasks.py +++ b/ibllib/pipes/tasks.py @@ -95,8 +95,8 @@ def run(self, **kwargs): _logger.info(f"Running on machine: {self.machine}") _logger.info(f"running ibllib version {version.ibllib()}") # setup + start_time = time.time() try: - start_time = time.time() setup = self.setUp(**kwargs) _logger.info(f"Setup value is: {setup}") self.status = 0 @@ -117,7 +117,8 @@ def run(self, **kwargs): _logger.error(traceback.format_exc()) _logger.info(f"Job {self.__class__} errored") self.status = -1 - self.time_elapsed_secs = time.time() - start_time + + self.time_elapsed_secs = time.time() - start_time # log the outputs if isinstance(self.outputs, list): diff --git a/ibllib/pipes/training_preprocessing.py b/ibllib/pipes/training_preprocessing.py index a08ea4ad3..2089e3b37 100644 --- a/ibllib/pipes/training_preprocessing.py +++ b/ibllib/pipes/training_preprocessing.py @@ -25,6 +25,31 @@ def _run(self, overwrite=False): class TrainingTrials(tasks.Task): priority = 90 level = 0 + force = False + signature = { + 'input_files': [('_iblrig_taskData.raw.*', 'raw_behavior_data', True), + ('_iblrig_taskSettings.raw.*', 'raw_behavior_data', True), + ('_iblrig_encoderEvents.raw*', 'raw_behavior_data', True), + ('_iblrig_encoderPositions.raw*', 'raw_behavior_data', True)], + 'output_files': [('*trials.choice.npy', 'alf', True), + ('*trials.contrastLeft.npy', 'alf', True), + ('*trials.contrastRight.npy', 'alf', True), + ('*trials.feedbackType.npy', 'alf', True), + ('*trials.feedback_times.npy', 'alf', True), + ('*trials.firstMovement_times.npy', 'alf', True), + ('*trials.goCueTrigger_times.npy', 'alf', True), + ('*trials.goCue_times.npy', 'alf', True), + ('*trials.intervals.npy', 'alf', True), + ('*trials.itiDuration.npy', 'alf', False), + ('*trials.probabilityLeft.npy', 'alf', True), + ('*trials.response_times.npy', 'alf', True), + ('*trials.rewardVolume.npy', 'alf', True), + ('*trials.stimOn_times.npy', 'alf', True), + ('*wheel.position.npy', 'alf', True), + ('*wheel.timestamps.npy', 'alf', True), + ('*wheelMoves.intervals.npy', 'alf', True), + ('*wheelMoves.peakAmplitude.npy', 'alf', True)] + } def _run(self): """ diff --git a/release_notes.md b/release_notes.md index 7491cbc9d..d9056624c 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,4 +1,8 @@ ## Release Notes 2.3 +### Release Notes 2.3.1 2021-11-08 +- Trial wheel extraction: use alternative sync method when first on fails +- bugfix: timer for tasks was returning None + ### Release Notes 2.3.1 2021-11-5 - Add setup method in tasks.py into try except to catch globus download errors diff --git a/setup.py b/setup.py index 804ffe80c..3efad2ab8 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ setup( name='ibllib', - version='2.3.1', + version='2.3.2', python_requires='>={}.{}'.format(*REQUIRED_PYTHON), description='IBL libraries', license="MIT",