Anyone know how to convert dicom file to mat file?
8 views (last 30 days)
Show older comments
Dear all,
Anyone know how convert dicom file to mat file?
the dicom file as attached.
I've tried this code. but got error.
clc
clear all
[spect map] = dicomread('Khadijahkalai.dcm');
size(spect);
spect = squeeze(spect);
for k = 1:142
matwrite(P(:,:,k),sprintf('I-13125610N125666666%03d.dcm',k));
end
8 Comments
Walter Roberson
on 31 May 2022
assign the slice to a variable. Call save() passing in the file name and the name of the variable (as a character vector.)
spectslice = spect(:, :, k);
filename = sprintf('I-13125610N125666666%03d.mat',k);
save(filename, 'spectslice')
This assumes that you have good reasons to save each slice as a separate mat file, which we are having trouble thinking of a good reason to do. It would be more common to save the entire array as one mat, or to save slices as images.
Rik
on 31 May 2022
If you really want to store every slice as a separate mat file (which I don't understand why you would want that):
dicom_filename='I-13125610N1256x25672-95.dcm';
[spect,map] = dicomread(dicom_filename);
spect = squeeze(spect);
for k = 1:24
matfilename=sprintf('%s_%03d.mat',dicom_filename,k);
spect_slice=spect(:,:,k);
save(matfilename,'spect_slice')
end
Answers (0)
See Also
Categories
Find more on Explore and Edit Images with Image Viewer App in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!