All projects
Case study · 04

Research · AI · Biomedical

Université de Florence

A twelve-week research internship at the University of Florence’s AI laboratory, focused on automatic cell detection in 3D human and murine brain volumes acquired by microscopy.

Status
International research internship — 2025
My role
Development of the detection pipeline, synthetic data generation, evaluation metrics, Napari interface, and automated parameter selection.
Stack
Python · NumPy · scikit-learn · Napari · Weighted Mean Shift · PCA · Random Forest · Grid Search
04

Detecting cells in 3D brain images

01

Context

The data consists of 3D volumes of human and murine brains acquired by microscopy and stored in TIFF format. These volumes combine noise, intensity variations, and large size — a demanding setting for reliable detection of cell centers. The goal was to improve this detection and build a reproducible experimentation pipeline to compare results.

02

Detection pipeline

The final pipeline chains several complementary steps, from the raw volume to the detected cell centers.

PythonNumPy
  • Volume preprocessing
  • Splitting into overlapping sub-volumes
  • Adaptive thresholding and candidate seed generation
  • Weighted Mean Shift clustering
  • Merging detected centers across the full volume
  • Optional morphological post-processing

03

Preprocessing and scaling

An initial direct implementation gave correct results on simple synthetic volumes but became too costly on real biological volumes. Preprocessing combines filtering and noise reduction; the volume is then split into overlapping sub-volumes, which reduces memory usage, allows blocks to be processed independently, and avoids losing cells sitting at the boundary between two sub-volumes. Some costly steps were parallelized to speed up experimentation.

Before/after comparison of preprocessing on a sub-volume: noise reduction and improved contrast.
Sub-volume before (left) and after (right) preprocessing.
Full volume with a sub-volume highlighted by a frame, illustrating the overlapping split.
Splitting into overlapping sub-volumes, to avoid cutting cells at the boundaries.

04

Weighted Mean Shift

Starting from the candidate points, each point is iteratively shifted toward the center of mass of its local neighborhood, weighted by the intensity of surrounding voxels, until it converges on a high-density region. Centers close enough to each other are then merged into a single cell center.

Weighted Mean Shift
3D volume with cell centers detected, in green, by the weighted Mean Shift.
Centers detected by the weighted Mean Shift, overlaid on the 3D volume.

05

Napari interface

An interactive interface built with Napari brings the pipeline together into a visually operable tool, serving at once as a visualization, analysis, and experimental validation tool.

Napari
  • Loading a 3D volume and its reference annotations
  • Adjusting detection parameters
  • Running the full pipeline, with optional post-processing
  • Visualizing detected centers within the volume, distinguishing true positives, false positives, and false negatives
  • Displaying evaluation metrics and saving detected centers
Napari interface: loading the volume and annotations, tuning the weighted Mean Shift parameters, and 3D visualization.
Napari interface bringing together loading, parameters, pipeline, and evaluation.

06

Grid search and evaluation

A grid search explores the influence of the main weighted Mean Shift parameters. Each configuration is evaluated by precision, recall, and F1, with heatmaps generated to compare results on a single volume or across a full set of volumes.

Grid Search
  • F1 Macro — average of per-volume F1 scores
  • F1 Micro — global computation from cumulative true positives, false positives, and false negatives
Grid search heatmaps: F1 Macro and F1 Micro scores as a function of the weighted Mean Shift’s r and R parameters.
F1 Macro (top) and F1 Micro (bottom) across the r and R parameters.

07

Automation

A complementary approach uses a multi-output Random Forest regression model to automatically predict the pipeline’s parameters from features extracted from the volumes, reducing manual tuning and improving detection reproducibility.

Random Forest
  • Grid search to produce reference configurations
  • Automatic feature extraction from the volumes
  • Training a multi-output Random Forest model
  • Predicting parameters and running the full pipeline
  • Automatic evaluation of results

08

Experimental limits

Metrics should not be interpreted independently of ground-truth quality. Some reference annotations are not perfectly aligned with the processed volumes, which can artificially penalize precision, recall, and F1 even when detections remain visually consistent with the observed structures. This limitation led to keeping both a quantitative and a visual analysis of the results.

Comparison between ground-truth annotations and the 3D volume: visible structures don’t always match the reference points.
Ground truth and 3D volume: a misalignment that limits direct interpretation of the metrics.

09

End-to-end chain

The pipeline links 3D image processing, clustering, parameter optimization, machine learning, interactive visualization, and evaluation into a single experimental chain. It allows different cell-center detection strategies on 3D biomedical volumes to be explored, compared, and automated.

Next project

QR Menu SaaS