-
Notifications
You must be signed in to change notification settings - Fork 21
Manual cell sorting of cell extraction outputs
Please use the online documentation website going forward: https://bahanonu.github.io/ciatah/
This page will go over best practices and common issues seen when sorting cells from PCA-ICA. Advice can also apply to other cell sorting algorithms (CNMF, etc.).
As a general note, it is a bad idea to bias users by using heuristics or computational models to pre-select or guess whether a cell extraction output is a cell or non-cell. This will skew results toward whatever the heuristics or model are looking for rather than reveal the true preferences of the user.
Usage instructions below for signalSorter.m
:
Main inputs
-
inputImages
- [x y N] matrix where N = number of images, x/y are dimensions. -
inputSignals
- [N frames] double matrix where N = number of signals (traces). -
inputMovie
- [x y frames] matrix
Main outputs
-
choices
- [N 1] vector of 1 = cell, 0 = not a cell -
inputImagesSorted
- [x y N] filtered by `choices' -
inputSignalsSorted
- [N frames] filtered bychoice
iopts.inputMovie = inputMovie; % movie associated with traces
iopts.valid = 'neutralStart'; % all choices start out gray or neutral to not bias user
iopts.cropSizeLength = 20; % region, in px, around a signal source for transient cut movies (subplot 2)
iopts.cropSize = 20; % see above
iopts.medianFilterTrace = 0; % whether to subtract a rolling median from trace
iopts.subtractMean = 0; % whether to subtract the trace mean
iopts.movieMin = -0.01; % helps set contrast for subplot 2, preset movie min here or it is calculated
iopts.movieMax = 0.05; % helps set contrast for subplot 2, preset movie max here or it is calculated
iopts.backgroundGood = [208,229,180]/255;
iopts.backgroundBad = [244,166,166]/255;
iopts.backgroundNeutral = repmat(230,[1 3])/255;
[inputImagesSorted, inputSignalsSorted, choices] = signalSorter(inputImages, inputSignals, 'options',iopts);
For imaging movies that are too large to fit into RAM or that are stored on remote systems, run the below commands. Remember to change inputImages
, inputSignals
, iopts.inputMovie
, and iopts.inputDatasetName
to values appropriate for your data). Note: only HDF5 files are supported with this feature due to use of spatial chunking.
% CRITICAL USER PARAMETERS
% Input images and signals, change from PCA-ICA to whatever is appropriate for input from user's cell extraction algorithm.
inputImages = pcaicaAnalysisOutput.IcaFilters; % cell array of [x y nSignals] matrices containing each set of images corresponding to inputSignals objects.
inputSignals = pcaicaAnalysisOutput.IcaTraces; % cell array of [nSignals frames] matrices containing each set of inputImages signals.
iopts.inputMovie = ['pathToImagingSessionFolder' filesep 'MOVIE_FILE_NAME.h5'];
iopts.inputDatasetName = '/1'; % HDF5 dataset name
% MAIN USER parameters: change these as needed
iopts.preComputeImageCutMovies = 0; % Binary: 0 recommended. 1 = pre-compute movies aligned to signal transients, 0 = do not pre-compute.
iopts.readMovieChunks = 1; % Binary: 1 recommended. 1 = read movie from HDD, 0 = load entire movie into RAM.
iopts.showImageCorrWithCharInputMovie = 0; % Binary: 0 recommended. 1 = show the image correlation value when input path to options.inputMovie (e.g. when not loading entire movie into RAM).
iopts.maxSignalsToShow = 9; %Int: max movie cut images to show
iopts.nSignalsLoadAsync = 30; % Int: number of signals ahead of current to asynchronously load imageCutMovies, might make the first couple signal selections slow while loading takes place
iopts.threshold = 0.3; % threshold for thresholding images
iopts.thresholdOutline = 0.3; % threshold for thresholding images
% OPTIONAL
iopts.valid = 'neutralStart'; % all choices start out gray or neutral to not bias user
iopts.cropSizeLength = 20; % region, in px, around a signal source for transient cut movies (subplot 2)
iopts.cropSize = 20; % see above
iopts.medianFilterTrace = 0; % whether to subtract a rolling median from trace
iopts.subtractMean = 0; % whether to subtract the trace mean
iopts.movieMin = -0.01; % helps set contrast for subplot 2, preset movie min here or it is calculated
iopts.movieMax = 0.05; % helps set contrast for subplot 2, preset movie max here or it is calculated
iopts.backgroundGood = [208,229,180]/255;
iopts.backgroundBad = [244,166,166]/255;
iopts.backgroundNeutral = repmat(230,[1 3])/255;
[~, ~, choices] = signalSorter(inputImages, inputSignals, 'options',iopts);
Example good cell extraction output
Example bad cell extraction output
Jump to arbitrary cells
- Click the cell map window or press
V
and a orange cross hair will appear, this will take the user to the clicked upon cell. - Or select the full cellmap, will obtain the same result.
- This cell can be viewed like normal.
- Users can then press
Y
to take them back to the last sorted cell (here #2). This function works even with theG
go to new signal via index number command.
Press "t" to bring up interface to compare neighboring cells
- Users can zoom in on the traces to get a better sense of correlation between activity traces.
Press "r" to bring up different views of trace
- ROI trace included in instances where the entire movie is already loaded into RAM.
Press "c" to bring up the whole movie cut to extraction output activity trace events
- Always sort the cells with the trace, filter, and either images or video cut to transients in the movie.
- This gets around two types of cells: those with irregular firing patterns that might be thrown out (see below) or those whose filter and traces look good, but are either fragments of a high SNR cell (see Common issues) or not actually a cell (e.g. a particulate in the field of view that has transient-like movement).
- Sometimes two or more cell extraction outputs are for the same cell. In these suspected cases, press
t
in thesignalSorter
interface to pull up images and activity traces of nearby cells to see which have a higher SNR or better cell shape and should be kept.
- Sometimes two or more cell extraction outputs are for the same cell. In these suspected cases, press
t
in thesignalSorter
interface to pull up images and activity traces of nearby cells to see which have a higher SNR or better cell shape and should be kept. - See below for an example, in which cell #3 (yellow) is a duplicate of cell #1 (blue).
- Cells with high SNR will sometimes be split into multiple cell extraction outputs. Refer to algorithm specific to notes on how to get around this problem.
- Example of a good cell with GCaMP like rise/decay and for one-photon miniature microscope movies, has nice 2D Gaussian-like shape during transients in the movie.
- Example of good cells on left and bad on right. Subplots: CELLMax output, mean movie frame centered on the cell and aligned to cell transients, and example CELLMax traces.
- Example of not-cells or borderline not-cells.
- Good cells with their matched movies aligned to algorithm (PCA-ICA in this case) detected transients.
- Additional examples of good cells.
- As noted, without the transient aligned movie (see above), cells with unusual traces might be discarded, e.g. all three below are actual cells when the movie is visualized.