Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2025 Mar;22(3):600-611.
doi: 10.1038/s41592-024-02583-1. Epub 2025 Jan 27.

A deep learning pipeline for three-dimensional brain-wide mapping of local neuronal ensembles in teravoxel light-sheet microscopy

Affiliations

A deep learning pipeline for three-dimensional brain-wide mapping of local neuronal ensembles in teravoxel light-sheet microscopy

Ahmadreza Attarpour et al. Nat Methods. 2025 Mar.

Abstract

Teravoxel-scale, cellular-resolution images of cleared rodent brains acquired with light-sheet fluorescence microscopy have transformed the way we study the brain. Realizing the potential of this technology requires computational pipelines that generalize across experimental protocols and map neuronal activity at the laminar and subpopulation-specific levels, beyond atlas-defined regions. Here, we present artficial intelligence-based cartography of ensembles (ACE), an end-to-end pipeline that employs three-dimensional deep learning segmentation models and advanced cluster-wise statistical algorithms, to enable unbiased mapping of local neuronal activity and connectivity. Validation against state-of-the-art segmentation and detection methods on unseen datasets demonstrated ACE's high generalizability and performance. Applying ACE in two distinct neurobiological contexts, we discovered subregional effects missed by existing atlas-based analyses and showcase ACE's ability to reveal localized or laminar neuronal activity brain-wide. Our open-source pipeline enables whole-brain mapping of neuronal ensembles at a high level of precision across a wide range of neuroscientific applications.

PubMed Disclaimer

Conflict of interest statement

Competing interests: The authors declare no competing interests.

Figures

Fig. 1
Fig. 1. Methodological workflow of ACE.
ac, Intact whole brains immunolabeled, cleared and imaged with LSFM were used as input to the ACE pipeline. a, Whole-brain LSFM data are passed to ACE’s segmentation module, consisting of ViT- and CNN-based DL models, to generate binary segmentation maps in addition to a voxel-wise uncertainty map for estimation of model confidence. b, The autofluorescence channel of data is passed to the registration module, consisting of MIRACL registration algorithms, to register to a template brain such as the Allen Mouse Brain Reference Atlas (ARA). High-resolution segmentation maps are then voxelized using a convolution filter and warped to the ARA (10 µm) using deformations obtained from registration. c, Voxelized and warped segmentation maps are passed to ACE’s statistics module. Group-wise heatmaps of neuronal density are obtained by subtracting the average of warped and voxelized segmentation maps in each group to identify neural activity hotspots. To identify significant localized group-wise differences in neuronal activity in an atlas-agnostic manner, a cluster-wise, threshold-free cluster enhancement permutation analysis (using group-wise ANOVA) is conducted. The resulting P value map represents clusters showing significant differences between groups. Correspondingly, ACE outputs a table summarizing these clusters, including their volumes and the portion of each brain region included in each cluster. Significant clusters are then passed to the ACE native space cluster validation module, where clusters are warped to the native space of each subject. Utilizing warped clusters and ACE segmentation maps, the number of neurons within each cluster is calculated and a post hoc nonparametric test is applied between counts within each cluster across two groups. The top left panel of the figure was created using BioRender.com.
Fig. 2
Fig. 2. Performance of ACE in brain-wide segmentation of neuronal cell bodies.
a, Maximum-intensity projection rendering of whole-brain c-Fos expression, with an enlarged view of a cortical patch. Segmentation maps (blue) predicted by the ViT ensemble for the enlarged subregion are shown and compared with GT (red). b, Raw image, GT and segmentation maps for two example image patches, along with voxel-wise uncertainty maps. Regions of high uncertainty are localized around the boundary of sparsely mislabeled processes such as axons (left-hand column) and neuronal somas (right-hand column). Arrows indicate mis-segmented regions from a. c, Qualitative evaluation of segmentation accuracy of ACE versus Ilastik in terms of detection of neurons with low signal intensity or slight blurriness (top), and their shape (bottom). Arrows indicate the boundary of two neurons close to each other. d,e, Quantitative evaluation of the segmentation accuracy of ACE versus Ilastik (d), and detection accuracy of ACE versus Cellfinder (e), in terms of average DSC, precision, recall, HD95 and F1 score on test datasets (n = 12,160 unique patches with 963 ≃ 0.35 mm3) and unseen datasets (n = 1,824 unique patches of 963 ≃ 0.27 × 0.27 × 0.48 mm3). In box plots: box limits, upper and lower quartiles; center line, median; whiskers, 1.5× interquartile range; points, outliers. Mann–Whitney U-test (two-sided), ***P < 0.0001.
Fig. 3
Fig. 3. ROI-wise evaluation of ACE segmentation module in segmentation of neuronal cell bodies across the whole brain.
a, Qualitative evaluation of ACE’s segmentation module in different cortical regions in an example subject from the test dataset. Each panel from left to right demonstrates a 3D maximum-intensity projection of a raw (input) image patch, GT (red), model output (blue) and an overlaid version of all three. bd, On the test set (in total, n = 1,600 unique patches 963 ≃ 0.35 mm3; minimum n = 10 and maximum n = 155 unique patches per region), we registered each LSFM dataset to the ARA using our MIRACL platform’s registration algorithms. ARA labels were then warped to each subject’s native space, with these warped labels then used to determine the location of each image patch in the brain. Average DSC (b) and HD95 (c) were obtained between ACE outputs and GT per ARA label (d) and compared against Ilastik. Box plots: box limits, upper and lower quartiles; center line, median; whiskers, 1.5× interquartile range; points, outliers. Mann–Whitney U-test (two-sided), ***P < 0.001, **P < 0.01, *P < 0.05. CB, cerebellum; CNU, cerebral nuclei; CTX, cerebral cortex; IB, interbrain; MB, midbrain.
Fig. 4
Fig. 4. Mapping neuronal activity underlying food seeking following cold stress.
a, Experimental design (n = 4 per group). b, LSFM data were registered to the ARA using MIRACL. Left and right panels show autofluorescence data overlaid on labels for two subjects in each group. c, Segmentation maps from ACE were voxelized to ARA 10-µm resolution; voxelized maps were then warped to ARA. Top, one subject per group overlaid on labels; bottom, 3D rendering of segmentation maps color coded based on six regions: cerebral cortex (CTX), cerebral nuclei (CNU), midbrain (MB), hindbrain (HB), interbrain (IB) and cerebellum (CB). d, Segmentation maps were averaged and then subtracted to obtain group-wise heatmaps. e, An independent t-test (two-sided) was applied between c-Fos+ density per label for ROI-wise analysis (n = 4 per group). Top left, trending ROIs (P < 0.1); top right, significant regions (***P > 0.001, **P < 0.01, *P < 0.05); bottom, corresponding P values per label. Box plots: box limits, upper and lower quartiles; center line, median; whiskers, 1.5× interquartile range. Data are presented as mean ± s.d. f, ACE cluster-wise analysis (two-way ANOVA). Top, significant clusters within the midline group of the dorsal thalamus (MTN), including one cluster close to the Xi region between the paraventricular nucleus of the hypothalamus (PVH) and above the third ventricle (left); and multiple clusters in the dorsal subregion of the paraventricular nucleus of the thalamus (PVT, right). Middle, Pearson correlation (significant correlations only, P < 0.01, bottom left triangle) and Euclidean distance (top right triangle) between the 22 significant clusters, ranked according to activation strength. Arrow indicates correlation between one cluster located in the nucleus of reuniens (RE) and another in the nucleus accumbens (ACB). Bottom, 3D connectivity maps derived from anterograde viral vector (AAV) tracing from an experiment (ID 184158290) in the ARA, demonstrating structural connectivity between the RE in MTN and ACB. Panels, from left to right, show (1) MTN and ACB, (2) fibers originating from RE and projecting into ACB, (3) maximum-intensity projection and (4) a sagittal view of the atlas. a was created using BioRender.com.
Fig. 5
Fig. 5. ACE native space cluster validation algorithm.
a, Overview of the validation algorithm. Significant clusters identified through ACE’s cluster-wise TFCE permutation-based statistical algorithm were binarized and underwent a connected component analysis to differentiate each cluster. The processed significant clusters were then warped to the native space of each subject using registration deformation fields. Using ACE segmentation maps, the number of neurons within each cluster was computed. A Mann–Whitney U-test (two-sided) was used to compare the number of neurons within each cluster between the two groups. The number of neurons per subject for each cluster—in addition to their volume, effect size, atlas space P value (obtained via ACE cluster-wise TFCE permutation), brain regions they spanned and native space P value (obtained via post hoc Mann–Whitney U-test)—are summarized. b, Validation of neuronal ensembles detected by ACE cluster-wise analysis in the food-seeking behavior experiment. From left to right, axial view of the cluster-wise P value map, overlaid on ARA label boundaries at a resolution of 10 µm; zoomed view of significant clusters in PVT. The P value map was warped back into the native space of randomly selected subjects of the 4 and 30 ° groups using the deformation matrices obtained by registration; corresponding axial views from subjects in the 4 and 30 °C groups, respectively, and zoomed versions of cluster boundaries in PVT, showing higher c-Fos+ activity in the 4 versus 30 °C condition in the clusters detected in atlas space. Cluster colors in native space (columns 2 and 3) correspond to the manually drawn boundary in atlas space (column 1), for visual comparison. NS, not significant.
Extended Data Fig. 1
Extended Data Fig. 1. ACE’s segmentation module.
A 3D vision transformer (UNETR) with multi-head attention was used as our backbone architecture. Our optimized UNETR model receives an 963 image patch and generates a probability map of the same size. ACE also consists of a convolutional neural network-based 3D U-Net architecture, operating on 1283 image patches. The probability map of each model is passed to a Monte-Carlo dropout block to estimate model confidence and generate an ensemble of 50 models, improving the accuracy of the overall prediction. To increase the generalizability of the ACE segmentation module, the user can deploy another layer of ensembling by combining both UNETR and U-Net outputs. Created in BioRender.com.
Extended Data Fig. 2
Extended Data Fig. 2. Light-sheet fluorescence microscopy (LSFM) datasets used to develop and evaluate ACE’s deep learning models.
Our training data consists of 18 animals with 10 acquired from the whole brain and eight animals with data acquired from the left hemisphere. We used whole-brain LSFM datasets (see Methods-Datasets and Experiments) from different studies to evaluate ACE deep learning models. Panel a shows axial views of an example subject from each group. Panel b shows the intensity histogram of a randomly selected image patch for each subject shown in panel a. c. Image characteristics of each dataset. Our unseen datasets were obtained using a different experimental setup including a different microscope, rodent model, fluorescence proteins, and tissue-clearing technique. See Method–Datasets and Experiments for more details.
Extended Data Fig. 3
Extended Data Fig. 3. ROI-wise evaluation of ACE segmentation module in segmenting neuronal cell bodies across the whole brain.
Average precision (a) and recall (b) obtained between ACE outputs and ground truth per ARA label (c) and compared against Ilastik. In total N: 1600 unique patches with 963≃0.35 mm3; minimum 10 and maximum 155 unique patches/region. Box plots: box limits, upper and lower quartiles; center line, median; whiskers, 1.5× interquartile range; points, outliers. Mann-Whitney U test (two-sided), ***P < 0.001, **P < 0.01, and ***P < 0.05.
Extended Data Fig. 4
Extended Data Fig. 4. Evaluation of ACE segmentation models’ robustness to simulating distribution shifts.
The x-axis of the first row in panels a-c shows the severity of each transform. The second row in each panel demonstrates the effect of each transform on the input image. a. Adding Gaussian noise to the image with zero mean and 0 < σ<1. b. Sharpening the image using the Gaussian Blur filter with zero mean and 0.05 <σ < 2. c. Apply Gaussian smooth to the input data based on the specified parameter (0.05 <σ < 2).
Extended Data Fig. 5
Extended Data Fig. 5. Performance of ACE in brain-wide segmentation of neuronal cell bodies in unseen dataset 2.
a. An axial view from a random depth of whole-brain c-Fos expression with an enlarged view of a cortical patch plus its associated ground truth data in red (b). c. The segmentation maps (blue) predicted by the ACE UNETR ensemble for the enlarged subregion are shown and compared with the Ilastik output for the same patch (blue). d and e. Quantitative evaluation of the segmentation accuracy of ACE vs. Ilastik (d) and detection accuracy of ACE vs. Cellfinder (e) in terms of average Dice coefficient, precision, recall, 95% Hausdorff distance, and F1 score on (N: 152 unique patches of 963≃0.17×0.17×0.38 mm3). Box plots: box limits, upper and lower quartiles; center line, median; whiskers, 1.5× interquartile range; points, outliers. Mann-Whitney U test (two-sided), ***p < 0.0001.
Extended Data Fig. 6
Extended Data Fig. 6. Fine-tuning ACE segmentation models to segment other cellular markers with different morphological features compared to c-Fos.
Panel a shows a randomly selected image patch from training data vs. a new unseen dataset with an enlarged view of several cells to highlight the different morphological appearance. b. An axial view from a random depth of the whole brain of the new dataset. c. two randomly selected image patches (with the size of 512x512x512 voxels); patch number 1 was used to fine-tune the ACE UNETR model while patch number 2 was used to evaluate the model performance. d. Qualitative ACE performance before and after fine-tuning. e. Quantitative performance of ACE deep learning models on N: 152 unique patches of 963≃0.17×0.17×0.19 mm3. Box plots: box limits, upper and lower quartiles; center line, median; whiskers, 1.5× interquartile range; points, outliers. Mann-Whitney U test (two-sided), ***p < 0.0001.
Extended Data Fig. 7
Extended Data Fig. 7. Brain-wide identification of local neuronal activity changes underlying walking.
a. The overview of experimental design to analyze c-Fos+ cell distribution in whole-brain LSFM data during walking (n = 3/group). b. Automated segmentation of c-Fos+ cell distribution using ACE’s segmentation module. Panels show a 3D rendering of a maximum intensity projection of raw data from the walking group, ACE output (blue), and raw data overlaid on ACE’s output. c. Segmentation maps were voxelized to the ARA 10um resolution. Subsequently, the voxelized segmentation maps were warped to ARA space. Left panels show an example of a downsampled subject overlaid on ARA labels after registration from each group. Right panels show a 3D rendering of voxelized and warped segmentation maps color-coded based on 6 ARA regions: CTX, Cerebral Cortex; CNU, Cerebral Nuclei; MB, Midbrain; HB, Hindbrain; IB, Interbrain; and CB, Cerebellum. d. To identify neural activity hotspots, group-wise heatmaps of neuronal density were obtained by subtracting the average of the voxelized and warped segmentation maps in each group. Panels show two different coronal views as an example. e. Result of ACE cluster-wise threshold-free cluster enhancement permutation analysis, using a group-wise two-way ANOVA. The panels demonstrate the resulting p-value map representing the clusters showing significant differences between groups and corresponding to the coronal sections in d. Zoomed views show two significant clusters in MOp (left panel) and Retrosplenial area (right panel). See Supplementary Table 3 for strength (effect size), volume, and brain regions each cluster spanned. f. Lateral Hypothalamic Area (LHA) label was warped back into native space using the deformation matrix obtained by registration. Left and right panels show two example subjects from the walking and homecage groups respectively with a zoomed version of LHA, showcasing higher c-Fos+ activity in the walking vs. homecage condition. Section a is created in BioRender.com.
Extended Data Fig. 8
Extended Data Fig. 8. ACE statistical analysis for unraveling neuronal ensembles controlling walking.
a. ARA labels at the level of whole brain vs. depth 6 based on the ARA ontology (hierarchy). b. Group-wise heatmaps of neuronal density were obtained by subtracting the average of the voxelized and warped segmentation maps in each group. Panels show different coronal, sagittal, and axial views as an example. c. Using voxelized and warped segmentation maps and ARA labels at 10 µm, we obtained neuronal density per brain region at both whole-brain and depth 6 levels. An independent student t-test (two-sided) was then applied between c-Fos+ cell density per ARA label to perform a whole-brain and depth 6 level ROI-wise statistical test (N: 3/group) Data are presented as mean values ± standard deviation. The upper panel shows the results of the whole-brain analysis with a zoomed version on the right, demonstrating the most significant ROIs. The lower panel shows the results of the depth 6 analysis. The ARA labels are sorted based on p value (***p < 0.001, **p < 0.01, and *p < 0.05). d. ACE cluster-wise analysis with group-wise two-way ANOVA documented several sub-regional and laminar neuronal clusters differentially activated during walking. Left panel shows a coronal view of a cluster-wise p-value map with two zoomed views of significant clusters spanning in the primary and secondary motor area layers 6, 6a and 6b and the primary somatosensory area layers 2/3 and 4. The table summarizes the information of each cluster. Using ACE cluster-wise analysis, the volume (µm3 x1,0002), maximum strength (Cluster-wise TFCE F-statistic x1,000), brain regions each cluster spanned out on, and centroid of each significant cluster on Allen 10 µm atlas was computed.
Extended Data Fig. 9
Extended Data Fig. 9. ACE cluster-wise statistical analysis for unraveling neuronal ensembles controlling walking.
a. Voxelized and warped segmentation maps, obtained by integrating ACE’s segmentation module and MIRACL registration algorithms, were averaged per group. The average of the homecage (non-walking) group was subtracted from the walking group to obtain a density heatmap, demonstrating neuronal hotspots differentially activated in the walking group. b. Statistical whole-brain p-value map obtained by ACE cluster-wise analysis with a group-wise two-way ANOVA, demonstrating several sub-regional and laminar neuronal clusters differentially activated during walking.
Extended Data Fig. 10
Extended Data Fig. 10. The effects of different user-fed parameters to control the rigor of ACE cluster-wise statistics.
a. An axial view of the group density heatmap next to its corresponding ACE cluster-wise p-value map for the cold-induced experiment. b-d. The effects of the threshold used to define the adjacency matrix (b), Step-down p-value (c), TFCE step size, and TFCE E (d) on the results of ACE cluster-wise TFCE permutation algorithm. See Methods - Cluster-wise permutation-based statistical algorithm and analysis for more details.

Similar articles

References

    1. Renier, N. et al. Mapping of brain activity by automated volume analysis of immediate early genes. Cell165, 1789–1802 (2016). - PMC - PubMed
    1. Kim, Y. et al. Mapping social behavior-induced brain activation at cellular resolution in the mouse. Cell Rep.10, 292–305 (2015). - PMC - PubMed
    1. Dyer, L., Parker, A., Paphiti, K. & Sanderson, J. Lightsheet microscopy. Curr. Protoc.2, e448 (2022). - PubMed
    1. Stelzer, E. H. K. Light-sheet fluorescence microscopy for quantitative biology. Nat. Methods12, 23–26 (2015). - PubMed
    1. Chung, K. et al. Structural and molecular interrogation of intact biological systems. Nature497, 332–337 (2013). - PMC - PubMed

LinkOut - more resources