scalpel {scalpel} | R Documentation |
Perform entire SCALPEL pipeline.
Description
Segmentation, Clustering, and Lasso Penalties (SCALPEL) is a method for neuronal calcium imaging
data that identifies the locations of neurons, and estimates their calcium concentrations over time.
The pipeline involves several steps, each of which is described briefly in its corresponding
function. See scalpelStep0
, scalpelStep1
, scalpelStep2
,
scalpelStep3
for more details.
Full details for the SCALPEL method are provided in Petersen, A., Simon, N., and Witten, D. (Forthcoming).
SCALPEL: Extracting Neurons from Calcium Imaging Data.
Usage
scalpel(
outputFolder,
rawDataFolder,
videoHeight,
minClusterSize = 1,
lambdaMethod = "trainval",
lambda = NULL,
cutoff = 0.18,
omega = 0.2,
fileType = "R",
processSeparately = TRUE,
minSize = 25,
maxSize = 500,
maxWidth = 30,
maxHeight = 30,
removeBorder = FALSE,
alpha = 0.9,
thresholdVec = NULL,
maxSizeToCluster = 3000
)
Arguments
outputFolder |
Step 0 parameter: The existing directory where the results should be saved. |
rawDataFolder |
Step 0 parameter: The directory where the raw data version of Y is saved. The data should be a
PxT matrix, where P is the total number of pixels per image frame and T
the number of frames of the video, for which the (i,j)th element contains the
fluorescence of the ith pixel in the jth frame. To create Y, you should
vectorize each 2-dimensional image frame by concatenating the columns of the image frame. If the data is
saved in a single file, it should be named "Y_1.mat", "Y_1.rds", "Y_1.txt", or "Y_1.txt.gz" (depending on |
videoHeight |
Step 0 parameter: The height of the video (in pixels). |
minClusterSize |
Step 3 parameter: The minimum number of preliminary dictionary elements that a cluster must contain in order to be included in the sparse group lasso. |
lambdaMethod |
Step 3 parameter: A description of how lambda should be chosen: either |
lambda |
Step 3 parameter: The value of lambda to use when fitting the sparse group lasso. By default, the value is automatically
chosen using the approach specified by |
cutoff |
Step 2 parameter: A value in [0,1] indicating where to cut the dendrogram that results from hierarchical clustering of the preliminary dictionary elements. The default value is 0.18. |
omega |
Step 2 parameter: A value in [0,1] indicating how to weight spatial vs. temporal information in the dissimilarity metric
used for clustering. If |
fileType |
Step 0 parameter: Indicates whether raw data is an .rds (default value; |
processSeparately |
Step 0 parameter: Logical scalar giving whether the multiple raw data files should be
processed individually, versus all at once. Processing the files separately may be preferable for larger videos.
Default value is |
minSize , maxSize |
Step 1 parameter: The minimum and maximum size, respectively, for a preliminary dictionary element with default values of 25 and 500, respectively. |
maxWidth , maxHeight |
Step 1 parameter: The maximum width and height, respectively, for a preliminary dictionary element with default values of 30. |
removeBorder |
Step 3 parameter: A logical scalar indicating whether the dictionary elements containing pixels in the 10-pixel
border of the video should be removed prior to fitting the sparse group lasso. The default value is |
alpha |
Step 3 parameter: The value of alpha to use when fitting the sparse group lasso. The default value is 0.9. |
thresholdVec |
Optional advanced user argument: Step 1 parameter: A vector with the desired thresholds to use for image segmentation. If not specified, the default is to use the negative of the minimum of the processed Y data, the negative of the 0.1% quantile of the processed Y data, and the mean of these. If there were multiple raw data files that were processed separately, these values are calculated on only the first part of data, and then these thresholds are used for the remaining parts. |
maxSizeToCluster |
Optional advanced user argument: Step 2 parameter: The maximum number of preliminary dictionary elements to cluster at once. We attempt to cluster each
overlapping set of preliminary dictionary elements, but if one of these sets is very large (e.g., >10,000), memory issues may
result. Thus we perform a two-stage clustering in which we first cluster together random sets of size
approximately equaling |
Details
Several files containing data from the pipeline, as well as summaries of each step, are saved in various subdirectories of "outputFolder".
Value
An object of class scalpel
, which can be summarized using summary
, used to rerun SCALPEL Steps 1-3 with new parameters using scalpelStep1
, scalpelStep2
, and scalpelStep3
,
or can be used with any of the plotting functions: plotFrame
, plotThresholdedFrame
, plotVideoVariance
, plotCandidateFrame
,
plotCluster
, plotResults
, plotResultsAllLambda
, plotSpatial
,
plotTemporal
, and plotBrightest
.
The individual elements are described in detail in the documentation for the corresponding step: scalpelStep0
, scalpelStep1
, scalpelStep2
, and scalpelStep3
.
See Also
The individual steps in the pipeline can be run using the scalpelStep0
,
scalpelStep1
, scalpelStep2
, and scalpelStep3
functions.
Results can be summarized using summary
, loaded at a later time using getScalpel
, and plotted using plotResults
,
plotSpatial
, plotTemporal
, plotCluster
, plotVideoVariance
,
plotFrame
, plotThresholdedFrame
, plotCandidateFrame
, and plotBrightest
.
Examples
## Not run:
### many of the functions in this package are interconnected so the
### easiest way to learn to use the package is by working through the vignette,
### which is available at ajpete.com/software
#existing folder to save results (update this to an existing folder on your computer)
outputFolder = "scalpelResults"
#location on computer of raw data in R package to use
rawDataFolder = gsub("Y_1.rds", "", system.file("extdata", "Y_1.rds", package = "scalpel"))
#video height of raw data in R package
videoHeight = 30
#run SCALPEL pipeline
scalpelOutput = scalpel(outputFolder = outputFolder, rawDataFolder = rawDataFolder,
videoHeight = videoHeight)
#summarize each step
summary(scalpelOutput, step = 0)
summary(scalpelOutput, step = 1)
summary(scalpelOutput, step = 2)
summary(scalpelOutput, step = 3)
## End(Not run)