Skip to content

Commit

Permalink
fix copier tests and relax stats on ephys statistics test
Browse files Browse the repository at this point in the history
  • Loading branch information
oliche committed Aug 31, 2023
1 parent 6f5f7c2 commit 9402d22
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 11 deletions.
8 changes: 4 additions & 4 deletions iblrig/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,19 @@ def transfer_data(local_subjects_path=None, remote_subjects_path=None, dry=False
if sc.state == 3:
logger.info(f"{state}, {sc.session_path}")
# once we copied the data, remove older session for which the data was successfully uploaded
remove_local_sessions(weeks=2, dry=dry)
remove_local_sessions(weeks=2, dry=dry, local_subjects_path=local_subjects_path, remote_subjects_path=remote_subjects_path)


def remove_local_sessions(weeks=2, dry=False):
def remove_local_sessions(weeks=2, local_subjects_path=None, remote_subjects_path=None, dry=False):
"""
Remove local sessions older than 2 weeks
:param weeks:
:param dry:
:return:
"""
iblrig_settings = load_settings_yaml()
local_subjects_path = Path(iblrig_settings['iblrig_local_data_path'])
remote_subjects_path = Path(iblrig_settings['iblrig_remote_data_path']).joinpath('Subjects')
local_subjects_path = local_subjects_path or Path(iblrig_settings['iblrig_local_data_path'])
remote_subjects_path = remote_subjects_path or Path(iblrig_settings['iblrig_remote_data_path']).joinpath('Subjects')

size = 0
for flag in sorted(list(local_subjects_path.rglob('_ibl_experiment.description_behavior.yaml')), reverse=True):
Expand Down
10 changes: 10 additions & 0 deletions iblrig/device_descriptions/cameras/body_left_right.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cameras:
body:
collection: raw_video_data
sync_label: frame2ttl
left:
collection: raw_video_data
sync_label: frame2ttl
right:
collection: raw_video_data
sync_label: frame2ttl
4 changes: 4 additions & 0 deletions iblrig/device_descriptions/cameras/left.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cameras:
left:
collection: raw_video_data
sync_label: frame2ttl
4 changes: 4 additions & 0 deletions iblrig/device_descriptions/microphone/microphone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
microphone:
microphone:
collection: raw_behavior_data
sync_label: null
7 changes: 7 additions & 0 deletions iblrig/device_descriptions/neuropixel/dual_probe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
neuropixel:
probe00:
collection: raw_ephys_data/probe00
sync_label: imec_sync
probe01:
collection: raw_ephys_data/probe01
sync_label: imec_sync
4 changes: 4 additions & 0 deletions iblrig/device_descriptions/neuropixel/single_probe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
neuropixel:
probe00:
collection: raw_ephys_data/probe00
sync_label: imec_sync
18 changes: 18 additions & 0 deletions iblrig/device_descriptions/neuropixel/wirings/3A.wiring.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"SYSTEM": "3A",
"SYNC_WIRING_DIGITAL": {
"pin03": "left_camera",
"pin04": "right_camera",
"pin05": "camera_level_shifter_board_ground",
"pin06": "body_camera",
"pin09": "bpod",
"pin10": "bpod_ground",
"pin15": "frame2ttl_ground",
"pin16": "frame2ttl",
"pin17": "rotary_encoder_0",
"pin18": "rotary_encoder_1",
"pin19": "audio",
"pin20": "audio_ground",
"pin23": "rotary_encoder_ground"
}
}
7 changes: 7 additions & 0 deletions iblrig/device_descriptions/neuropixel/wirings/3B.wiring.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"SYSTEM": "3B",
"SYNC_WIRING_DIGITAL": {
"P0.6": "imec_sync"
}
}

18 changes: 18 additions & 0 deletions iblrig/device_descriptions/neuropixel/wirings/nidq.wiring.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"SYSTEM": "3B",
"SYNC_WIRING_DIGITAL": {
"P0.0": "left_camera",
"P0.1": "right_camera",
"P0.2": "body_camera",
"P0.3": "imec_sync",
"P0.4": "frame2ttl",
"P0.5": "rotary_encoder_0",
"P0.6": "rotary_encoder_1",
"P0.7": "audio"
},
"SYNC_WIRING_ANALOG": {
"AI0": "bpod",
"AI1": "laser",
"AI2": "laser_ttl"
}
}
4 changes: 4 additions & 0 deletions iblrig/device_descriptions/sync/bpod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sync:
bpod:
collection: raw_behavior_data
extension: bins
5 changes: 5 additions & 0 deletions iblrig/device_descriptions/sync/nidq.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sync:
nidq:
collection: raw_ephys_data
extension: bin
acquisition_software: spikeglx
2 changes: 1 addition & 1 deletion iblrig/test/tasks/test_biased_choice_world_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_task(self):
# make sure that all subsequent blocks alternate between 0.2 and 0.8 left probability
assert np.all(np.isclose(np.abs(np.diff(df_blocks['stim_probability_left'].values[1:])), 0.6))
# assert the the trial outcomes are within 0.3 of the generating probability
assert np.all(np.abs(df_blocks['position'] - df_blocks['stim_probability_left']) < 0.3)
np.testing.assert_array_less(np.abs(df_blocks['position'] - df_blocks['stim_probability_left']), 0.4)

def check_quiescent_period(self):
"""
Expand Down
12 changes: 6 additions & 6 deletions iblrig/transfer_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class VideoCopier(SessionCopier):

def initialize_experiment(self, acquisition_description=None, **kwargs):
if not acquisition_description:
stub_file = Path(iblrig.__file__).parent.joinpath('device_stubs', 'cameras_body_left_right.yaml')
stub_file = Path(iblrig.__file__).parent.joinpath('device_descriptions', 'cameras', 'body_left_right.yaml')
acquisition_description = session_params.read_params(stub_file)
super(VideoCopier, self).initialize_experiment(acquisition_description=acquisition_description, **kwargs)

Expand All @@ -201,10 +201,10 @@ def initialize_experiment(self, acquisition_description=None, nprobes=None, **kw
if not acquisition_description:
nprobes = nprobes or len(list(self.session_path.joinpath('raw_ephys_data').rglob('*.ap.bin')))
match nprobes:
case 1: stub_name = 'neuropixel_single_probe.yaml'
case 2: stub_name = 'neuropixel_dual_probe.yaml'
stub_file = Path(iblrig.__file__).parent.joinpath('device_stubs', stub_name)
sync_file = Path(iblrig.__file__).parent.joinpath('device_stubs', 'sync_nidq_raw_ephys_data.yaml')
case 1: stub_name = 'single_probe.yaml'
case 2: stub_name = 'dual_probe.yaml'
stub_file = Path(iblrig.__file__).parent.joinpath('device_descriptions', 'neuropixel', stub_name)
sync_file = Path(iblrig.__file__).parent.joinpath('device_descriptions', 'sync', 'nidq.yaml')
acquisition_description = session_params.read_params(stub_file)
acquisition_description.update(session_params.read_params(sync_file))
super(EphysCopier, self).initialize_experiment(acquisition_description=acquisition_description, **kwargs)
Expand All @@ -219,7 +219,7 @@ def _copy_collections(self):
ibllib.pipes.misc.rename_ephys_files(self.session_path)
ibllib.pipes.misc.move_ephys_files(self.session_path)
# copy the wiring files from template
path_wiring = Path(iblrig.ephyspc.__file__).parent.joinpath('wirings')
path_wiring = Path(iblrig.__file__).parent.joinpath('device_descriptions', 'neuropixel', 'wirings')
probe_model = '3A'
for file_nidq_bin in self.session_path.joinpath('raw_ephys_data').glob('*.nidq.bin'):
probe_model = '3B'
Expand Down

0 comments on commit 9402d22

Please sign in to comment.