Skip to content

Commit e3846c3

Browse files
authored
Merge pull request #627 from int-brain-lab/photometry_witten
Photometry witten
2 parents 64a1db7 + b86671d commit e3846c3

File tree

9 files changed

+523
-148
lines changed

9 files changed

+523
-148
lines changed

ibllib/io/extractors/fibrephotometry.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,22 @@
4646
NEUROPHOTOMETRICS_LED_STATES = {
4747
'Condition': {
4848
0: 'No additional signal',
49-
1: 'Output 0 signal HIGH + Stimulation',
50-
2: 'Output 0 signal HIGH + Input 0 signal HIGH',
51-
3: 'Input 0 signal HIGH + Stimulation',
52-
4: 'Output 0 HIGH + Input 0 HIGH + Stimulation'
49+
1: 'Output 1 signal HIGH',
50+
2: 'Output 0 signal HIGH',
51+
3: 'Stimulation ON',
52+
4: 'GPIO Line 2 HIGH',
53+
5: 'GPIO Line 3 HIGH',
54+
6: 'Input 1 HIGH',
55+
7: 'Input 0 HIGH',
56+
8: 'Output 0 signal HIGH + Stimulation',
57+
9: 'Output 0 signal HIGH + Input 0 signal HIGH',
58+
10: 'Input 0 signal HIGH + Stimulation',
59+
11: 'Output 0 HIGH + Input 0 HIGH + Stimulation',
5360
},
54-
'No LED ON': {0: 0, 1: 48, 2: 528, 3: 544, 4: 560},
55-
'L415': {0: 1, 1: 49, 2: 529, 3: 545, 4: 561},
56-
'L470': {0: 2, 1: 50, 2: 530, 3: 546, 4: 562},
57-
'L560': {0: 4, 1: 52, 2: 532, 3: 548, 4: 564}
61+
'No LED ON': {0: 0, 1: 8, 2: 16, 3: 32, 4: 64, 5: 128, 6: 256, 7: 512, 8: 48, 9: 528, 10: 544, 11: 560},
62+
'L415': {0: 1, 1: 9, 2: 17, 3: 33, 4: 65, 5: 129, 6: 257, 7: 513, 8: 49, 9: 529, 10: 545, 11: 561},
63+
'L470': {0: 2, 1: 10, 2: 18, 3: 34, 4: 66, 5: 130, 6: 258, 7: 514, 8: 50, 9: 530, 10: 546, 11: 562},
64+
'L560': {0: 4, 1: 12, 2: 20, 3: 36, 4: 68, 5: 132, 6: 260, 7: 516, 8: 52, 9: 532, 10: 548, 11: 564}
5865
}
5966

6067

ibllib/pipes/behavior_tasks.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from pkg_resources import parse_version
66
import one.alf.io as alfio
77
from one.alf.files import session_path_parts
8+
from one.api import ONE
89

10+
from ibllib.oneibl.registration import get_lab
911
from ibllib.pipes import base_tasks
1012
from ibllib.io.raw_data_loaders import load_settings
1113
from ibllib.qc.task_extractors import TaskQCExtractor
@@ -455,7 +457,14 @@ def _run(self, upload=True):
455457
"""
456458
Extracts training status for subject
457459
"""
458-
df = training_status.get_latest_training_information(self.session_path, self.one)
460+
461+
lab = get_lab(self.session_path, self.one.alyx)
462+
if lab == 'cortexlab':
463+
one = ONE(base_url='https://alyx.internationalbrainlab.org')
464+
else:
465+
one = self.one
466+
467+
df = training_status.get_latest_training_information(self.session_path, one)
459468
if df is not None:
460469
training_status.make_plots(self.session_path, self.one, df=df, save=True, upload=upload)
461470
# Update status map in JSON field of subjects endpoint

ibllib/pipes/dynamic_pipeline.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
import ibllib.pipes.video_tasks as vtasks
2020
import ibllib.pipes.ephys_tasks as etasks
2121
import ibllib.pipes.audio_tasks as atasks
22-
from ibllib.pipes.photometry_tasks import TaskFibrePhotometryPreprocess, TaskFibrePhotometryRegisterRaw
22+
import ibllib.pipes.photometry_tasks as ptasks
23+
# from ibllib.pipes.photometry_tasks import FibrePhotometryPreprocess, FibrePhotometryRegisterRaw
2324

2425
_logger = logging.getLogger(__name__)
2526

@@ -307,9 +308,9 @@ def make_pipeline(session_path, **pkwargs):
307308
tasks[tn] = type((tn := f'VideoSyncQC_{sync}'), (vtasks.VideoSyncQcNidq,), {})(
308309
**kwargs, **video_kwargs, **sync_kwargs, parents=[tasks['VideoCompress']] + sync_tasks)
309310

310-
if len(video_kwargs['cameras']) == 3:
311-
tasks[tn] = type((tn := 'DLC'), (epp.EphysDLC,), {})(
312-
**kwargs, parents=[dlc_parent_task])
311+
if sync_kwargs['sync'] != 'bpod':
312+
tasks[tn] = type((tn := 'DLC'), (vtasks.DLC,), {})(
313+
**kwargs, **video_kwargs, parents=[dlc_parent_task])
313314
tasks['PostDLC'] = type('PostDLC', (epp.EphysPostDLC,), {})(
314315
**kwargs, parents=[tasks['DLC'], tasks[f'VideoSyncQC_{sync}']])
315316

@@ -357,11 +358,11 @@ def make_pipeline(session_path, **pkwargs):
357358
if 'photometry' in devices:
358359
# {'collection': 'raw_photometry_data', 'sync_label': 'frame_trigger', 'regions': ['Region1G', 'Region3G']}
359360
photometry_kwargs = devices['photometry']
360-
tasks['TaskFibrePhotometryRegisterRaw'] = type('TaskFibrePhotometryRegisterRaw', (
361-
TaskFibrePhotometryRegisterRaw,), {})(**kwargs, **photometry_kwargs)
362-
tasks['TaskFibrePhotometryPreprocess'] = type('TaskFibrePhotometryPreprocess', (
363-
TaskFibrePhotometryPreprocess,), {})(**kwargs, **photometry_kwargs, **sync_kwargs,
364-
parents=[tasks['TaskFibrePhotometryRegisterRaw']] + sync_tasks)
361+
tasks['FibrePhotometryRegisterRaw'] = type('FibrePhotometryRegisterRaw', (
362+
ptasks.FibrePhotometryRegisterRaw,), {})(**kwargs, **photometry_kwargs)
363+
tasks['FibrePhotometryPreprocess'] = type('FibrePhotometryPreprocess', (
364+
ptasks.FibrePhotometryPreprocess,), {})(**kwargs, **photometry_kwargs, **sync_kwargs,
365+
parents=[tasks['FibrePhotometryRegisterRaw']] + sync_tasks)
365366

366367
p = mtasks.Pipeline(session_path=session_path, **pkwargs)
367368
p.tasks = tasks

ibllib/pipes/ephys_preprocessing.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
from ibllib.io.video import label_from_path, assert_valid_label
2222
from ibllib.io.extractors import ephys_fpga, ephys_passive, camera
2323
from ibllib.pipes import tasks, base_tasks
24-
from ibllib.pipes.training_preprocessing import TrainingRegisterRaw as EphysRegisterRaw
25-
from ibllib.pipes.training_preprocessing import TrainingStatus as EphysTrainingStatus
24+
import ibllib.pipes.training_preprocessing as tpp
2625
from ibllib.pipes.misc import create_alyx_probe_insertions
2726
from ibllib.qc.alignment_qc import get_aligned_channels
2827
from ibllib.qc.task_extractors import TaskQCExtractor
@@ -1324,7 +1323,7 @@ def __init__(self, session_path=None, **kwargs):
13241323
self.session_path = session_path
13251324
# level 0
13261325
tasks['ExperimentDescriptionRegisterRaw'] = base_tasks.ExperimentDescriptionRegisterRaw(self.session_path)
1327-
tasks["EphysRegisterRaw"] = EphysRegisterRaw(self.session_path)
1326+
tasks["EphysRegisterRaw"] = tpp.TrainingRegisterRaw(self.session_path)
13281327
tasks["EphysPulses"] = EphysPulses(self.session_path)
13291328
tasks["EphysRawQC"] = RawEphysQC(self.session_path)
13301329
tasks["EphysAudio"] = EphysAudio(self.session_path)
@@ -1341,7 +1340,7 @@ def __init__(self, session_path=None, **kwargs):
13411340
self.session_path, parents=[tasks["EphysVideoCompress"], tasks["EphysPulses"], tasks["EphysTrials"]])
13421341
tasks["EphysCellsQc"] = EphysCellsQc(self.session_path, parents=[tasks["SpikeSorting"]])
13431342
tasks["EphysDLC"] = EphysDLC(self.session_path, parents=[tasks["EphysVideoCompress"]])
1344-
tasks['EphysTrainingStatus'] = EphysTrainingStatus(self.session_path, parents=[tasks["EphysTrials"]])
1343+
tasks['EphysTrainingStatus'] = tpp.TrainingStatus(self.session_path, parents=[tasks["EphysTrials"]])
13451344
# level 3
13461345
tasks["EphysPostDLC"] = EphysPostDLC(self.session_path, parents=[tasks["EphysDLC"], tasks["EphysTrials"],
13471346
tasks["EphysVideoSyncQc"]])

ibllib/pipes/photometry_tasks.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,55 @@
44
from collections import OrderedDict
55

66
from ibllib.pipes import tasks, base_tasks
7-
from ibllib.pipes.training_preprocessing import (
8-
TrainingRegisterRaw, TrainingAudio, TrainingTrials, TrainingDLC, TrainingStatus, TrainingVideoCompress)
7+
import ibllib.pipes.training_preprocessing as tpp
98
from ibllib.io.extractors.fibrephotometry import FibrePhotometry
109

1110
_logger = logging.getLogger('ibllib')
1211

1312

14-
class TaskFibrePhotometryRegisterRaw(base_tasks.RegisterRawDataTask):
13+
class FibrePhotometryRegisterRaw(base_tasks.RegisterRawDataTask):
1514

1615
priority = 100
1716
job_size = 'small'
1817

1918
def __init__(self, *args, **kwargs):
2019
super().__init__(*args, **kwargs)
2120
self.collection = self.get_task_collection(kwargs.get('collection', None))
21+
self.device_collection = self.get_device_collection('photometry', device_collection='raw_photometry_data')
2222

2323
@property
2424
def signature(self):
2525
signature = {
2626
'input_files': [],
27-
'output_files': [('_mcc_DAQdata.raw.tdms', self.collection, True),
28-
('_neurophotometrics_fpData.raw.pqt', self.collection, True)]
27+
'output_files': [('_mcc_DAQdata.raw.tdms', self.device_collection, True),
28+
('_neurophotometrics_fpData.raw.pqt', self.device_collection, True)]
2929
}
3030
return signature
3131

3232

33-
class TaskFibrePhotometryPreprocess(base_tasks.DynamicTask):
34-
signature = {
35-
'input_files': [('*fpData.raw*', 'raw_photometry_data', True), ],
36-
'output_files': [('photometry.signal.pqt', 'alf', True), ]
37-
}
33+
class FibrePhotometryPreprocess(base_tasks.DynamicTask):
34+
@property
35+
def signature(self):
36+
signature = {
37+
'input_files': [('_mcc_DAQdata.raw.tdms', self.device_collection, True),
38+
('_neurophotometrics_fpData.raw.pqt', self.device_collection, True)],
39+
'output_files': [('photometry.signal.pqt', 'alf/photometry', True)]
40+
}
41+
return signature
42+
3843
priority = 90
3944
level = 1
4045

4146
def __init__(self, session_path, regions=None, **kwargs):
4247
super().__init__(session_path, **kwargs)
4348
# Task collection (this needs to be specified in the task kwargs)
4449
self.collection = self.get_task_collection(kwargs.get('collection', None))
50+
self.device_collection = self.get_device_collection('photometry', device_collection='raw_photometry_data')
4551
self.regions = regions
4652

4753
def _run(self, **kwargs):
48-
_, out_files = FibrePhotometry(self.session_path, collection=self.collection).extract(
49-
regions=self.regions, save=True)
54+
_, out_files = FibrePhotometry(self.session_path, collection=self.device_collection).extract(
55+
regions=self.regions, path_out=self.session_path.joinpath('alf', 'photometry'), save=True)
5056
return out_files
5157

5258

@@ -63,13 +69,13 @@ def __init__(self, session_path=None, **kwargs):
6369
tasks = OrderedDict()
6470
self.session_path = session_path
6571
# level 0
66-
tasks['TrainingRegisterRaw'] = TrainingRegisterRaw(self.session_path)
67-
tasks['TrainingTrials'] = TrainingTrials(self.session_path)
68-
tasks['TrainingVideoCompress'] = TrainingVideoCompress(self.session_path)
69-
tasks['TrainingAudio'] = TrainingAudio(self.session_path)
72+
tasks['TrainingRegisterRaw'] = tpp.TrainingRegisterRaw(self.session_path)
73+
tasks['TrainingTrials'] = tpp.TrainingTrials(self.session_path)
74+
tasks['TrainingVideoCompress'] = tpp.TrainingVideoCompress(self.session_path)
75+
tasks['TrainingAudio'] = tpp.TrainingAudio(self.session_path)
7076
# level 1
71-
tasks['BiasedFibrePhotometry'] = TaskFibrePhotometryPreprocess(self.session_path, parents=[tasks['TrainingTrials']])
72-
tasks['TrainingStatus'] = TrainingStatus(self.session_path, parents=[tasks['TrainingTrials']])
73-
tasks['TrainingDLC'] = TrainingDLC(
77+
tasks['BiasedFibrePhotometry'] = FibrePhotometryPreprocess(self.session_path, parents=[tasks['TrainingTrials']])
78+
tasks['TrainingStatus'] = tpp.TrainingStatus(self.session_path, parents=[tasks['TrainingTrials']])
79+
tasks['TrainingDLC'] = tpp.TrainingDLC(
7480
self.session_path, parents=[tasks['TrainingVideoCompress']])
7581
self.tasks = tasks

0 commit comments

Comments
 (0)