Skip to content

Commit

Permalink
add quiescence period extracted file (#606)
Browse files Browse the repository at this point in the history
* add quiescence period extracted file

* Extract quiescence period for ephys sessions

* add quiescence period to FPGA extractor

* Always create new tag in registration test

---------

Co-authored-by: Miles Wells <[email protected]>
  • Loading branch information
oliche and k1o0 authored May 15, 2023
1 parent 62c0e53 commit dbb2c4f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ibllib/io/extractors/biased_trials.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ProbaContrasts(BaseBpodTrialsExtractor):
Bpod pre-generated values for probabilityLeft, contrastLR, phase, quiescence
"""
save_names = ('_ibl_trials.contrastLeft.npy', '_ibl_trials.contrastRight.npy', None, None,
'_ibl_trials.probabilityLeft.npy', None)
'_ibl_trials.probabilityLeft.npy', '_ibl_trials.quiescencePeriod.npy')
var_names = ('contrastLeft', 'contrastRight', 'phase',
'position', 'probabilityLeft', 'quiescence')

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 @@ -694,7 +694,7 @@ def get_protocol_period(session_path, protocol_number, bpod_sync):
class FpgaTrials(extractors_base.BaseExtractor):
save_names = ('_ibl_trials.intervals_bpod.npy',
'_ibl_trials.goCueTrigger_times.npy', None, None, None, None, None, None, None,
'_ibl_trials.stimOff_times.npy', None, None, None, None,
'_ibl_trials.stimOff_times.npy', None, None, None, '_ibl_trials.quiescencePeriod.npy',
'_ibl_trials.table.pqt', '_ibl_wheel.timestamps.npy',
'_ibl_wheel.position.npy', '_ibl_wheelMoves.intervals.npy',
'_ibl_wheelMoves.peakAmplitude.npy')
Expand Down
2 changes: 1 addition & 1 deletion ibllib/io/extractors/training_trials.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ class PhasePosQuiescence(BaseBpodTrialsExtractor):
"""Extracts stimulus phase, position and quiescence from Bpod data.
For extraction of pre-generated events, use the ProbaContrasts extractor instead.
"""
save_names = (None, None, None)
save_names = (None, None, '_ibl_trials.quiescencePeriod.npy')
var_names = ('phase', 'position', 'quiescence')

def _extract(self, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion ibllib/tests/extractors/test_ephys_trials.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,5 @@ def test_get_probabilityLeft(self):
self.assertTrue(all([x in [0.2, 0.5, 0.8] for x in np.unique(pLeft1)]))


if __name__ == "__main__":
if __name__ == '__main__':
unittest.main(exit=False, verbosity=2)
16 changes: 6 additions & 10 deletions ibllib/tests/test_oneibl.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,9 @@ def setUp(self) -> None:
self.rev = self.one.alyx.rest('revisions', 'read', id=self.revision)
except HTTPError:
self.rev = self.one.alyx.rest('revisions', 'create', data={'name': self.revision})
# Create a tag if doesn't already exist
try:
self.tag = next(x for x in self.one.alyx.rest('tags', 'list')
if x['name'] == 'test_tag')
except StopIteration:
self.tag = self.one.alyx.rest('tags', 'create',
data={'name': 'test_tag', 'protected': True})
# Create a new tag
tag_data = {'name': f'test_tag_{np.random.randint(0, 1e3)}', 'protected': True}
self.tag = self.one.alyx.rest('tags', 'create', data=tag_data)

def test_registration_datasets(self):
# registers a single file
Expand Down Expand Up @@ -252,7 +248,7 @@ def test_registration_datasets(self):
dsets = self.one.alyx.rest('datasets', 'list', session=ses['url'][-36:])
for d in dsets:
self.one.alyx.rest('datasets', 'partial_update',
id=d['url'][-36:], data={'tags': ['test_tag']})
id=d['url'][-36:], data={'tags': [self.tag['name']]})

# Test registering with a revision already in the file path, should use this rather than create one with today's date
flist = list(self.rev_path.glob('*.npy'))
Expand All @@ -265,7 +261,7 @@ def test_registration_datasets(self):
dsets = self.one.alyx.rest('datasets', 'list', session=ses['url'][-36:])
for d in dsets:
self.one.alyx.rest('datasets', 'partial_update',
id=d['url'][-36:], data={'tags': ['test_tag']})
id=d['url'][-36:], data={'tags': [self.tag['name']]})

# Register again with revision in file path, it should register to self.revision + a
flist = list(self.rev_path.glob('*.npy'))
Expand All @@ -290,7 +286,7 @@ def test_registration_datasets(self):
dsets = self.one.alyx.rest('datasets', 'list', session=ses['url'][-36:], no_cache=True)
for d in dsets:
self.one.alyx.rest('datasets', 'partial_update',
id=d['url'][-36:], data={'tags': ['test_tag']})
id=d['url'][-36:], data={'tags': [self.tag['name']]})

# Same day revision
# Need to remake the original files
Expand Down

0 comments on commit dbb2c4f

Please sign in to comment.