Code Monkey home page Code Monkey logo

suite2p's Introduction

Suite2p: fast, accurate and complete two-photon pipeline

Registration, cell detection, spike extraction and visualization GUI.

Algorithmic details in http://biorxiv.org/content/early/2016/06/30/061507.

IMG

This code was written by Marius Pachitariu, Carsen Stringer and members of the cortexlab (Kenneth Harris and Matteo Carandini). It is provided here with no warranty. For support, please open an issue directly on github.

For the python version of the code, go here. We recommend using the python code - the documentation is better (see wiki), and the graphical interface has more functionality. We also are going to discontinue updating the matlab version.

Examples

An example dataset (with master_file and make_db) is provided here.

I. Introduction

This is a complete, automated pipeline for processing two-photon Calcium imaging recordings. It is simple, fast and yields a large set of active ROIs. A GUI further provides point-and-click capabilities for refining the results in minutes. The pipeline includes the following steps

  1. X-Y subpixel registration: using a modification of the phase correlation algorithm and subpixel translation in the FFT domain. If a GPU is available, this completes in 20 minutes per 1h of recordings at 30Hz and 512x512 resolution.

  2. SVD decomposition: this provides the input to cell detection and accelerates the algorithm.

  3. Cell detection: using clustering methods in a low-dimensional space. The clustering algorithm provides a positive mask for each ROI identified, and allows for overlaps between masks. There is also an option to perform automated red cell detection.

  4. Signal extraction: by default, all overlapping pixels are discarded when computing the signal inside each ROI, to avoid using "demixing" approaches, which can be biased. The neuropil signal is also computed independently for each ROI, as a weighted pixel average, pooling from a large area around each ROI, but excluding all pixels assigned to ROIs during cell detection.

  5. Spike deconvolution: cell and neuropil traces are further processed to obtain an estimate of spike times and spike "amplitudes". The amplitudes are proportional to the number of spikes in a burst/bin. Even under low SNR conditions, where transients might be hard to identify, the deconvolution is still useful for temporally-localizing responses. The cell traces are baselined using the minimum of the (overly) smoothed trace.

  6. Neuropil subtraction: coefficient is estimated iteratively together with spike deconvolution to minimize the residual of spike deconvolution. The user is encouraged to also try varying this coefficient, to make sure that any scientific results do not depend crucially on it.

  7. Automatic and manual curation: the output of the cell detection algorithm can be visualized and further refined using the included GUI. The GUI is designed to make cell sorting a fun and enjoyable experience. It also includes an automatic classifier that gradually refines itself based on the manual labelling provided by the user. This allows the automated classifier to adapt for different types of data, acquired under different conditions. (README FOR GUI AT https://github.com/cortex-lab/Suite2P/blob/master/gui2P/README.md)

II. Getting started

The toolbox runs in Matlab and currently only supports tiff file inputs. To begin using the toolbox, you will need to make local copies (in a separate folder) of two included files: master_file and make_db. It is important that you make local copies of these files, otherwise updating the repository will overwrite them (and you can lose your files). The make_db file assembles a database of experiments that you would like to be processed in batch. It also adds per-session specific information that the algorithm requires such as the number of imaged planes and channels. The master_file sets general processing options that are applied to all sessions included in make_db, UNLESS the option is over-ridden in the make_db file.

Example database entry

Look into make_db_example for more detailed examples.

The following is a typical database entry in the local make_db file, which can be modelled after make_db_example. The folder structure assumed is RootStorage/mouse_name/date/expts(k) for all entries in expts(k).

i = i+1; 
db(i).mouse_name = 'M150329_MP009'; 
db(i).date = '2015-04-27'; 
db(i).expts = [5 6]; % which experiments to process together

Other (hidden) options are described in make_db_example.m, and at the top of run_pipeline.m (set to reasonable defaults).

Running the pipeline

Change paths in master_file to the paths to your local toolbox and to your data. Then run this function. The master_file creates the ops0 variable and the db0 variable, and runs the main pipeline:

run_pipeline(db, ops);

Spike deconvolution

For spike deconvolution, you need to download the OASIS github (https://github.com/zhoupc/OASIS_matlab) and add the path to this folder on your computer to the top of your master_file

addpath(genpath('pathtoOASIS')))

To run spike deconvolution (after running the pipeline), run

add_deconvolution(ops0, db);

For L0 spike deconvolution, you need to run mex -largeArrayDims SpikeDetection/deconvL0.c (or .cpp under Linux/Mac). If you're on Windows, you will need to install Visual Studio Community in order to mex files in matlab. To choose this deconvolution method, set

ops0.deconvType = 'L0';

See this paper comparing spike deconvolution methods for more information on choosing deconvolution methods/parameters: http://www.biorxiv.org/content/early/2017/06/27/156786

You can also run spike deconvolution without running the entire pipeline by calling wrapperDECONV(ops,F,N), where F and N are the fluorescence and neuropil traces respectively, while ops specifies some deconvolution parameters like sampling rate and sensory decay timescale. See the function help for more information.


Below we describe the outputs of the pipeline first, and then describe the options for setting it up, and customizing it. Importantly, almost all options have pre-specified defaults. Any options specified in master_file in ops0 overrides these defaults. Furthermore, any option specified in the make_db file (experiment specific) overrides both the defaults and the options set in master_file. This allows for flexibility in processing different experiments with different options. The only critical option that you'll need to set is ops0.diameter, or db(N).diameter. This gives the algorithm the scale of the recording, and the size of ROIs you are trying to extract. We recommend as a first run to try the pipeline after setting the diameter option. Depending on the results, you can come back and try changing some of the other options.

Note: some of the options are not specified in either the example master_file or the example make_db file. These are usually more specialized features.

III. Outputs.

The output is a struct called dat which is saved into a mat file in ResultsSavePath using the same subfolder structure, under a name formatted like F_M150329_MP009_2015-04-29_plane1. It contains all the information collected throughout the processing, and contains the ROI and neuropil traces in Fcell and FcellNeu, and whether each ROI j is a cell or not in stat(j).iscell. stat(j) contains information about each ROI j and can be used to recover the corresponding pixels for each ROI in stat.ipix. The centroid of the ROI is specified in stat as well. Here is a summary of where the important results are:

cell traces are in Fcell
neuropil traces are in FcellNeu

deconvolved traces are in sp

Each cell of the above structures is a different experiment from db.expts. manual, GUI overwritten "iscell" labels are in stat.iscell

stat(icell) contains all other information:

  • iscell: automated label, based on anatomy
  • neuropilCoefficient: multiplicative coefficient on the neuropil signal
  • xpix, ypix: x and y indices of pixels belonging to this max. These index into the valid part of the image (defined by ops.yrange, ops.xrange).
  • ipix: linearized indices ((ypix, xpix) --> ypix + (xpix-1) x Ly) of pixels belonging to this mask.
  • isoverlap: whether the pixels overlap with other masks.
  • lam, lambda: mask coefficients for the corresponding pixels. lambda is the same as lam, but normalized to 1.
  • med: median of y and x pixels in the ROI (indices for the valid part of the image, defined by ops.yrange, ops.xrange).
  • blockstarts: the cumulative number of frames per block. Clould be useful for concatenating experiments correctly (some planes will have fewer frames/block).
  • footprint, mrs, mrs0, cmpct, aspec_ratio, ellipse, mimgProj, skew, std, maxMinusMed, top5pcMinusMed: these are used by the automated classifier to label an ROI as cell or not. see section IX for details.

There are fields for red cell detection too (see the section on Identifying red cells)

The settings for the registration and the mean image are also output in the ops structure:

  • mimg: target mean image computed at the beginning of registration to which all frames are aligned
  • mimg1: mean image computed from all the frames across all experiments
  • DS: offsets computed in XY

IV. Input-output file paths

  • RootStorage --- the root location where the raw tiff files are stored.
  • RegFileRoot --- location on local disk where to keep the registered movies in binary format. This will be loaded several times so it should ideally be an SSD drive. (to view registered movies use script "view_registered_binaries.m" in main folder)
  • ResultsSavePath --- where to save the final results.
  • DeleteBin --- deletes the binary file created to store the registered movies
  • RegFileTiffLocation --- where to save registered tiffs (if empty, does not save) if you want to save red tiffs, then specify ops.RegFileTiffLocation and set ops.REDbinary = 1

ResultsSavePath is completed with separate subfolders per animal and experiment, specified in the make_db file. Your data should be stored under a file tree of the form

\RootStorage\mouse_name\session\block*.tif(f)

If you don't want to use this folder structure, see the make_db_example file for alternatives. The make_db_example file also shows how to group together tiffs from different experiments (i.e. different subfolders within this folder structure).

The output is a struct called dat which is saved into a mat file in ResultsSavePath using the same subfolder structure, under a name formatted like F_M150329_MP009_2015-04-29_plane1. It contains all the information collected throughout the processing, and contains the fluorescence traces in dat.Fcell and whether a given ROI is a cell or not in dat.stat(N).iscell. dat.stat contains information about each ROI and can be used to recover the corresponding pixels for each ROI N in dat.stat(N).ipix. The centroid of the ROI N is specified in dat.stat(N) as well.

V. Options

Registration

  • showTargetRegistration --- whether to show an image of the target frame immediately after it is computed.
  • PhaseCorrelation --- whether to use phase correlation (default is phase-correlation, if 0 then cross-correlation used).
  • SubPixel --- accuracy level of subpixel registration (default is 10 = 0.1 pixel accuracy)
  • kriging --- compute shifts using kernel regression with a gaussian kernel of width 1 onto a grid of 1/SubPixel (default is kriging = 1)
  • maxregshift --- maximum amount of movement allowed in FOV (default is 10% of max(y pixels, x pixels))
  • maskSlope --- slope on the taper mask applied to image (default is 2 pixel exponential decay)
  • NimgFirstRegistration --- number of randomly sampled images to compute target image from
  • NiterPrealign --- number of iterations for the target computation (iterative re-alignment of subset of frames)
  • smooth_time_space --- convolves raw movie with a Gaussian of specified size in specified dimensions; [t]: convolve in time with gauss. of std t, [t s]: convolve in time and space, [t x y]: convolve in time, and in space with an ellipse rather than circle
  • nimgbegend --- number of frames over which to average at beginning and end of experiment (if worried about drift) (default is 0 frames)

Block Registration (for high zoom/npixels)

  • nonrigid --- set to 1 for non-rigid registration (or set numBlocks > 1)
  • numBlocks --- 1x2 array denoting the number of blocks to divide image in y and x (default is [8 1])
  • blockFrac --- percent of image to use per block (default is 1/(numBlocks-1))
  • quadBlocks --- interpolate block shifts to single line shifts (6 blocks -> 512 lines) by fitting a quadratic function (default is 1)
  • smoothBlocks --- if quadBlocks = 0, then smoothBlocks is the standard deviation of the gaussian smoothing kernel

Bidirectional scanning issues (frilly cells - default is to correct)

  • dobidi --- compute bidirectional phase offset from images (default 1)
  • BiDiPhase --- value of bidirectional phase offset to use for computation (will not compute bidirectional phase offset)

Recordings with red channel

  • AlignToRedChannel --- perform registration to red channel (non-functional channel) rather than green channel (this assumes that you have a red channel for all recordings in db.expts)
  • redMeanImg --- compute mean image of red channel from experiments with red and green channel (you do not need to have a red channel for all db.expts, computes only from db.expred -- so make sure this isn't empty!!)
  • REDbinary --- compute a binary file of the red channel (like the green channel binary) from db.expred

output ops.mimgRED will contain mean image (if AlignToRedChannel, redMeanImg or REDbinary = 1)

Splitting large tiffs for registration if running out of memory (e.g. 2048 x 2048 pixel images) currently only works with rigid registration, where each section of FOV is registered separately

  • splitFOV --- 1x2 array specifying chunk size in y and x (default is [1 1])

Cell detection

  • sig --- spatial smoothing constant: smooths out the SVDs spatially. Indirectly forces ROIs to be more round.
  • nSVDforROI --- how many SVD components to keep for clustering. Usually ~ the number of expected cells.
  • ShowCellMap --- whether to show the clustering results as an image every 10 iterations of the clustering
  • getROIs --- whether to run the ROI detection algorithm after registration
  • stopSourcery --- stop clustering if # of ROIs extracted < (ROIs extracted on iteration 1) x (stopSourcery) (default is 1/10)
  • maxIterRoiDetection --- maximum number of clustering iterations (default is 100)
  • refine --- whether or not to refine ROIs - suite2p smooths the PCs to find masks, refinement uses unsmoothed PCs to recompute masks from smoothed estimates

SVD decomposition

  • NavgFramesSVD --- for SVD, data has to be temporally binned. This number specifies the final number of points to be obtained after binning. In other words, datasets with many timepoints are binned in higher windows while small datasets are binned less.
  • getSVDcomps --- whether to obtain and save to disk SVD components of the registered movies. Useful for pixel-level analysis and for checking the quality of the registration (residual motion will show up as SVD components). This is a separate SVD decomposition from that done for cell clustering (does not remove a running baseline of each pixel).
  • nSVDforROI --- how many SVD components to keep.
  • getSVDcomps --- whether to obtain and save to disk SVD components of the registered movies. Useful for pixel-level analysis and for checking the quality of the registration (residual motion will show up as SVD components). This is a separate SVD decomposition from that done for cell clustering (does not remove a running baseline of each pixel).
  • nSVD --- if getSVDcomps=1, then nSVD specifies how many components to save

Signal extraction

  • signalExtraction --- how should the fluorescence be extracted? The 'raw' option restricts cells to be non-overlapping, 'regression' option allows cell overlaps. The neuropil model is a set of spatial basis functions that tile the FOV. The 'surround' option means that the cell's activity is the weighted sum of the detected pixels (weighted by lambda). The neuropil is computed as the sum of activity of surrounding pixels (excluding other cells in the computation).

Neuropil options

  • ratioNeuropil --- used for both spatial basis functions and surround neuropil - the spatial extent of the neuropil as a factor times the radius of the cells (ops.ratioNeuropil * cell radius = neuropil radius)

if using surround neuropil (signalExtraction = 'surround')

  • innerNeuropil --- padding in pixels around cell to exclude from neuropil
  • outerNeuropil --- radius of neuropil surround (set to Inf to use ops.ratioNeuropil)
  • minNeuropilPixels --- minimum number of pixels in neuropil surround (radius will expand until this number is reached)

Spike deconvolution

  • imageRate --- imaging rate per plane.
  • sensorTau --- decay timescale (in seconds).
  • maxNeurop --- neuropil contamination coef has to be less than this (sometimes good to impose a ceiling at 1, i.e. for interneurons)
  • deconvType --- which type of deconvolution to use (either 'L0' or 'OASIS')

Identifying red cells

use function identify_redcells_sourcery(db, ops0) to identify cells with red

Outputs are appended to stat in F.mat file

  • redratio = red pixels inside / red pixels outside
  • redcell = redratio > mean(redratio) + redthres x std(redratio)
  • notred = redratio < mean(redratio) + redmax x std(redratio)

Options are

  • redthres --- higher thres means fewer red cells (default 1.35)
  • redmax --- the higher the max the more NON-red cells (default 1)

Measures used by classifier

The Suite2p classifier uses a number of features of each ROI to assign cell labels to ROIs. The classifier uses a naive Bayes approach for each feature, and models the distribution of each feature with a non-parametric, adaptively binned empirical distribution. The classifier is initialized with some standard distributions for these features, but is updated continuously with new data samples as the user refines the output manually in the GUI.

The features used are the following (can see values for each ROI by selecting it in the GUI).

  • std = standard deviation of the cell trace, normalized to the size of the neuropil trace
  • skew = skewness of the neuropil-subtracted cell trace
  • pct = mean distance of pixels from ROI center, normalized to the same measuree for a perfect disk
  • footprint = spatial extent of correlation between ROI trace and nearby pixels
  • mimgProjAbs = whether this ROI shape is correlated to the shape on the mean image
  • aspect_ratio = of an ellipse fit to the ROI

suite2p's People

Contributors

boazmohar avatar carsen-stringer avatar fralik avatar hwpdalgleish avatar lfedros avatar llerussell avatar mariodipoppa avatar marius10p avatar mkrumin avatar pipcoen avatar sfailor avatar swkeemink avatar sylviaschroeder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

suite2p's Issues

Making fixed variables as input parameters

in get_signals_and_neuropil, neuropil radius, microscope zoom, inner radius of the neuropil mask are fixed variables. We should make them input parameters in make_db. Number of pixels of each frames can instead be read from the tiff file.

Change neuropil basis function scale with zoom

Does the scale of the basis function used for the neuropil model change with the zoom, or even more precisely with the microns/pixels (for images with same zoom but different resolution) of the recording?

deal with bad frames

Sometimes a frame is completely dark, or screwed up in some way. These should be correctly identified, and carefully excluded from further analysis.

Integrating red and green channels

It is important to integrate information from the red channel with that from the green channels. The ROIs detection should be independent in the two channels, and the second one only needs the mean fluorescence (this detection could be an option of the gui). Once the ROIs of somata and dendrites are selected, one could compare the two (this could be another option of the gui). Looking at the contour the gui/and or the user will decide whether to merge two overlapping ROIs or delete the overlap.

add back soft signal extraction

Due to the possibility of overlapping ROIs in the "Sourcery" version, I had removed the simpler signal and neuropil extraction method (computing signal inside and outside of ROIs).

We can add this back if we discard all overlapping pixels. In addition, we must ensure that the contaminated pixels are not used for neuropil subtraction.

Errors when not using GPU

Hello,
I've just started using your software and have encountered problems related to not having an Nvidia GPU (my machine has an AMD card).
In master_file I have set
ops0.useGPU = false

So far I have encountered errors at two stages during registration, with reg2P.


ERROR 1::

Error using gpuDevice (line 26)
There is a problem with the CUDA driver or
with this GPU device. Be sure that you have
a supported GPU and that the latest driver
is installed.

Error in getBatchSize (line 3)
g = gpuDevice;

Error in register_movie (line 6)
nFramesPerBatch = getBatchSize(w*h);

Error in align_iterative (line 20)
dreg = register_movie(data, ops,
dsnew);

Caused by:
The CUDA driver could not be loaded.
The library name used was 'nvcuda.dll'.
The error was:
The specified module could not be
found.


This error occurs when register_movie calls getBatchSize, which in turn calls gpuDevice.
To temporarily get around this error I commented out the call to getBatchSize and set
nFramesPerBatch = 2 in register_movie.

However, I then get a second error later in reg2P:


ERROR 2::
There is a problem with the CUDA driver or
with this GPU device. Be sure that you have
a supported GPU and that the latest driver
is installed.

Error in regoffKriging (line 128)
dl =
gpuArray(single(-lpad:1:lpad));

Error in GetRegOffsets (line 13)
[ds, Corr] = regoffKriging(dat,
ops1{i,l}, 0);

Error in reg2P (line 132)
[dsall, ops1] =
GetRegOffsets(data, j, iplane0,
ops, ops1, yFOVs, xFOVs);

Caused by:
The CUDA driver could not be loaded.
The library name used was 'nvcuda.dll'.
The error was:
The specified module could not be
found.


As far as I can see, the call to gpuArray in regoffKriging occurs whether or not useGPU is true.

Please advise. Thanks very much for your help.

Issue in the F file

In an F file generated by suite2P, for one cell number #icell
stat(#icell).ipix
is an empty array. Is this normal?

This create a bug later in createNeuropilMask when it is trying to compute the centroid

standalone deconvolution questions

i) Is the output of the algorithm particularly sensitive to the parameters provided?

ii) When using Suite2P, how do you suggest handling missing data points? Would setting them to zero Vs stripping them out (shortening the recording) bias the output of the deconvolution particularly?

gui2P background and mask

For better visual inspection, the background should remain visible when changing the mask.
For example, when choosing the mean projection as background, the mask should be overlaid
on the mean projection.

Cell signal inversion

I am having a weird issue, where some of my dF/F traces will be inverted (deflections in the negative direction and the dF/F value computed is also negative).

This seems to only happen to a subset of cells in any field of view and after several attempts I have not been able to nail down what is causing this. I suspected it has something to do with the neuropil calculation but trying variations on the basis as well as tiling does not seem to resolve the issue. Has anyone else seen this before or have any ideas?

Suite 2P not converging.

I have a few recordings where Suite2P doesn't converge and continues to identify ROI's. Is it possible to change the stopping criterion in the master_file?

Example terminal output:
3957 total ROIs, err 1.1211, thresh 0.0022
3969 total ROIs, err 1.1205, thresh 0.0022
3980 total ROIs, err 1.1201, thresh 0.0022
3993 total ROIs, err 1.1199, thresh 0.0022
4003 total ROIs, err 1.1193, thresh 0.0022
4014 total ROIs, err 1.1192, thresh 0.0022
4023 total ROIs, err 1.1187, thresh 0.0022
4033 total ROIs, err 1.1191, thresh 0.0022
4046 total ROIs, err 1.1182, thresh 0.0022
4056 total ROIs, err 1.1178, thresh 0.0022
4068 total ROIs, err 1.1174, thresh 0.0022
4080 total ROIs, err 1.1175, thresh 0.0022
4095 total ROIs, err 1.1169, thresh 0.0022
4110 total ROIs, err 1.1165, thresh 0.0022
4118 total ROIs, err 1.1163, thresh 0.0022
4129 total ROIs, err 1.1158, thresh 0.0022
...

Retrieve neuropil basis function

It would be useful to retrieve the traces and the maps of the basis functions used to model the neuropil. It would allow to make maps of neuropil-only responses. Is this info already available somewhere in the dat structure? Thanks, Federico

Support for separate Tiffs

It'd be really useful if there were support for lists of tiff files that are individual images rather than image stacks. Doing the conversion manually can be very time consuming, even on 3000 frames. With the bigger datasets, it becomes prohibitive.

Documentation non-rigid registration

It would be great if you could include an example master_file.m for using non-rigid registration or expand the documentation to list what options need to be set for non-rigid registration to work. It's not clear what values ops.splitBlocks or ops.splitTaper should take, and what additional options may need to be defined.

Suggested changes to options

  1. Naming in the option structure is a bit chaotic. How painful would it be to rename some of the options to to make them more intuitive and consistent? e.g. nimgbegend, Nk Nk0 and niterclustering and RootStorage. Ideally all options would be reasonably understandable from their name and would have consistent casing, that is idiomatic MATLAB. MathWorks usually use camelCasing for structure fields with a lower case initial letter. We could also use substructures to create namespaces to help further tidy it up. e.g. ops.reg.targetFrame.
  2. Many of the functions would be more lightweight if they didn't require the options structure to be passed in and used some sensible defaults. I suggest we make it an optional last argument of the functions. A simple way to reduce the code overhead for handling defaults inside the functions is to use a pattern like theOption = getOr(ops, 'theOption', 'some default value').

Classify somata and dendrites

It could be useful to classify somata and dendrites. Even if we use only somata for analysis, the dendrite ROIs could be subtracted from the neuropil masks. One possibility would be to put both somata and dendrites on the left, somata having warm colors and dendrites cold colors. To classify well dendrites it is probably necessary to well inspect the mean signal, therefore one could have three options for the field of views: only colored ROIs, only grey mean fluorescence and one additional image with mean fluorescence as brightness and ROIs as hue.

ichanset(1) off by 1?

in reg2Pnew.m, line 60

ichanset(1), the index of the first Tiff page to load, seems to consistently be off by 1. It is always 2 in my hands. This prevents being able to process a folder of single-page tiffs, but is generally OK with multipage tiffs.

Registration error for certain image sizes

Hi,

I'm getting errors during registration for certain values of image size. I therefore ran some tests, trying to register the same movie after cropping to different sizes.

My movie is 1024x1024 pixels x 881 frames. This works fine, and also registers if I crop to 767x768 or 512x512 pixels. However, 1023x1023 and 767x767 cause crashes as per below:


ERROR with 1023x1023 (x881 frames) and with 767x767 (x881 frames)::

running rigid registration
Error using .*
Array dimensions must match for binary
array op.

Error in BiDiPhaseOffsets (line 18)
cc = ifft(d1 .* d2,[],2);

Error in reg2P (line 44)
BiDiPhase = BiDiPhaseOffsets(IMG);


Stand-alone calcium deconvolution function

Currently deconvolution of calcium trace can be performed only on output data from suite2P. It would be useful a function that takes as an input any matrix of fluorescence data [#cells x time points] plus a vector of real times.

Neurofinder

This isn't really an issue, but wanted to let you know that I ran your algorithm on the neurofinder datasets and uploaded the results. We ran it with all the defaults but no registration or deconvolution, and thresholded using the standard deviation of the traces.

Your algorithm is currently doing the best! If you want to discuss, feel free to open an issue on the neurofinder repo.

Mean image range

It would be useful to change the range of the mean image so that dimmer cells can become visible. One could also add an option of some spatial filtering (with a difference of gaussian) so that it is possible to view at the same time part of the image with different background fluorescence.

Phase correlation alignment glitch?

Generally phase correlation alignment works nicely, but sometimes it fails for data-sets that have weaker signal. Below is one example where the algorithm is "fixing" two frames at the beginning (large spikes) that do not need fixing (I have checked the raw data).
Is there some simple trick/modification that I could try to make the algorithm less likely to do such corrections? For example, should I turn off phase-correlation and/or smooth the data before entering it into alignment?

alignment_glitch

add hard and soft categorization labels to each ROI

Currently only "soft" labels are provided: could this be an ROI at all? Then we load the soft-labelled ROIs into the GUI and play with the ROI criteria on a dataset by dataset basis.

We should also have a "hard" label: if you pushed the algorithm to give you its best guess, which ROIs would be classified as cells? @syncrostone, this will be the label that should be used for the neurofinder challenge.

trim low-weight pixels for the ROI masks

We have not bothered with this in the past, because the pixels were not used to compute fluorescence (only the weighted masks).

@syncrostone This will help on the neurofinder challenge for the inclusion and exclusion scores.

robustness of automated cell labelling

The across-ROI normalization of the statistics should be based only on ROIs within a certain confidence criterion: the "obviously not cells" should be excluded.

A mechanism should be provided to completely over-ride the priors set by default: just make them count for many fewer ROIs (currently 500).

hdf5 files

Reading different data formats in Suite2p.

Saving error in the main GUI

Hi
I am getting a save error after I have processed in the main GUI, this message appears when I press the 'save proc file' button:

"Reference to non-existent field 'statLabels'.

Error in new_main>pushbutton84_Callback (line 222)
statLabels = h.statLabels;

Error in gui_mainfcn (line 95)
feval(varargin{:});

Error in new_main (line 17)
gui_mainfcn(gui_State, varargin{:});

Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)new_main('pushbutton84_Callback',hObject,eventdata,guidata(hObject))

Error while evaluating UIControl Callback"

Any idea why this might be happening?

Thanks,
Kath

error in get_svdForROI

Hi Marius,

I'm getting the following error:


Subscript indices must either be real
positive integers or logicals.

Error in get_svdForROI (line 47)
mov(:,:,ix + (1:size(davg,3))) =
davg(ops.yrange, ops.xrange, :);


Checking ops.xrange and ops.yrange, I find they extend from 0 to 767 (for a 768x768 movie) but 0 is not valid for indexing davg.

Isaac

Bug in new_main

I got the following bug:
Reference to non-existent field 'region'.
Error in get_parent_stats (line 6)
h.dat.stat(i).V = sum([h.dat.stat(i).region.V]);

I'm not sure where h.dat.stat(i).region should be computed in suite2P

Slow drifts in the data (should I worry?)

Hi

This is not really an issue/defect on Suite2P, but a more general question about Suite2P capabilities.

In our data there is occasionally noticeable slow mean intensity drifting, which leads to large discontinuities when multiple files are joined together. I the example dataset shown here, I have joined together 26 recording sessions with total length of 86min. Mean signal intensity decreases slowly for all ROIs, until baseline is recovered at mid experiment (more water was added over the window).

Can Suite2P process this type of data reliably?
What kind of effect such large drifts/discontinuities have on ROI clustering, neuropil estimation and deconvolution?

I could try to remove these drifts after alignment is finished (that huge .bin file). Some high-pass filtering/regression should do the trick.

water_loss_example_2068_2r_170124

call CUDA fft directly

Whatever Matlab is doing, new versions have limited more and more the size of the maximum batch to do the ffts. This should not be a difficult operation, so we should figure out how to improve on it.

Folder structure for raw data

I'm suggesting to make the expected path where to find the raw 2P data more flexible. Right now Suite2P expects the data in '...<animal_name><date><experiment ID>. Instead one could define path components, like animal name, in the data base file, as is done already, and then specify the exact path made up of these components and possibly other folders inside the master file, which is defined by each user separately.

spike time indexing

I have a problem with matching up the spike times/amps with the calcium traces... I selected cells using the GUI and plotted the Calcium traces (dat.F.Fcell{dat.cl.iscell}) and then I plotted with it the spike times/amps (dat.cl.dcell{dat.cl.iscell}.st), the spike times do not seem to line up well with my Ca2+ traces... is the indexing of the spike times different to the calcium traces? I have pasted some examples below (the Ca2+ trace is in grey @30fps and the spikes blue):
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.