Skip to content

A Python package for detecting somas in ExaSPIM image datasets. Includes tools for image preprocessing and deep learning-based classification and training.

License

Notifications You must be signed in to change notification settings

AllenNeuralDynamics/aind-exaspim-soma-detection

Repository files navigation

ExaSPIM Soma Detection

License Code Style semantic-release: angular Interrogate Coverage Python

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.

Overview

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.


pipeline
Figure: Visualization of soma detection pipeline, see Method section for description of each step.

Method

Step 1: Proposal Generation

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.

proposals
Figure: Proposals generated across a large region.

Step 2: Proposal Filtering

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.

proposals
Figure: Proposals generated across a large region.

Step 3: Proposal Classification

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.

detections
Figure: Detected somas across a large region.

Installation

To use the software, in the root directory, run

pip install -e .

Usage

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,
)

Contact Information

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.

License

aind-exaspim-soma-detection is licensed under the MIT License.

About

A Python package for detecting somas in ExaSPIM image datasets. Includes tools for image preprocessing and deep learning-based classification and training.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •