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 for classification.
The soma detection pipeline consists of three main steps:
1. Proposal Generation: Detects blob-like structures to generate initial soma proposals and filter trivial false positives.
2. Proposal Filtering: Remove trivial false positives using heuristics and prior knowledge of soma characteristics. .
3. Proposal Classification: Classify proposals with a convolutional neural network.
Figure: Visualization of soma detection pipeline, see Method section for description of each step.
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.
Proposals are filtered by leveraging prior knowledge, such as the Gaussian-like appearance and expected size of somas, to remove trivial false positives.
a. Merges proposals within a given distance threshold.
b. 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: Proposals generated across a large region.
The 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 .
Here is an example of running the full soma detection pipeline.
from aind_exaspim_soma_detection.pipeline import run_pipeline
# Initializations
brain_id = "unique-identifier-of-dataset"
img_path = "path-to-image"
output_dir = "directory-to-write-results"
# Parameters
proposal_params = {
"multiscale": 4,
"patch_shape": (64, 64, 64),
"bright_threshold": 150,
"patch_overlap":(28, 28, 28),
}
classify_params = {
"multiscale": 1,
"patch_shape": (102, 102, 102),
"accept_threshold": 0.4,
"model_path": "path-to-model",
}
# Main
run_pipeline(
brain_id,
img_path,
output_dir,
proposal_params,
classify_params,
)
For any inquiries, feedback, or contributions, please do not hesitate to contact us. You can reach us via email at [email protected] or connect on LinkedIn.
aind-exaspim-soma-detection is licensed under the MIT License.