SPM12 toolbox implementation of "Synthetic Data for Robust Stroke Segmentation" published in Machine Learning for Biomedical Imaging (MELBA) 2025.
This SPM12 toolbox provides automated stroke lesion segmentation for brain MRI and CT images using deep learning. The toolbox integrates directly into SPM's batch system and includes a pre-trained U-Net model trained on synthetic stroke data for robust performance across different imaging protocols.
Features:
- Pre-trained U-Net model for automated stroke lesion segmentation
- Native SPM12 batch interface integration
- Support for both T1-weighted MRI and CT imaging
- Test Time Augmentation (TTA) for improved accuracy
- Automatic 1mm isotropic resampling with restoration to original resolution
- Morphological hole filling and configurable probability thresholds
Paper: Chalcroft, L., Pappas, I., Price, C. J., & Ashburner, J. (2025). Synthetic Data for Robust Stroke Segmentation. Machine Learning for Biomedical Imaging, 3, 317–346.
Note: This tool is currently in early development. Please report any issues on GitHub to help improve the tool's reliability.
- MATLAB (R2024a or later recommended)
- SPM12 (SPM25 should work but is untested)
- Deep Learning Toolbox
- Image Processing Toolbox
- Deep Learning Toolbox Converter for ONNX Model Format (Support Package)
-
Download the toolbox:
git clone https://github.com/liamchalcroft/SynthStrokeSPM.git
-
Install ONNX support package:
- Open MATLAB → HOME tab → Add-Ons → Get Add-Ons
- Search for "Deep Learning Toolbox Converter for ONNX Model Format"
- Install the package
-
Place in SPM toolbox directory:
mv SynthStrokeSPM /path/to/spm12/toolbox/
-
Restart SPM12 or refresh the toolbox menu
The toolbox requires no compilation and works entirely within MATLAB.
- Open SPM12 and navigate to Batch → SPM → Tools → SynthStroke
- Test with sample data: Select
test_input/ct_img.nii
ortest_input/mprage_img.nii
- Run batch to generate segmentation results
- Load images: Select your T1-weighted MRI or CT scans (.nii/.img files)
- Configure options:
- Use TTA: Enable for improved accuracy (slower processing)
- Fill Holes: Remove small gaps in lesion masks
- Lesion Threshold: Adjust sensitivity (default: 0.5)
- Output Directory: Specify save location (optional)
- Run batch processing
- Single image: 1-2 minutes (standard), 5-10 minutes (with TTA)
- Batch processing: Scales linearly with number of images
The toolbox generates the following files:
c1*
- Background tissue posterior probability mapc2*
- Stroke lesion posterior probability maplesion_*
- Binary lesion mask (thresholded with optional hole filling)
For issues, questions, or contributions:
- Bug reports: Open an issue
- PyTorch implementation: SynthStroke repository
- Questions: Contact via GitHub issues
If you use this work in your research, please cite:
@article{Chalcroft2025,
title = {Synthetic Data for Robust Stroke Segmentation},
volume = {3},
ISSN = {2766-905X},
url = {http://dx.doi.org/10.59275/j.melba.2025-f3g6},
DOI = {10.59275/j.melba.2025-f3g6},
number = {August 2025},
journal = {Machine Learning for Biomedical Imaging},
publisher = {Machine Learning for Biomedical Imaging},
author = {Chalcroft, Liam and Pappas, Ioannis and Price, Cathy J. and Ashburner, John},
year = {2025},
month = aug,
pages = {317–346}
}
This project is licensed under the MIT License - see the LICENSE file for details.