Skip to content

Mesoscope qc #970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ibllib/pipes/dynamic_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,9 @@ def make_pipeline(session_path, **pkwargs):
**kwargs, **mscope_kwargs, **sync_kwargs)
tasks['MesoscopeCompress'] = type('MesoscopeCompress', (mscope_tasks.MesoscopeCompress,), {})(
**kwargs, **mscope_kwargs, parents=[tasks['MesoscopePreprocess']])
# TODO update with relevant parent dependencies once QC finalised
tasks['MesoscopeQC'] = type('MesoscopeCompress', (mscope_tasks.MesoscopeQC,), {})(
**kwargs, **mscope_kwargs, parents=[tasks['MesoscopePreprocess'], tasks['MesoscopeSync']])

if 'neurophotometrics' in devices:
# {'collection': 'raw_photometry_data', 'datetime': '2024-09-18T16:43:55.207000',
Expand Down
46 changes: 45 additions & 1 deletion ibllib/pipes/mesoscope_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from ibllib.pipes import base_tasks
from ibllib.oneibl.data_handlers import ExpectedDataset, dataset_from_name
from ibllib.io.extractors import mesoscope
import ibllib.qc.mesoscope as mesoQC


_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -503,7 +504,7 @@ def _consolidate_exptQC(exptQC):
qc_labels = ['ok']
frame_qc = []
for e in exptQC:
assert e.keys() >= set(['frameQC_names', 'frameQC_frames'])
assert e.keys() >= {'frameQC_names', 'frameQC_frames'}
# Initialize an NaN array the same size of frameQC_frames to fill with new enum values
frames = np.full(e['frameQC_frames'].shape, fill_value=np.nan)
# May be numpy array of str or a single str, in both cases we cast to list of str
Expand Down Expand Up @@ -1372,6 +1373,49 @@ def project_mlapdv(self, meta, atlas=None):
return mlapdv, location_id


class MesoscopeQC(base_tasks.MesoscopeTask):
"""Create FOV and FOV location objects in Alyx from metadata."""

priority = 40
job_size = 'small'

@property
def signature(self):
signature = {
'input_files': [('mpci.ROIActivityF.npy', 'alf/FOV*', True),
('mpci.ROINeuropilActivityF.npy', 'alf/FOV*', True),
('mpci.ROIActivityDeconvolved.npy', 'alf/FOV*', True),
('mpci.badFrames.npy', 'alf/FOV*', True),
('mpci.mpciFrameQC.npy', 'alf/FOV*', True),
('mpciFrameQC.names.tsv', 'alf/FOV*', True),
('mpciMeanImage.images.npy', 'alf/FOV*', True),
('mpciROIs.stackPos.npy', 'alf/FOV*', True),
('mpciROIs.mpciROITypes.npy', 'alf/FOV*', True),
('mpciROIs.cellClassifier.npy', 'alf/FOV*', True),
('mpciROIs.uuids.csv', 'alf/FOV*', True),
('mpciROITypes.names.tsv', 'alf/FOV*', True),
('mpciROIs.masks.sparse_npz', 'alf/FOV*', True),
('mpciROIs.neuropilMasks.sparse_npz', 'alf/FOV*', True),
('mpci.times.npy', 'alf/FOV*', True),
('mpciStack.timeshift.npy', 'alf/FOV*', True)],
'output_files': []
}
return signature

def _run(self, **kwargs):

assert self.eid
assert self.one and not self.one.offline

update = kwargs.pop('update', True)
outcome = mesoQC.MesoscopeQC.qc_session(self.eid, one=self, update=update, **kwargs)

if update:
mesoQC.update_dataset_qc_for_session(self.eid, outcome, [],
self.one, override=False)
return []


def surface_normal(triangle):
"""
Calculate the surface normal unit vector of one or more triangles.
Expand Down
Loading
Loading