Skip to content

Commit

Permalink
Merge pull request #405 from int-brain-lab/hotfix/2.3.2
Browse files Browse the repository at this point in the history
bugfix: training wheel extraction more robust
  • Loading branch information
oliche authored Nov 8, 2021
2 parents 13d00dc + 80784e3 commit e8415f6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
7 changes: 7 additions & 0 deletions ibllib/io/extractors/training_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions ibllib/pipes/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
25 changes: 25 additions & 0 deletions ibllib/pipes/training_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
4 changes: 4 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e8415f6

Please sign in to comment.