SAM2Flow: Interactive Optical Flow Estimation with Dual Memory for in vivo Microcirculation Analysis

Luojie Huang, Ryan Zhang, Marisa M Morakis, Michaela Taylor-Williams, Gregory N. McKay, Nicholas J. DurrNeurIPS 2025

Introduction

Monitoring blood flow at the capillary level—known as microcirculation—provides a vital window into a patient’s health, offering critical insights for diagnosing conditions like sickle cell disease and cardiovascular dysfunction. While techniques like Oblique Back-illumination Microscopy (OBM) can capture high-resolution videos of individual blood cells in vivo, analyzing these videos remains a significant challenge. Current methods are often semi-quantitative, labor-intensive, or computationally expensive.

Standard optical flow algorithms, which calculate how pixels move between frames, struggle with these microscopic videos for several reasons. First, they are typically designed for short clips rather than the minute-long sequences needed for clinical analysis. Second, they attempt to calculate movement for every pixel, including the static background, which introduces noise and errors. Finally, in dense vascular networks, vessels often overlap or twist, confusing automated trackers.

To address these challenges, researchers have introduced SAM2Flow, a new interactive tool designed to track blood flow in microscopic vessels with unprecedented accuracy and speed. By combining user-guided prompts with a "dual memory" system, SAM2Flow enables stable, long-term analysis of microcirculation.

Methodology: The SAM2Flow Architecture

SAM2Flow borrows the interactive philosophy of the Segment Anything Model 2 (SAM2), allowing users to guide the model's focus.

SAM2Flow Architecture

Key innovations of the SAM2Flow framework include:

  • Interactive ROI Selection: Instead of relying on the model to guess what to track, a user provides simple point prompts to select specific vessels or branches of interest.
  • Dual Memory Mechanism: The model maintains two distinct memory banks to ensure stability over long videos. Motion Memory tracks how blood typically flows in a specific region to ensure temporal smoothness. Meanwhile, Context Memory remembers the specific shape and identity of the vessel, preventing the tracker from drifting onto neighboring vessels.
  • ROI-Guided Correlation Lookup: Traditional models waste computational power searching the entire image to find where a pixel moved. SAM2Flow uses its internal segmentation to focus its search strictly on the prompted region, making it faster and highly resistant to background noise.

Datasets and Key Insights

To validate SAM2Flow, the authors established a massive new benchmark for the field: an In Vivo Microvascular Dataset comprising 75 videos (over 306,000 frames) captured from the oral cavities of 15 healthy volunteers using OBM. To demonstrate the model's generalizability, they also tested it on the Sintel and Spring datasets, which are standard benchmarks for general-purpose computer vision.

The development of SAM2Flow yielded several key insights:

  • Targeted Focus Improves Efficiency: By ignoring the background and focusing only on user-selected regions of interest (ROIs), the model achieves a win-win scenario: it is more accurate because it ignores background noise, and it is faster because it performs fewer calculations.
  • Memory Prevents "Merging": A common failure in optical flow occurs when two flows cross, causing models to mistakenly merge them. SAM2Flow’s dual memory allows it to maintain the distinct identity of a vessel even in complex, tangled vascular structures.
  • Clinical Waveforms Matter: The model goes beyond producing raw numbers; it generates high-fidelity velocity waveforms. These waveforms allow clinicians to visualize the "pulse" of the microcirculation, which is essential for calculating downstream biomarkers like heart rate and vascular elasticity.

Key Results

SAM2Flow demonstrates significant improvements over existing optical flow models, achieving state-of-the-art performance in both accuracy and speed.

Performance Comparison Table
  • State-of-the-Art Accuracy: SAM2Flow achieved the lowest Foreground End-Point Error (FEPE) on both the microvascular dataset and public benchmarks like Spring, outperforming established models such as RAFT, SEA-RAFT, and StreamFlow.
  • Real-Time Performance: The model runs at over 20 frames per second (fps) on standard 512x512 video inputs, making it fast enough for practical, real-time clinical use.
  • Robustness: In head-to-head qualitative tests, SAM2Flow successfully tracked crossing blood flows that caused all other baseline models to fail or "leak" motion into the background.

Limitations and Future Work

While highly powerful, SAM2Flow's current performance is dependent on the quality of the initial ROI detection. If the model fails to segment the vessel correctly in the first few frames based on the user prompts, the subsequent flow estimation will suffer.

Looking ahead, the authors suggest that future versions could utilize even more compact backbone architectures (such as SAM2-Tiny) to push inference speeds even higher. Furthermore, they plan to move beyond healthy volunteers to test the system on patients with conditions like sickle cell disease and sepsis, where microvascular flow patterns are significantly more erratic and difficult to track.

Summary updated

BibTeX
@inproceedings{huang2025sam,
  author = {Luojie Huang and Ryan Zhang and Marisa M Morakis and Michaela Taylor-Williams and Gregory N. McKay and Nicholas J. Durr},
  title = {{SAM2Flow: Interactive Optical Flow Estimation with Dual Memory for in vivo Microcirculation Analysis}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=rbr2mMSBua},
}
Figure