Anyone know how to convert dicom file to mat file?
11 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2022-5-31
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
2022-5-31
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
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!