How to save multiple dicom images in to a single mat file?

I have 100 MRI images in dicom format. How can I save all of them in a single .mat file? Thank you in advance.

Respuestas (2)

fd = fullfile(pwd, 'dcms');
fs = ls(fullfile(fd, '*.dcm'));
ims = [];
for i = 1 : size(fs,1)
im = dicomread(fullfile(fd, strtrim(fs(i,:))));
ims{i} = im;
end
save ims.mat ims

3 comentarios

Shourya
Shourya el 25 de Mzo. de 2022
Editada: Shourya el 26 de Mzo. de 2022
@yanqi liu Thank you for your response. I tried but it is throwing the following error.
------------------------------------------------
Error using images.internal.dicom.getFileDetails (line 14)
Error in dicomread>newDicomread (line 194)
fileDetails = images.internal.dicom.getFileDetails(filename, verifyIsDICOM);
Error in dicomread (line 91)
[X, map, alpha, overlays] = newDicomread(msgname, frames, useVRHeuristic);
Error in untitled7 (line 5)
im = dicomread(fullfile(fd, strtrim(fs(i,:))));
--------------------------------------------------------------------------------
I got a mat file of size 1x100 where each cell represents an image . How can I get a matrix where each column represents an image?
Yes am also facing same problem related to my work .

Iniciar sesión para comentar.

Hi, I made some changes in Yanqi Liu's answer. Try this!
fd = fullfile(pwd);
fs = ls(fullfile(fd, '*.dcm'));
ims = [];
for i = 1 : size(fs,1)
im = dicomread(fullfile(fd, strtrim(fs(i,:))));
ims(:,:,i) = im;
end
save ims.mat ims

Categorías

Más información sobre Convert Image Type en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 24 de Mzo. de 2022

Respondida:

el 26 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by