{"id":19354,"date":"2026-08-06T10:25:08","date_gmt":"2026-08-06T14:25:08","guid":{"rendered":"https:\/\/blogs.mathworks.com\/deep-learning\/?p=19354"},"modified":"2026-08-06T10:25:08","modified_gmt":"2026-08-06T14:25:08","slug":"developing-mri-reconstruction-workflows-in-matlab-from-k-space-to-ai-based-methods","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/deep-learning\/2026\/08\/06\/developing-mri-reconstruction-workflows-in-matlab-from-k-space-to-ai-based-methods\/","title":{"rendered":"Developing MRI Reconstruction Workflows in MATLAB: From k-Space to AI-Based Methods"},"content":{"rendered":"<div class=\"rtcContent\">\r\n<div style=\"margin: 2px 10px 14px 4px; padding: 0px; line-height: 22px; min-height: 0px; white-space: pre-wrap; color: #4a4a4a; font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 15px; font-weight: 400; text-align: left;\">The following post is from Sagar Hukkire, Senior Application Engineer at MathWorks, and Visa Suomi, Medical Devices Industry Manager.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Magnetic Resonance Imaging (MRI) reconstruction plays a critical role in transforming raw scanner data (in the frequency domain, known as k-space) into clinically usable images. In the examples shown here, we use low-SNR input k-space data from a T1-weighted MRI modality, which makes robust reconstruction especially important.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Building a scalable, flexible MRI reconstruction workflow that supports experimentation, acceleration, and deployment is a challenging but increasingly important task as MRI datasets continue to grow in size, advanced reconstruction methods such as compressed sensing and deep learning become more prevalent, and the demand for faster, higher-quality imaging in both research and clinical environments continues to increase.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">In this blog post, we present an end-to-end MRI reconstruction pipeline implemented in MATLAB&reg; that combines classical physics-based techniques with modern AI methods. The workflow integrates three complementary approaches:<\/div>\r\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px;\">\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Inverse FFT (IFFT) &ndash; a baseline reconstruction using the inverse fast Fourier transform on fully sampled data.<\/li>\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Compressed Sensing (CS) with wavelets &ndash; an accelerated reconstruction using undersampled data and sparse-signal recovery.<\/li>\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Deep Learning with a U-Net &ndash; a data-driven reconstruction that learns to restore high-quality images from undersampled data.<\/li>\r\n<\/ul>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">These techniques are realized in MATLAB and support GPU acceleration, enabling rapid prototyping and easy transition to deployment via automated code generation with IEC 62304 certification support. By blending tried-and-true signal processing methods with AI-based approaches, we can achieve high-quality MRI images with shorter scan times and maintain a smooth path from R&amp;D to production.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-19358\" style=\"vertical-align: baseline; max-width: 100%; height: auto;\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2026\/08\/MRI_k_space_nutshell.png\" alt=\"MRI k-space in a nutshell\" width=\"850\" \/><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: italic; font-size: 13px; font-weight: 400; text-align: center;\">MRI k-space in a nutshell &ndash; an MRI scanner uses controlled RF &amp; gradient pulses to fill k-space (frequency data). The inverse 2D FFT then produces the final image. Efficient reconstruction must balance scan time, image quality, and compute cost.<\/div>\r\n<h2 style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Why Combine Multiple Reconstruction Approaches?<\/h2>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">MRI reconstruction involves trade-offs between acquisition speed, image resolution, and artifact suppression. Traditionally, collecting a fully sampled k-space grid and applying an IFFT yields a high-quality image with minimal aliasing. However, fully sampling k-space is time-consuming, which can prolong scan durations for patients and reduce scanner throughput in busy clinical environments. Modern methods speed up scans by undersampling k-space, but a basic IFFT of undersampled data produces artifacts such as aliasing and blurring that can limit diagnostic quality. More advanced computational techniques are therefore needed to reconstruct images from incomplete data.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Instead of betting on a single &ldquo;silver bullet&rdquo; algorithm, our MATLAB workflow incorporates multiple reconstruction strategies in one environment. This approach lets you:<\/div>\r\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px;\">\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Establish a reliable baseline: The IFFT method provides ground-truth reconstruction on full data. We use it to validate our pipeline and as a quality benchmark.<\/li>\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Explore accelerated acquisitions: Compressed sensing (CS) allows scanning with fewer k-space samples and reconstructs images by leveraging sparsity &ndash; cutting scan time significantly at the cost of computational effort.<\/li>\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Leverage AI for improvements: Deep learning with a U-Net network architecture can further enhance reconstruction quality or speed by learning from data, reducing residual artifacts and possibly enabling even faster acquisitions without sacrificing image fidelity.<\/li>\r\n<\/ul>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">By unifying all three methods in MATLAB, you get the flexibility to switch or combine approaches as needed. For example, you might start from the IFFT baseline and then compare it to a CS reconstruction or use a deep network to refine a physics-based output. And because these solutions share a common environment, it&rsquo;s straightforward to integrate them with common tasks like visualization, image post-processing, and deployment.<\/div>\r\n<h2 style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Baseline Reconstruction with Inverse FFT (IFFT)<\/h2>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">We begin with the simplest case: fully sampled k-space data. If all required frequency samples have been acquired, reconstructing an image is as direct as performing a 2D inverse Fourier transform. In MATLAB, we can do this with a few lines of code (including coil combination if multiple receiver coils are used):<\/div>\r\n<pre class=\"codeinput\"><span class=\"comment\">% Read complex k-space data from HDF5 file<\/span>\r\nkspaceData = h5read(filePath, datasetPath);\r\n\r\n<span class=\"comment\">% Move the zero-frequency component from the center to the corners<\/span>\r\n<span class=\"comment\">% (undo the scanner\/vendor-specific k-space centering)<\/span>\r\nkspaceShifted = ifftshift(ifftshift(kspaceData, 1), 2);\r\n\r\n<span class=\"comment\">% Construct a complex-valued k-space matrix from real and imaginary parts<\/span>\r\nkspace = complex(kspaceShifted.r, kspaceShifted.i);\r\n\r\n<span class=\"comment\">% Perform 2-D inverse Fourier transform to reconstruct coil images<\/span>\r\nimageC = ifft2(double(kspace));\r\n\r\n<span class=\"comment\">% Shift reconstructed images so that the image center appears in the middle<\/span>\r\nimageC = fftshift(fftshift(imageC, 1), 2);\r\n\r\n<span class=\"comment\">% Combine multiple receiver coils using Root-Sum-of-Squares (RSS)<\/span>\r\n<span class=\"comment\">% Coil dimension is assumed to be the 3rd dimension<\/span>\r\nreconImage = sqrt(sum(abs(imageC).^2, 3));\r\n\r\n<span class=\"comment\">% Remove singleton dimensions to obtain the final image matrix<\/span>\r\nreconImage = squeeze(reconImage);\r\nimshow(abs(gather(reconImage)), []);              <span class=\"comment\">% display magnitude image<\/span><\/pre>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">This baseline IFFT reconstruction is fast, deterministic, and rooted in the physics of MRI. With fully sampled data, it produces a high-quality image that can serve as our reference. However, the need to capture all of k-space means long scan times in practice. Next, we look at how to get good images faster by collecting less data and using smarter reconstruction algorithms.<\/div>\r\n<h2 style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Compressed Sensing: Faster Scans with Sparse Reconstruction<\/h2>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Compressed Sensing (CS) is a technique that enables accurate reconstructions from significantly fewer samples by exploiting sparsity in some transform domain. For MRI, a common approach is to assume the image has a sparse representation in the wavelet domain. By undersampling k-space (skipping many phase-encode lines), we speed up acquisition; then, an iterative algorithm recovers the image by enforcing wavelet sparsity and consistency with the measured data.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">In our workflow&rsquo;s CS example, we simulate an undersampled acquisition (e.g., retaining 25% of the original k-space points in a variable-density random pattern). The reconstruction uses an iterative refine-and-threshold algorithm:<\/div>\r\n<pre class=\"codeinput\"><span class=\"comment\">% Initialize storage for compressed sensing reconstructions<\/span>\r\nim_cs = zeros(size(kspace_data));\r\n\r\n<span class=\"comment\">% Reconstruct each coil and frame independently<\/span>\r\nfor frame = 1:num_frames\r\n    for coil = 1:num_coils\r\n\r\n        <span class=\"comment\">% Apply undersampling mask in k-space<\/span>\r\n        undersampled_data = kspace_data(:,:,coil,frame) .* mask_vardens;\r\n\r\n        <span class=\"comment\">% Initial image reconstruction from undersampled data<\/span>\r\n        im_cs(:,:,coil,frame) = ifft2s(undersampled_data);\r\n\r\n        <span class=\"comment\">% Apply coil sensitivity map<\/span>\r\n        im_cs(:,:,coil,frame) = ...\r\n            im_cs(:,:,coil,frame) .* coilSensitivityMaps(:,:,coil,frame);\r\n\r\n        <span class=\"comment\">% POCS-based compressed sensing reconstruction<\/span>\r\n        for iter = 1:num_iters\r\n\r\n            <span class=\"comment\">% Transform to wavelet domain and enforce sparsity<\/span>\r\n            [C, S] = wavedec2(im_cs(:,:,coil,frame), 2, 'db1');\r\n            C_thresh = wthresh(C, 's', threshold);\r\n            im_cs(:,:,coil,frame) = waverec2(C_thresh, S, 'db1');\r\n\r\n            <span class=\"comment\">% Enforce k-space data consistency<\/span>\r\n            kspace_estimate = fft2s(im_cs(:,:,coil,frame));\r\n            kspace_estimate(mask_vardens) = ...\r\n                undersampled_data(mask_vardens);\r\n\r\n            <span class=\"comment\">% Update image estimate<\/span>\r\n            im_cs(:,:,coil,frame) = ifft2s(kspace_estimate);\r\n        end\r\n    end\r\nend\r\n\r\n<span class=\"comment\">% Combine all coils using Root-Sum-of-Squares (RSS)<\/span>\r\nrss_CSimage = sqrt(sum(abs(im_cs).^2, 3));\r\n\r\n<span class=\"comment\">% Remove singleton dimensions<\/span>\r\nrss_CSimage = squeeze(rss_CSimage);<\/pre>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">How it works: The loop alternates between enforcing measured data (swapping in the acquired k-space lines each iteration) and enforcing image sparsity (zeroing out small wavelet coefficients). Over iterations, the image converges as missing information is filled in by the constraints. The result is a high-quality image reconstructed from a fraction of the data.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">If we directly applied an IFFT to undersampled data, we would see strong artifacts due to violation of the Nyquist sampling criterion. With compressed sensing, many of those artifacts are suppressed and the image quality can approach the fully sampled baseline, even when only a fraction of the original k-space samples are acquired. Depending on the sampling pattern, pulse sequence, scanner constraints, and reconstruction setup, this can support meaningful scan-time reductions while helping preserve image quality.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-19356\" style=\"vertical-align: baseline; max-width: 100%; height: auto;\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2026\/08\/Compressed_sensing_reconstruction.png\" alt=\"Compressed sensing reconstruction of a representative T1-weighted MRI slice\" width=\"850\" \/><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: italic; font-size: 13px; font-weight: 400; text-align: center;\">Compressed sensing reconstruction of a representative T1-weighted MRI slice from undersampled, low-SNR input k-space data. The image shows how sparsity-based reconstruction can suppress undersampling artifacts while preserving major anatomical structures.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Note: The above code uses functions from Wavelet Toolbox&trade; (wavedec2, waverec2) and can automatically leverage the Parallel Computing Toolbox&trade; to run on a GPU if available (via gpuArray). The iterative CS algorithm is more computationally heavy than IFFT, but GPU acceleration can make it practical for routine use.<\/div>\r\n<h2 style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Deep Learning Reconstruction with U-Net<\/h2>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Our third approach uses deep learning to push MRI reconstruction further. Instead of relying on hand-crafted transforms or optimization, we train a U-Net (a type of convolutional neural network) to learn the transformation from incomplete data to fully reconstructed image. U-Nets are well-suited for image-to-image tasks like segmentation and, here, reconstruction, thanks to their encoder-decoder structure with skip connections that captures both global context and fine details.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">In our MATLAB example, we feed the network zero-filled IFFT reconstructions of undersampled data as inputs and the corresponding fully sampled images as targets. Using the Deep Learning Toolbox&trade;, we can set up and train the U-Net as follows:<\/div>\r\n<pre class=\"codeinput\"><span class=\"comment\">% Define a custom U-Net architecture for MRI reconstruction<\/span>\r\nlgraph = createCustomUNet([256 256 18], 18);\r\n\r\n<span class=\"comment\">% Specify training parameters<\/span>\r\noptions = trainingOptions(\"adam\", ...\r\n    InitialLearnRate = 1e-3, ...\r\n    MaxEpochs = 600, ...\r\n    MiniBatchSize = 12);\r\n\r\n<span class=\"comment\">% Train the network using undersampled and reference images<\/span>\r\nnet = trainNetwork(inputDataTrain, groundTruthDataTrain, ...\r\n                   lgraph, options);\r\n\r\n<span class=\"comment\">% Reconstruct images using the trained network<\/span>\r\nreconDL = predict(net, inputDataTest);<\/pre>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">What&rsquo;s happening? We define a custom U-Net architecture for image-to-image regression and train it on paired data: zero-filled reconstructions from undersampled k-space as inputs and fully sampled reconstructions as targets. The encoder-decoder structure with skip connections helps the network capture both global context and fine image details. Training options such as the optimizer, learning rate, number of epochs, and mini-batch size control the learning process. When a supported GPU is available and the execution environment is set appropriately, MATLAB can use GPU acceleration through Parallel Computing Toolbox&trade;. After training, the predict function generates rapid reconstructions for new undersampled inputs.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">This deep learning approach learns to map artifact-corrupted, zero-filled reconstructions to reference-quality images. If trained and validated well, the U-Net can reduce residual artifacts compared with conventional undersampled reconstruction and may support higher acceleration factors for a given image-quality target. It also runs very fast at inference because reconstruction is essentially one forward pass through the network. However, deep learning models require representative training data, careful validation, and quality-control checks to ensure that they generalize to new scans and do not introduce unintended artifacts. In practice, combining AI with physics-based methods, such as using a CS reconstruction as an input to the U-Net, can further improve robustness.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-19357\" style=\"vertical-align: baseline; max-width: 100%; height: auto;\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2026\/08\/Deep_learning_reconstruction.png\" alt=\"Deep learning reconstruction of a representative T1-weighted MRI slice\" width=\"850\" \/><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: italic; font-size: 13px; font-weight: 400; text-align: center;\">Deep learning reconstruction of a similar representative T1-weighted MRI slice from the same low-SNR input k-space dataset. The U-Net output is generated from an undersampled input reconstruction and is intended to reduce residual artifacts while preserving fine image detail.<\/div>\r\n<h2 style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Verification, Validation, and Deployment<\/h2>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Developing these algorithms is only part of the story &ndash; practical MRI workflows also require rich visualization and an eye towards deployment:<\/div>\r\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px;\">\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Automatic Testing and Verification: Because our three methods are implemented in one environment, we can easily create test scripts to verify that each reconstruction matches expected results (within tolerance) or to measure performance (like PSNR, SSIM) across a dataset. This can be integrated into a CI\/CD pipeline (Continuous Integration\/Deployment) to ensure code changes don&rsquo;t break the pipeline.<\/li>\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Interactive Visualization and Validation: MATLAB&rsquo;s Medical Imaging Toolbox&trade; provides apps and functions to explore 2D slices and 3D volumes, adjust colormaps (colormap), and even use cinematic volume rendering (volshow). This helps in visually validating results side by side: for example, comparing a CS reconstruction to the IFFT baseline, or overlaying error maps to spot differences.<\/li>\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">GPU Code Generation and Deployment: A standout feature is the ability to automatically generate C\/C++ and CUDA&reg; code from our MATLAB algorithms for deployment with IEC 62304 certification support. Using MATLAB Coder&trade; and GPU Coder&trade;, we can translate the IFFT, CS, or U-Net reconstruction into highly optimized code for embedded applications or integration into an MRI scanner&rsquo;s software. For instance, we can generate a MEX function or a standalone library from our MATLAB code with just a few commands. The image below shows a snippet of the code generation process in MATLAB:<\/li>\r\n<\/ul>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-19355\" style=\"vertical-align: baseline; max-width: 100%; height: auto;\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2026\/08\/GPU_Code_Gen_600dpi.jpg\" alt=\"GPU code generation in MATLAB for the IFFT reconstruction algorithm\" width=\"850\" \/><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: italic; font-size: 13px; font-weight: 400; text-align: center;\">GPU code generation in MATLAB for the IFFT reconstruction algorithm. The code generator converts our MATLAB reconstruction function into a C\/CUDA implementation (left: generated code preview and analysis) and reports a successful build (bottom). This enables integrating the proven algorithm into production systems, such as scanner software, with minimal manual coding.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Thanks to GPU acceleration and code generation, MRI reconstruction methods developed in MATLAB can scale from desktop prototyping to execution on specialized hardware. For example, once a U-Net is trained and validated in MATLAB, GPU Coder can help deploy inference code that uses optimized NVIDIA&reg; libraries such as cuDNN and TensorRT, reducing the need to hand-code the inference engine.<\/div>\r\n<h2 style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Conclusion and Key Takeaways<\/h2>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">By combining classical and AI-based reconstruction techniques in a single MATLAB workflow, we can address the diverse needs of modern MRI systems. A unified environment streamlines the process: raw data import, reconstruction, testing, verification, visualization, validation, and certification can all be done in one place, and when it&rsquo;s time to deploy, the same code is ready for automatic translation to C\/CUDA.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">In summary, this workflow shows how MATLAB can support MRI reconstruction from early experimentation to deployment:<\/div>\r\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px;\">\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">IFFT reconstruction provides a fast and reliable baseline for fully sampled data.<\/li>\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Compressed sensing enables accelerated acquisitions by combining undersampling, sparsity, and data-consistency constraints.<\/li>\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Deep learning can help reduce artifacts in undersampled reconstructions when trained and validated with representative data.<\/li>\r\n  <li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">GPU acceleration and code generation help bridge the gap between research prototypes and deployable reconstruction pipelines.<\/li>\r\n<\/ul>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">We hope this example has shown how classic reconstruction techniques and AI can reinforce each other. By exploring baseline, compressed sensing, and deep learning methods within a unified setting, engineers are empowered to iterate quickly and tailor MRI reconstruction workflows to achieve both faster scans and high image quality, all while maintaining a clear path to real-world deployment.<\/div>\r\n<h2 style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Try the examples yourself: <a href=\"https:\/\/github.com\/mathworks\/MRI-Reconstruction-in-MATLAB\/tree\/main\" target=\"_blank\" rel=\"noopener\">MRI Reconstruction in MATLAB<\/a><\/h2>\r\n<\/div>\r\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2026\/08\/MRI_k_space_nutshell.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\nThe following post is from Sagar Hukkire, Senior Application Engineer at MathWorks, and Visa Suomi, Medical Devices Industry Manager.\r\nMagnetic Resonance Imaging (MRI) reconstruction plays a... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/deep-learning\/2026\/08\/06\/developing-mri-reconstruction-workflows-in-matlab-from-k-space-to-ai-based-methods\/\">read more >><\/a><\/p>","protected":false},"author":156,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts\/19354"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/users\/156"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/comments?post=19354"}],"version-history":[{"count":6,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts\/19354\/revisions"}],"predecessor-version":[{"id":19365,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts\/19354\/revisions\/19365"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/media?parent=19354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/categories?post=19354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/tags?post=19354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}