Anyone know how to convert dicom file to mat file?

조회 수: 11 (최근 30일)
mohd akmal masud
mohd akmal masud 2022년 5월 31일
댓글: Rik 2022년 5월 31일
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
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
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개)

카테고리

Help CenterFile Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by