This repository implements a pipeline for detecting somas in whole-brain images. It utilizes a multi-step approach to propose, filter, and classify potential soma locations. This method prioritizes high recall in the initial proposal generation, followed by filtering based on prior knowledge of soma characteristics, and finally refines the proposals using a convolutional neural network (CNN) for classification.
The soma detection pipeline consists of three main steps:
a. Proposal Generation: Detects blob-like structures to generate initial soma proposals.
b. Proposal Filtering: Filters out trivial false positives using heuristics and prior knowledge of soma characteristics.
c. Proposal Classification: Classify proposals with a convolutional neural network (CNN).
Figure: Visualization of soma detection pipeline, see Inference section for description of each step.
Here is an example of calling the main routine to run the full pipeline.
if __name__ == "__main__":
# Initializations
brain_id = "unique-identifier-of-dataset"
img_prefix = "path-to-image"
# Parameters - Proposal Generation
multiscale_1 = 4
patch_shape_1 = (64, 64, 64)
bright_threshold = 100
overlap = (28, 28, 28)
save_proposals_bool = True
# Parameters - Proposal Classification
multiscale_2 = 1
patch_shape_2 = (102, 102, 102)
accept_threshold = 0.4
model_path = "path-to-model"
save_somas_bool = True
# Main
main()
The goal of this step is to generate initial proposals for soma locations by detecting blob-like structures in the image. The proposal generation algorithm consists of the following steps
a. Smooth image with Gaussian filter to reduce false positives.
b. Laplacian of Gaussian (LoG) with multiple sigmas to enhance regions where the gradient changes rapidly, then apply a max filter.
c. Generate initial set of proposals by detecting local maximas.
d. Shift each proposal to the brightest voxel in its neighborhood and reject it if the brightness is below a threshold.
Figure: Proposals generated across a large region.
The initial proposal generation step prioritizes high recall, which results in many false positives. This step leverages prior knowledge, such as the Gaussian-like appearance and expected size of somas, to filter out trivial false positives.
a. Merges proposals within a given distance threshold.
b. If the number of proposals exceeds a certain threshold, the top k brightest proposals are kept.
c. Fit Gaussian to neighborhood centered at proposal and compute fitness score by comparing fitted Gaussian to image values. Proposals are discarded if (1) fitness score is below threshold or (2) estimated standard deviation is out of range.
Figure: Examples of filtered proposals.
Finally, the remaining proposals are classified by a neural network that generates soma likelihoods. Proposals with a likelihood above a given threshold are accepted as soma locations.
Figure: Detected somas across a large region.
To use the software, in the root directory, run
pip install -e .
aind-exaspim-soma-detection is licensed under the MIT License.