SynapFlow: A Modular Framework Towards Large-Scale Analysis of Dendritic Spines

Pamela Osuna-Vargas, Altug Kamacioglu, Dominik F. Aschauer, Petros E. Vlachos, Sercan Alipek, Jochen Triesch, Simon Rumpel, Matthias Kaschube · DOI

Abstract

SynapFlow is a modular machine learning pipeline designed to automate the detection and tracking of dendritic spines in 4D (3D + time) microscopy data. By combining transformer-based detection with specialized tracking modules, it provides a scalable way for neuroscientists to analyze synaptic plasticity and structural brain changes over long periods. The framework addresses significant bottlenecks in longitudinal studies, specifically handling non-rigid tissue deformations and the labor-intensive nature of manual annotation.

Introduction

Dendritic spines are tiny protrusions on neurons that serve as the primary sites for excitatory synapses. Because their size and presence correlate with synaptic strength, tracking them is essential for studying the neural basis of learning and memory. However, analyzing this data is a monumental task. Researchers use two-photon microscopy to capture 3D volumes of brain tissue over several days. Manually identifying thousands of spines, linking 2D slices into 3D objects, and then finding those same spines across different imaging sessions is slow, prone to error, and labor-intensive. While automated tools exist, they often struggle with the "tracking" aspect—specifically handling the non-rigid deformations (shifts and stretches) that occur in living brain tissue between imaging sessions.

The SynapFlow Framework

The SynapFlow modular pipeline: (1) 2D spine detection, (2) tracking across depth, (3) tracking across time, and (4) feature extraction.

The authors propose SynapFlow, a modular framework consisting of four main stages:

  1. 2D Detection: Instead of traditional CNNs, SynapFlow utilizes Deformable DETR (Detection Transformer). This model is specifically optimized for small objects and converges faster than the original DETR by focusing on a sparse set of relevant image features.
  2. Depth Tracking: To reconstruct 3D spines from 2D slices, the system employs a Siamese neural network trained with a contrastive loss. This network learns to create "embeddings" (mathematical signatures) of spines. Spines are linked across depth layers using a combination of these visual embeddings and spatial consistency (generalized Intersection over Union, or gIoU).
  3. Time Tracking: To link 3D spines across different days, the framework uses Pump, an algorithm that estimates a deformation field to account for tissue movement. It then matches spines based on three factors: spatial location, appearance similarity, and depth consistency.
  4. Feature Extraction: The final module quantifies biologically relevant metrics, such as spine volume (estimated via integrated fluorescence intensity) and the distance from the spine head to the dendrite.

Experimental Evaluation

Datasets

The study utilizes four datasets, including two significant new contributions: S3D, for training and validating 2D detection and depth-tracking, and S2D+T, the first publicly available dataset featuring spines manually tracked across four timepoints (up to three days apart). Existing open-source datasets (DeepD3 & Smirnov-Garrett) were used to benchmark generalizability.

Key Results

SynapFlow demonstrates state-of-the-art performance across all metrics:

  • Detection Accuracy: SynapFlow achieved an F1-score of 0.77 on the S3D dataset, significantly outperforming existing tools like SpineS (0.34) and DeepD3 (0.39).
  • Depth Tracking: The system achieved a Multiple Object Tracking Accuracy (MOTA) of 98.38%, indicating near-perfect reconstruction of 3D objects from 2D slices.
  • Time Tracking: On the challenging longitudinal dataset, SynapFlow reached a HOTA (Higher Order Tracking Accuracy) of 90.23%, far surpassing general-purpose trackers like Trackformer (69.58%).
Comparison of predicted spine IDs vs. ground truth across Z-slices (A) and visualization of tracking across depth (B).

Discussion and Insights

The Deformable DETR architecture proved more robust than standard CNN-based detectors when applied to different datasets, maintaining a superior balance between precision and recall. Interestingly, for depth-tracking, spatial consistency was often more reliable than visual appearance; because many spines look similar, their relative position in the 3D volume serves as a stronger "fingerprint" than their shape.

Despite its success, the framework has limitations. The detection model struggles with spines oriented orthogonally to the imaging axis, which can lead to false turnover events. Additionally, while the tool measures volume, it does not yet extract granular features like neck length or head roundness. Future work will focus on refining algorithms for complex tissue deformations and expanding morphological analysis.

By separating detection from tracking, SynapFlow's modular flexibility allows researchers to update individual components without rebuilding the entire pipeline, paving the way for large-scale automated neuroscience research.

Summary updated

BibTeX
@misc{osunavargas2025synapflow,
  author = {Pamela Osuna-Vargas and Altug Kamacioglu and Dominik F. Aschauer and Petros E. Vlachos and Sercan Alipek and Jochen Triesch and Simon Rumpel and Matthias Kaschube},
  title = {{SynapFlow: A Modular Framework Towards Large-Scale Analysis of Dendritic Spines}},
  year = {2025},
  eprint = {2509.18926},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.18926},
}
Figure