Anyone know how to convert dicom file to mat file?

15 ビュー (過去 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 Center および File ExchangeExplore 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