SpectralSegmentatio​n

Open source ca imaging processing tools to aquire neural traces from 2 photon image sequences

11 Downloads

Updated Mon, 26 Sep 2022 12:57:10 +0000

From GitHub

View License on GitHub

SpecSeg: Cross spectral power-based segmentation of neurons and neurites in chronic calcium imaging datasets View SpectralSegmentation on File Exchange

This Github contains 'SpecSeg', an open source calcium imaging processing toolbox to detect regions of interest (ROIs) in calcium imaging datasets. ROI segmentation is based on cross-spectral power over a range of frequencies and has been tested and optimized for a variety of neuronal compartments (cell bodies, dendrites, axons) and (imaging) techniques (chronic glass windows, GRIN lenses, 1P, 2P). The SpecSeg toolbox contains user-friendly graphical interfaces to detect, adjust ROIs and visualize their activity traces. This pipeline includes code adapted from normcorre (Pnevmatikakis & Giovannucci 2016), to apply motion correction to sbx files. To be able to execute the motion correction, download the code from NoRMCorre and add the code into the matlab path below SpectralSegmentation.
Spike estimation can be done on the fluorescence traces, with code that uses MLspike (Deneux et al. 2016). MLspike requires the brick toolbox. Add MLspike and brick folders to the Matlab path.
This is the pipeline that is used by the Leveltlab in the Netherlands Institute of Neuroscience (NIN).

The pipeline is easily executable manually per step with the script SpectralPipeline.
Or via the script that runs the pipeline automatically for as many files as requested AutomatedPipeline, until RoiManagerGUI which requires manual input.

Readme's

Pipeline manual

RoiManagerGUI manual. User interface for data exploration and ROI editing

Why use the spectral segmentation toolbox

  • User-friendly.
  • Automatic ROI detection, with a user interface for a-priori selection of properties such as ROI size, minimum roundness, minimum signal correlation, etc.
  • Powerful ROI editor. Create new ROIs, split existing ROIs, delete ROIs manually or based on properties like size, roundness and spectral power. Visualize and explore the fluorescence data in many ways.
  • Designed for and tested on a range of techniques and neuronal compartments (cell bodies, dendrites, axons, 1P, 2P, chronic glass windows, chronic GRIN lenses, cortical and subcortical brain regions)
  • To increase speed and decrease memory load fluorescence data is transposed and memory mapped.
  • Some scripts increase speed by using parallel processing.
  • The cross-spectral power images that result from the spectral analysis show excellent separation of active neural elements from the background. The cross-spectral power has the advantage over correlation in the time domain of the fluorescence signal in that it has power over multiple different frequencies. Different frequencies contain different signal sources; noise can be visible in some frequencies, while neurons can be visible in others (see figure below).
  • Chronic tracking of ROIs over multiple sessions (imaged days to months apart).

This image shows results of the spectral analysis on two-photon calcium imaging in mouse V1. The average- and maximum fluorescence can show fluorescence that is not related to activity of neurons. For example, higher baseline fluorescence of a neuron that is not clearly active (cyan box, with its signal shown on the right), or lower baseline fluorescence in blood vessels (green box). However, the cross-spectral power images shows different active neurons, depending on the frequency. The red box indicates a neuron that was not visible in the average- and maximum fluorescence projection, but it is clearly visible in some of the cross-spectral power images. Therefore, these cross-spectral power images are very useful for ROI selection.

Installation

The SpecSeg pipeline only requires MATLAB to be able run on most operating systems.

  1. Download the SpecSeg code from this Github.

  2. To be able to use motion correction, download NoRMCorre.

  3. To be able to do spike estimation on ROI signals, download MLspike and brick.

  4. In MATLAB, add the folders from these repositories to your MATLAB path.

    Transposing datasets (StackTranspose.m) works via a MATLAB mex function. The mex function is compiled in MATLAB from the C++ code Zorder.cpp. For Windows 64-bit, and Mac 64-bit Zorder is compiled and should work automatically. However, for other operating systems it needs to be compiled for your system in MATLAB.

  5. (if necessary). Compile Zorder.cpp by setting MATLAB's current directory to SpectralSegmentation/Spectral/Dep and executing: mex Zorder.cpp For this to work a compiler must be installed in MATLAB, get information on that by executing mex -setup in MATLAB. To find a suitable compiler go to: https://www.mathworks.com/support/compilers. If you get the C++ compiler by installing Visual Studio, make sure to install: Desktop Development with C++.

Paper

A preprint has been published on biorxiv (Kraker et al. 2020).

Leander de Kraker, Koen Seignette, Premnath Thamizharasu, Bastijn J.G. van den Boom, Ildefonso Ferreira Pica, Ingo Willuhn, Christiaan N. Levelt, Chris van der Togt, SpecSeg is a versatile toolbox that segments neurons and neurites in chronic calcium imaging datasets based on low-frequency cross-spectral power, Cell Reports Methods, 2022, 100299, ISSN 2667-2375, https://doi.org/10.1016/j.crmeth.2022.100299.

Matlab dependencies

The following Matlab toolboxes are used in the Spectral Segmentation pipeline. They are required for some of the functions and scripts in the toolbox.

  • Image Processing Toolbox.
  • Signal Processing Toolbox.
  • Statistics and Machine Learning Toolbox.
  • Statistics Toolbox.
  • (optional) Parallel Computing Toolbox.
  • (optional) Polyspace Bug Finder.

Troubleshooting/ questions

For any questions, troubleshooting or comments, please contact Chris van der Togt (c.vandertogt@nin.knaw.nl) or Leander de Kraker (l.de.kraker@nin.knaw.nl). Or open an issue in this Git.

Developers

  • Chris v.d. Togt. Netherlands Insititue of Neuroscience (NIN)
  • Leander de Kraker. Netherlands Insititue of Neuroscience (NIN)

cite as: Leander de Kraker, & Chris van der Togt. (2022). Leveltlab/SpectralSegmentation: Public Release 1.0.1 (V1.01). Zenodo. https://doi.org/10.5281/zenodo.6993003

License

This software is published under creative common license CC-BY-NC 4.0

3rd party functions & toolboxes

Download the code from these toolboxes to be able to use them in the Spectral Segmentation toolbox.

  • Motion correction code NoRMCorre is adapted to process .sbx files. Place the NoRMCorre path below the SpectralSegmentation path in Matlab.
  • ROI calcium signal signal spike estimation with MLspike.

The following 3rd party functions are used in the spectral segmentation toolbox, they are already present in the Spectral Segmentation toolbox.

References

  • Deneux, T., Kaszas, A., Szalay, G., Katona, G., Lakner, T., Grinvald, A., Rózsa, B. & Vanzetta, I. (2016) Accurate spike estimation from noisy calcium signals for ultrafast three-dimensional imaging of large neuronal populations in vivo. Nature Communications 7, 12190. doi: 10.1038/ncomms12190

  • Eftychios A. Pnevmatikakis and Andrea Giovannucci, (2017) NoRMCorre: An online algorithm for piecewise rigid motion correction of calcium imaging data, Journal of Neuroscience Methods, vol. 291, pp 83-94, 2017; doi: /10.1016/j.jneumeth.2017.07.031

  • Kraker L., Seignette, K., Thamizharasu, P., Pica, I.F., Levelt, C.N. & Togt, C. (2020) Specseg: cross spectral power-based segmentation of neurons and neurites in chronic calcium imaging datasets. doi: 10.1101/2020.10.20.345371

Cite As

Leanderrr, and Chris Van Der Togt. Leveltlab/SpectralSegmentation: Public Release 1.0.1. Zenodo, 2022, doi:10.5281/ZENODO.6993003.

View more styles

Leander de Kraker and Chris Van Der Togt. Leveltlab/SpectralSegmentation: Public Release 1.0.1. Zenodo, 2022, doi:10.5281/ZENODO.6993003.

MATLAB Release Compatibility
Created with R2022b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.02

See release notes for this release on GitHub: https://github.com/Leveltlab/SpectralSegmentation/releases/tag/v1.02

1.01

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.