Skip to content

Commit

Permalink
Resolves #854
Browse files Browse the repository at this point in the history
  • Loading branch information
k1o0 committed Oct 16, 2024
1 parent 02178fe commit d71ac48
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 20 deletions.
16 changes: 8 additions & 8 deletions ibllib/io/extractors/biased_trials.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class TrialsTableBiased(BaseBpodTrialsExtractor):
save_names = ('_ibl_trials.table.pqt', None, None, '_ibl_wheel.timestamps.npy', '_ibl_wheel.position.npy',
'_ibl_wheelMoves.intervals.npy', '_ibl_wheelMoves.peakAmplitude.npy', None, None)
var_names = ('table', 'stimOff_times', 'stimFreeze_times', 'wheel_timestamps', 'wheel_position', 'wheelMoves_intervals',
'wheelMoves_peakAmplitude', 'peakVelocity_times', 'is_final_movement')
'wheelMoves_peakAmplitude', 'wheelMoves_peakVelocity_times', 'is_final_movement')

def _extract(self, extractor_classes=None, **kwargs):
extractor_classes = extractor_classes or []
Expand Down Expand Up @@ -125,7 +125,7 @@ class TrialsTableEphys(BaseBpodTrialsExtractor):
'_ibl_wheelMoves.intervals.npy', '_ibl_wheelMoves.peakAmplitude.npy', None,
None, None, None, '_ibl_trials.quiescencePeriod.npy')
var_names = ('table', 'stimOff_times', 'stimFreeze_times', 'wheel_timestamps', 'wheel_position', 'wheelMoves_intervals',
'wheelMoves_peakAmplitude', 'peakVelocity_times', 'is_final_movement',
'wheelMoves_peakAmplitude', 'wheelMoves_peakVelocity_times', 'is_final_movement',
'phase', 'position', 'quiescence')

def _extract(self, extractor_classes=None, **kwargs):
Expand All @@ -152,12 +152,12 @@ class BiasedTrials(BaseBpodTrialsExtractor):
save_names = ('_ibl_trials.goCueTrigger_times.npy', '_ibl_trials.stimOnTrigger_times.npy', None,
'_ibl_trials.stimOffTrigger_times.npy', None, None, '_ibl_trials.table.pqt',
'_ibl_trials.stimOff_times.npy', None, '_ibl_wheel.timestamps.npy', '_ibl_wheel.position.npy',
'_ibl_wheelMoves.intervals.npy', '_ibl_wheelMoves.peakAmplitude.npy', None, None, '_ibl_trials.included.npy',
None, None, '_ibl_trials.quiescencePeriod.npy')
'_ibl_wheelMoves.intervals.npy', '_ibl_wheelMoves.peakAmplitude.npy', None, None,
'_ibl_trials.included.npy', None, None, '_ibl_trials.quiescencePeriod.npy')
var_names = ('goCueTrigger_times', 'stimOnTrigger_times', 'itiIn_times', 'stimOffTrigger_times', 'stimFreezeTrigger_times',
'errorCueTrigger_times', 'table', 'stimOff_times', 'stimFreeze_times', 'wheel_timestamps', 'wheel_position',
'wheelMoves_intervals', 'wheelMoves_peakAmplitude', 'peakVelocity_times', 'is_final_movement', 'included',
'phase', 'position', 'quiescence')
'wheelMoves_intervals', 'wheelMoves_peakAmplitude', 'wheelMoves_peakVelocity_times', 'is_final_movement',
'included', 'phase', 'position', 'quiescence')

def _extract(self, extractor_classes=None, **kwargs) -> dict:
extractor_classes = extractor_classes or []
Expand All @@ -182,8 +182,8 @@ class EphysTrials(BaseBpodTrialsExtractor):
'_ibl_trials.included.npy', None, None, '_ibl_trials.quiescencePeriod.npy')
var_names = ('goCueTrigger_times', 'stimOnTrigger_times', 'itiIn_times', 'stimOffTrigger_times', 'stimFreezeTrigger_times',
'errorCueTrigger_times', 'table', 'stimOff_times', 'stimFreeze_times', 'wheel_timestamps', 'wheel_position',
'wheelMoves_intervals', 'wheelMoves_peakAmplitude', 'peakVelocity_times', 'is_final_movement', 'included',
'phase', 'position', 'quiescence')
'wheelMoves_intervals', 'wheelMoves_peakAmplitude', 'wheelMoves_peakVelocity_times', 'is_final_movement',
'included', 'phase', 'position', 'quiescence')

def _extract(self, extractor_classes=None, **kwargs) -> dict:
extractor_classes = extractor_classes or []
Expand Down
2 changes: 1 addition & 1 deletion ibllib/io/extractors/ephys_fpga.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def get_wheel_positions(sync, chmap, tmin=None, tmax=None):
A dictionary with keys ('timestamps', 'position'), containing the wheel event timestamps and
position in radians
Bunch
A dictionary of detected movement times with keys ('intervals', 'peakAmplitude', 'peakVelocity_times').
A dictionary of detected movement times with keys ('intervals', 'peakAmplitude', 'wheelMoves_peakVelocity_times').
"""
ts, pos = extract_wheel_sync(sync=sync, chmap=chmap, tmin=tmin, tmax=tmax)
moves = Bunch(extract_wheel_moves(ts, pos))
Expand Down
4 changes: 2 additions & 2 deletions ibllib/io/extractors/training_trials.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ class TrialsTable(BaseBpodTrialsExtractor):
save_names = ('_ibl_trials.table.pqt', None, None, '_ibl_wheel.timestamps.npy', '_ibl_wheel.position.npy',
'_ibl_wheelMoves.intervals.npy', '_ibl_wheelMoves.peakAmplitude.npy', None, None)
var_names = ('table', 'stimOff_times', 'stimFreeze_times', 'wheel_timestamps', 'wheel_position', 'wheelMoves_intervals',
'wheelMoves_peakAmplitude', 'peakVelocity_times', 'is_final_movement')
'wheelMoves_peakAmplitude', 'wheelMoves_peakVelocity_times', 'is_final_movement')

def _extract(self, extractor_classes=None, **kwargs):
base = [Intervals, GoCueTimes, ResponseTimes, Choice, StimOnOffFreezeTimes, ContrastLR, FeedbackTimes, FeedbackType,
Expand All @@ -732,7 +732,7 @@ class TrainingTrials(BaseBpodTrialsExtractor):
var_names = ('repNum', 'goCueTrigger_times', 'stimOnTrigger_times', 'itiIn_times', 'stimOffTrigger_times',
'stimFreezeTrigger_times', 'errorCueTrigger_times', 'table', 'stimOff_times', 'stimFreeze_times',
'wheel_timestamps', 'wheel_position', 'wheelMoves_intervals', 'wheelMoves_peakAmplitude',
'peakVelocity_times', 'is_final_movement', 'phase', 'position', 'quiescence', 'pause_duration')
'wheelMoves_peakVelocity_times', 'is_final_movement', 'phase', 'position', 'quiescence', 'pause_duration')

def _extract(self) -> dict:
base = [RepNum, GoCueTriggerTimes, StimOnTriggerTimes, ItiInTimes, StimOffTriggerTimes, StimFreezeTriggerTimes,
Expand Down
10 changes: 5 additions & 5 deletions ibllib/io/extractors/training_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def extract_wheel_moves(re_ts, re_pos, display=False):

# Put into dict
wheel_moves = {
'intervals': np.c_[on, off], 'peakAmplitude': amp, 'peakVelocity_times': peak_vel}
'intervals': np.c_[on, off], 'peakAmplitude': amp, 'wheelMoves_peakVelocity_times': peak_vel}
return wheel_moves


Expand Down Expand Up @@ -407,9 +407,9 @@ class Wheel(BaseBpodTrialsExtractor):
save_names = ('_ibl_wheel.timestamps.npy', '_ibl_wheel.position.npy',
'_ibl_wheelMoves.intervals.npy', '_ibl_wheelMoves.peakAmplitude.npy', None,
'_ibl_trials.firstMovement_times.npy', None)
var_names = ('wheel_timestamps', 'wheel_position', 'wheelMoves_intervals',
'wheelMoves_peakAmplitude', 'peakVelocity_times', 'firstMovement_times',
'is_final_movement')
var_names = ('wheel_timestamps', 'wheel_position',
'wheelMoves_intervals', 'wheelMoves_peakAmplitude', 'wheelMoves_peakVelocity_times',
'firstMovement_times', 'is_final_movement')

def _extract(self):
ts, pos = get_wheel_position(self.session_path, self.bpod_trials, task_collection=self.task_collection)
Expand All @@ -426,5 +426,5 @@ def _extract(self):

first_moves, is_final, _ = extract_first_movement_times(moves, trials, min_qt=min_qt)
output = (ts, pos, moves['intervals'], moves['peakAmplitude'],
moves['peakVelocity_times'], first_moves, is_final)
moves['wheelMoves_peakVelocity_times'], first_moves, is_final)
return output
1 change: 1 addition & 0 deletions ibllib/oneibl/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from one.converters import ConversionMixin
import one.alf.exceptions as alferr
from one.api import ONE
from one.util import datasets2records
from iblutil.util import ensure_list

import ibllib
Expand Down
2 changes: 1 addition & 1 deletion ibllib/qc/task_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ def check_n_trial_events(data, **_):
# test errorCueTrigger_times separately
# stimFreeze_times fails often due to TTL flicker
exclude = ['camera_timestamps', 'errorCueTrigger_times', 'errorCue_times',
'firstMovement_times', 'peakVelocity_times', 'valveOpen_times',
'firstMovement_times', 'wheelMoves_peakVelocity_times', 'valveOpen_times',
'wheel_moves_peak_amplitude', 'wheel_moves_intervals', 'wheel_timestamps',
'wheel_intervals', 'stimFreeze_times']
events = [k for k in data.keys() if k.endswith('_times') and k not in exclude]
Expand Down
4 changes: 2 additions & 2 deletions ibllib/tests/extractors/test_ephys_fpga.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def test_extract_wheel_moves(self):
n = 56 # expected number of movements
self.assertTupleEqual(wheel_moves['intervals'].shape, (n, 2), 'failed to return the correct number of intervals')
self.assertEqual(wheel_moves['peakAmplitude'].size, n)
self.assertEqual(wheel_moves['peakVelocity_times'].size, n)
self.assertEqual(wheel_moves['wheelMoves_peakVelocity_times'].size, n)

# Check the first 3 intervals
ints = np.array([[24.78462599, 25.22562599], [29.58762599, 31.15062599], [31.64262599, 31.81662599]])
Expand All @@ -468,7 +468,7 @@ def test_extract_wheel_moves(self):
self.assertIsNone(np.testing.assert_allclose(actual, expected), 'unexpected amplitudes')

# Check peak velocities
actual = wheel_moves['peakVelocity_times'][-3:]
actual = wheel_moves['wheelMoves_peakVelocity_times'][-3:]
expected = [175.13662599, 176.65762599, 178.57262599]
self.assertIsNone(np.testing.assert_allclose(actual, expected), 'peak times')

Expand Down
2 changes: 1 addition & 1 deletion ibllib/tests/extractors/test_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def test_size_outputs(self):
mock_data = {
'intervals': np.array([[0, 1], ]),
'peakAmplitude': np.array([1, 1]),
'peakVelocity_times': np.array([1, 1])}
'wheelMoves_peakVelocity_times': np.array([1, 1])}
function_name = 'ibllib.io.extractors.training_wheel.extract_wheel_moves'
# Training
with unittest.mock.patch(function_name, return_value=mock_data):
Expand Down

0 comments on commit d71ac48

Please sign in to comment.