Welcome to the MRI Reconstruction in MATLAB® repository! This project showcases three effective examples of MRI reconstruction algorithms using raw k-space brain image data [1] as input. Each example is designed to leverage GPU capabilities for rapid prototyping and easy deployment in production. Additionally, these examples support CI/CD integration for automated testing and verification, and can be incorporated into an IEC 62304 -compliant medical software development workflow*.
- Description: This algorithm uses the Inverse Fast Fourier Transform (IFFT) to reconstruct MRI images from full k-space data, providing a baseline for comparison with more sophisticated methods.
- Description: Utilizing wavelet transforms, this algorithm implements a compressed sensing approach using under-sampled k-space data to enhance image reconstruction speed without compromising the quality.
3. Deep Learning-Based Algorithm (U_Net)
• Description: Employing a U_Net architecture, this algorithm uses a deep learning technique with under-sampled k-space data to showcase a modern approach for MRI reconstruction.
• GPU-Enabled: Optimized for GPU acceleration for fast prototyping as well as automatic CUDA code generation for deployment.
• Ease of Use: Designed for straightforward experimentation with easy-to-use apps for visualization and testing.
• CI/CD Integration: Enabled for use in continuous integration and continuous deployment pipelines for automated testing and verification*.
• IEC 62304 Certification: The algorithms can be incorporated into a IEC 62304 -compliant medical software development workflow*.
*. Requires additional products
You will need MATLAB release R2025a or newer and the following MathWorks Products to run these examples.
• MATLAB Coder™
• GPU Coder™
- Clone the repository:
git clone https://github.com/mathworks/MRI-Reconstruction-in-MATLAB.git
- Navigate to the project directory:
cd MRI-Reconstruction-in-MATLAB
- Open MATLAB and add the project directory to the path:
addpath(genpath('path_to_project_directory'))
-
Navigate to the
MRI_Project/scripts
folder. There are two folders available for different intentions: -
Testing Different MRI Reconstruction Examples: Check the folder: 01_Example_Scripts
-
Run the
startup.m
file first. It will download the dataset from support files and create the necessary folder structure to run the MRI reconstruction examples.
Run the desired algorithm script:
• Exp1_IFFT_MRI.mlx
for IFFT-based reconstruction.
• Exp2_CS_MRI.mlx
for wavelet-based reconstruction.
• Exp3_DL_MRI.mlx
for deep learning-based reconstruction.
- Running MRI Reconstruction Examples on GPU and Generating CUDA Code: Check the folder: 02_GPU_Support_Scripts
Run the demoScript.mlx
, which provides options to run all three examples on GPU or CPU. Furthermore, the script allows to automatically generate CUDA code of all three examples.
[1] Lyu, M., Mei, L., Huang, S. et al. M4Raw: A multi-contrast, multi-repetition, multi-channel MRI k-space dataset for low-field MRI research. Sci Data 10, 264 (2023). https://doi.org/10.1038/s41597-023-02181-4
The license is available in license.txt file in this GitHub repository.
Copyright 2025 The MathWorks, Inc.