Loading Mutiple DICOM images
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2015-12-5
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 个评论
Walter Roberson
2015-12-5
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?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!