Anyone know how to convert dicom file to mat file?

8 visualizzazioni (ultimi 30 giorni)
mohd akmal masud
mohd akmal masud il 31 Mag 2022
Commentato: Rik il 31 Mag 2022
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 Commenti
Walter Roberson
Walter Roberson il 31 Mag 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
Rik il 31 Mag 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

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by