MATLAB analysis pipeline for two-photon microscopy vasculature -- vessel tracing, diameter measurement, mesh reconstruction, and 3D visualization.
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#E8F4FD', 'primaryBorderColor': '#7BA7C9', 'primaryTextColor': '#2C3E50', 'secondaryColor': '#FDF2E9', 'secondaryBorderColor': '#D4A574', 'secondaryTextColor': '#2C3E50', 'tertiaryColor': '#EAFAF1', 'tertiaryBorderColor': '#82C9A1', 'tertiaryTextColor': '#2C3E50', 'lineColor': '#5D6D7E', 'textColor': '#2C3E50', 'background': '#FFFFFF', 'mainBkg': '#E8F4FD', 'nodeBorder': '#7BA7C9', 'clusterBkg': '#F8F9FA', 'clusterBorder': '#BDC3C7', 'fontSize': '14px'}}}%%
graph LR
A[Raw 2PM Stack] --> B[Denoising]
B --> C[Vesselness Filter]
C --> D[Segmentation]
D --> E[Mesh Reconstruction]
E --> F[Morphology Analysis]
F --> G[3D Visualization]
style A fill:#FDF2E9,stroke:#D4A574
style B fill:#E8F4FD,stroke:#7BA7C9
style C fill:#E8F4FD,stroke:#7BA7C9
style D fill:#E8F4FD,stroke:#7BA7C9
style E fill:#E8F4FD,stroke:#7BA7C9
style F fill:#E8F4FD,stroke:#7BA7C9
style G fill:#EAFAF1,stroke:#82C9A1
twoPhotonVessels is a MATLAB toolbox for end-to-end analysis of vasculature imaged with two-photon microscopy. It covers the complete pipeline from raw noisy volumetric stacks through denoising, vessel enhancement, segmentation, 3D mesh reconstruction, and quantitative morphological analysis.
The denoising module supports multiple approaches including BM4D (block-matching in 4D), guided filtering, and non-local means for Poisson noise. Vessel enhancement uses oriented optimally-selective flux (OOF/OFA) filters to highlight tubular structures. Segmentation can be performed via level sets or continuous max-flow methods. The resulting binary volumes are converted to 3D surface meshes using marching cubes or CGAL Poisson reconstruction, enabling diameter measurement, shape diameter function (SDF) analysis, and mesh registration across time points.
This toolbox is designed for neurovascular researchers working with two-photon microscopy data who need reproducible quantitative analysis of vessel morphology, diameter distributions, and permeability characteristics.
- Multiple denoising strategies: BM4D, guided filter, non-local means (Poisson-adapted)
- Vesselness filtering via OOF, OOF-OFA, and multi-scale approaches
- Segmentation with level sets and continuous max-flow
- 3D mesh reconstruction (marching cubes, CGAL Poisson surface)
- Morphological analysis: SDF values, curvature, permeability coefficients
- Mesh registration via ICP for longitudinal studies
- Extensive visualization and figure export utilities
- Demo scripts for each pipeline stage
% Add toolbox to path
addpath(genpath('twoPhotonVessels'));
% Process a single file through the full pipeline
process_SingleFile('path/to/your/stack.tif');
% Or run individual demos
demo_plotSteps % Visualize each pipeline stage
demo_justTheMeshPart % Mesh reconstruction only
demo_meshMeanCurvature % Curvature analysistwoPhotonVessels/
├── 3rdParty/ # External dependencies
│ ├── BM4D/ # Block-matching 4D denoising
│ ├── iso2mesh/ # Mesh generation from volumes
│ ├── gptoolbox/ # Geometry processing
│ ├── OOF/ # Oriented optimally-selective flux
│ └── ... # (20+ third-party packages)
├── demos/ # Runnable demo scripts
│ ├── demo_plotSteps.m
│ ├── demo_justTheMeshPart.m
│ └── segmentationDemo/
├── denoise_*.m # Denoising functions
├── enhance_*.m # Vessel enhancement filters
├── segment_*.m # Segmentation methods
├── mesh_*.m # Mesh reconstruction and filtering
├── analyze_*.m # Morphological measurements
├── visualize_*.m # Visualization utilities
├── export_*.m # Figure and data export
└── testData/ # Sample test data
- MATLAB (tested on R2015b+)
- Image Processing Toolbox
- Statistics and Machine Learning Toolbox
- Third-party packages (included in
3rdParty/) - Optional: CGAL for Poisson surface reconstruction
- Optional: ImageJ/Fiji via MIJ bridge for vesselness computation
If you use this toolbox, please cite the companion segmentation paper:
@article{teikari2016deep,
title={Deep Learning Convolutional Networks for Multiphoton Microscopy
Vasculature Segmentation},
author={Teikari, Petteri and Santos, Marc and Poon, Charissa and Hynynen, Kullervo},
journal={arXiv preprint arXiv:1606.02382},
year={2016}
}MIT