Sparse representation for brain image segmentation

by li wang
This is a Matlab demo code of patch-based sparse representation for brain image segmentation.
Updated 28 Aug 2022
Download link:
Code document: Generally, we assume the similar patches share the same labels. Based on this assumption, we employ the sparse representation to measure the patch similarity between the target patch and the template patches, then propagate the labels from the templates to the target image. In this source code, the target image is test.img, the atlas intensity image are named as atlas1, …, atlas7 and their corresponding labels are names as atlas1_label, …, atlas7_label. I have already aligned all the atlases to the target image space based on the intensity image (Note that atlas images and labels are in the Atlas folder).
1. Download the sparse coding toolbox: SPMAS toolbox ( After downloading, unzip it and run the examples in
Matlab to see if it is correctly working.
2. Modify the path in the Demo_sparse_segmentation.m:
3. In Matlab, run “mex extract_patches_for_prior.c”
4. Run Demo_sparse_segmentation.m in Matlab.
5. Enjoy and you will get the results.
More information and codes could be found in my homepage:
MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on MRI in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!