Loading Mutiple DICOM images
조회 수: 5 (최근 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?
참고 항목
카테고리
Help Center 및 File Exchange에서 DICOM Format에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!