Matlab code for analysis of calcium imaging data from the Drosophila brain, including motion correction, ROI segmentation, and detection of stimulus-modulated ROIs.
To process either 3DxT or 2DxT datasets:
-
- Convert tiffs to mat files (generate image data variable 'Data', and image metadata variable 'iDat').
-
- Pull extra information from metadata files ('.bin', '_vDat.mat', or '.mat' (LEDcontroler)).
-
- Do motion correction (using NoRMCorre).
-
- Do spatial and/or temporal resampling
- this includes re-slicing for volumetric datasets and aligment relative to stimuli delivery.
- generates main metadata variable used for ROI segmentation (wDat).
-
- select brain pixels (generate a binary mask).
-
- i) format stacks for ROI segmentation.
-
- ii) stitch (along z axis) and format stacks for ROI segmentation.
-
- ROI segmentation (in progress)
-
- Detect stimulus-modulated ROIs (in progress)
To register image segments to local whole brain and to in vivo atlas
- (in progress)
For processing of imaging data this pipeline requires the following packages:
- CaImAn, see link for dependencies.
- NoRMCorre, see link for dependencies.
- CMTK_matlab_wrapper, this requires the Computational Morphometry Toolkit CMTK
For processing of behavior videos with fictrac this pipeline requires the following packages:
- Fictrac, see link for installation & dependencies (for windows see fic-trac-win).
- generate calibration-transform.dat, and update that file in /toolbox/fictrac_offline/fictrac_settings
For saving figures install:
For stitching Z-stacks:
- fiji, make sure you have the bio format plugin, Imagescience plugin, stitching plugin(make sure you have Plugins/Stitching/Pairwise Stitching) and NIfTI plugin(make sure you have File/Save as/Analyze(nifti-1))
For interfacing with a cluster:
- download pu_cluster_interface (it requires the user defined temporary folder to save job parameters)
To use this package
- Copy and edit fiji_fullpathedit.m (see that file for details), and save as fiji_fullpath.m.
For examples see all the demos: FlyCaImAn_demo.m FlyCaImAn_behavior_only_demo.m FlyCaImAn_behavior_plus_stimuli_demo.m FlyCaImAn_behavior_plus_stimuli_plus_imaging_demo.m FlyCaImAn_imaging_only_demo.m FlyCaImAn_Zstack_demo.m
Special thanks to:
- Eftychios Pnevmatikakis and Andrea A. Giovannuci for help with CaImAn-MATLAB and NoRMCorre toolboxes
- Gregory Jefferis and Torsten Rohlfing for help with CMTK toolbox
If you use this code please cite the following paper: Pacheco, D.A., Thiberge, S.Y., Pnevmatikakis, E. et al. Auditory activity is diverse and widespread throughout the central brain of Drosophila. Nat Neurosci (2020). https://doi.org/10.1038/s41593-020-00743-y