Converting 4D- Dynamic Contrast Enhanced MRI (DCE-MRI) MATLAB Data into DICOM
4 次查看(过去 30 天)
显示 更早的评论
With the following code I try to convert the matlab data into dicom data. The data was converted into dicom but when I want to visualize this dicom data in another software environment such as : MITK ( a software like 3D Slicer) it is showing only 1 axial slice amd only 1 time point. Though I have 15 slice and 85 different timepoints in original.
so the original overall size is = 64x64x15x84 (rows x col x slice x timepoints )
in software the size is = 64x
% Load the .mat file
matFile = 'M132_D0_E25_dce.mat';
load(matFile); % Load the data from the .mat file
% Extract the 4D dynamic DCE MRI data
dceData = dce_struct.dceDyn;
% Get the dimensions of the 4D data
[rows, cols, slices, timePoints] = size(dceData);
% Define the DICOM output directory
outputDir = 'dicom_output';
if ~exist(outputDir, 'dir')
mkdir(outputDir);
end
% Normalize and scale the data for better quality before DICOM conversion
% Find the global minimum and maximum values in the 4D data
minValue = min(dceData(:)); % Global minimum
maxValue = max(dceData(:)); % Global maximum
% Normalize the data to a range of 0 to 4294967295 (for uint32)
dceDataScaled = (dceData - minValue) ./ (maxValue - minValue); % Normalize between 0 and 1
dceDataScaled = uint32(dceDataScaled * 4294967295); % Scale to full uint32 range
% Loop through time points (t), slices (z), and save each slice for each time point
for t = 1:timePoints % Loop over time points
for z = 1:slices % Loop over slices
% Create the DICOM filename, including time and slice information
dicomFileName = fullfile(outputDir, sprintf('time_%02d_slice_%03d.dcm', t, z));
% Extract the 2D slice data for the current time point and slice
sliceData = dceDataScaled(:,:,z,t); % Extract the 2D slice for this time and slice
% Write the current slice to a DICOM file
dicomwrite(dceDataScaled, dicomFileName);
end
end
disp('4D DICOM conversion completed with axial slices and time points saved.');
1 个评论
Gayathri
2024-9-5
I think you have mistakenly written
dicomwrite(dceDataScaled, dicomFileName);
instead of
dicomwrite(sliceData, dicomFileName);
This will help you solve the issue.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!