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

aind-exaspim-soma-detection

License Code Style semantic-release: angular Interrogate Coverage Python

Overview

To do...

pipeline
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 inference pipeline.

if __name__ == "__main__":
    # Initializations
    brain_id = "unique-identifier-of-dataset"
    img_prefix = "path-to-image"
    save_proposals_bool = True
    save_somas_bool = True

    # Parameters ~ Proposal Generation
    multiscale_1 = 4
    patch_shape_1 = (64, 64, 64)
    bright_threshold = 100
    overlap = (28, 28, 28)

    # Parameters ~ Proposal Classification
    multiscale_2 = 1
    patch_shape_2 = (102, 102, 102)
    accept_threshold = 0.4
    model_path = "path-to-model"

    # Main
    main()

Inference

Step 1: Proposal Generation

The objective of this step is to generate initial proposals for potential soma locations by detecting blob-like structures in the image. Our proposal generation algorithm consists 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 non-linear maximum filter.

c. Generate initial set of proposals by detecting local maximas.

d. Shift each proposal to the brightest voxel in its neighborhood. If the brightness is below a threshold, reject the proposal.

proposals
Figure: Example of proposals generated across a large region.

Step 2: Filter Proposals with Heuristics

The initial proposal generation step is tuned to prioritize high recall which often results in a large number of false positives. The purpose of this step is to use prior knowledge, such as somas having a Gaussian-like appearance and an expected size range, to filter out trivial false positives.

a. Compute distances between proposals and 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.

proposals
Figure: Examples of filtered proposals.

Step 3: Classify Proposals with Convolutional Neural Network (CNN)

To do...

detections
Figure: Example of detected somas across a large region.

Train Classification Model

To do...

Installation

To use the software, in the root directory, run

pip install -e .

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published