Loading Mutiple DICOM images
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hello,
i have 53 DICOM images named 000000.dcm - 000053.dcm. i tried to load images and montage view but i am getting only 53rd image.
mri=zeros(256,256,54);
for i=0:53
if i<=9
a=dicomread(['00000' num2str(i) '.dcm']);
else
a=dicomread(['0000' num2str(i) '.dcm']);
end
a(:,:,i+1)=uint8(a);
end
%%Generate Montage
figure
montage(a(:,:,i+1), 'DisplayRange', [0 255]);
i am getting a warning message as Warning: Suspicious fragmentary file, might not be DICOM. Warning: Not enough data imported. Attempted to read 225731429 bytes at position 8. Only read 132756.
0 commentaires
Réponses (1)
Walter Roberson
le 5 Déc 2015
Note: you do not need the 'if':
a = dicomread('000000.dcm');
size0 = size(a);
a(end,end,54) = 0; %for efficiency
for i = 1 : 53
thisfile = sprintf('%06d.dcm', i);
thisdata = dicomread( thisfile );
if ~isequal(size(thisdata), size0)
warning( sprintf('skipped file %s, wrong data size', thisfile ) );
else
a(:,:,i+1) = thisdata;
end
end
This will tell you which files it skipped, and it will leave that slice as all 0.
2 commentaires
Walter Roberson
le 5 Déc 2015
a = dicomread('000000.dcm');
size0 = size(a);
a(end,end,:,54) = 0; %for efficiency
for i = 1 : 53
thisfile = sprintf('%06d.dcm', i);
thisdata = dicomread( thisfile );
if ~isequal(size(thisdata), size0)
warning( sprintf('skipped file %s, wrong data size', thisfile ) );
else
a(:,:,:,i+1) = thisdata;
end
end
montage requires the individual images to be in the 4th dimension.
I expect this to still tell you that one of your images is corrupt, but I am expecting that it will tell you which of your images is corrupt, which you would then investigate. Which file is it telling you was skipped?
Voir également
Catégories
En savoir plus sur DICOM Format dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!