You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
i wanted to read .dcm files for my project from a folder
11 views (last 30 days)
Show older comments
can anyone give me code to read the dicom files from folder and
X = repmat(int16(0), [128 128 1 200]);
dicomFiles = dir('E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\*.dcm');
y=length(dicomFiles)
% Read the series of images.
for p=1:y
%filename = sprintf('IM_%01d.dcm', p);
X(:,:,1,p) = dicomread(dicomFiles);
end
% Display the image stack.
montage(X,[])
Accepted Answer
Walter Roberson
on 14 Nov 2016
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
dicomFiles = dir( fullfile(projectdir, '*.dcm' ));
y = length(dicomFiles)
X = zeros(128, 128, 1, y, 'uint8');
% Read the series of images.
for p=1:y
filename = fullfile( projectdir, dicomFiles(p).name );
X(:,:,1,p) = dicomread(filename);
end
% Display the image stack.
montage(X,[])
14 Comments
andhavarapu lokesh
on 14 Nov 2016
thank you very much sir but iam still getting this error Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error in rep (line 10) X(:,:,1,p) = dicomread(filename);
Walter Roberson
on 14 Nov 2016
The below will probably emit some messages, but we will need to know the sizes that it reports.
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
dicomFiles = dir( fullfile(projectdir, '*.dcm' ));
y = length(dicomFiles)
X = zeros(128, 128, 1, y, 'uint8');
% Read the series of images.
for p=1:y
filename = fullfile( projectdir, dicomFiles(p).name );
imdata = dicomread(filename);
imsize = size(imdata);
if ~isequal( imsize, [128 128] )
fprintf('file is unexpected size %s instead of [128 128], skipping "%s"\n', mat2str(imsize), filename);
else
X(:,:,1,p) = imdata;
end
% Display the image stack.
montage(X,[])
andhavarapu lokesh
on 14 Nov 2016
Edited: Walter Roberson
on 14 Nov 2016
>> Untitled7
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_1.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_10.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_100.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_101.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_102.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_103.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_104.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_105.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_106.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_107.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_108.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_109.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_11.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_110.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_111.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_112.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_113.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_114.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_115.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_116.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_117.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_118.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_119.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_12.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_120.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_121.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_122.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_123.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_124.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_125.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_126.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_127.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_128.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_129.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_13.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_130.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_131.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_132.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_133.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_134.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_135.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_136.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_137.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_138.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_139.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_14.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_140.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_141.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_142.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_143.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_145.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_15.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_16.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_17.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_18.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_19.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_2.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_20.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_21.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_22.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_23.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_24.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_25.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_26.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_27.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_28.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_29.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_3.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_30.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_31.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_32.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_33.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_34.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_35.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_36.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_37.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_38.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_39.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_4.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_40.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_41.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_42.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_43.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_44.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_45.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_46.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_47.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_48.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_49.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_5.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_50.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_51.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_52.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_53.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_54.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_55.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_56.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_57.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_58.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_59.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_6.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_60.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_61.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_62.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_63.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_64.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_65.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_66.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_67.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_68.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_69.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_7.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_70.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_71.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_72.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_73.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_74.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_75.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_76.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_77.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_78.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_79.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_8.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_80.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_81.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_82.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_83.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_84.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_85.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_86.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_87.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_88.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_89.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_9.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_90.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_91.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_92.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_93.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_94.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_95.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_96.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_97.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_98.dcm"
file is unexpected size [128 128 1 72] instead of [128 128], skipping "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_99.dcm"
Warning: Image is too big to fit on screen; displaying at 50%
> In images.internal.initSize (line 71)
In imshow (line 305)
In montage (line 152)
In Untitled7 (line 16)
sir it is running but iam gettig only empty figure with black image
Walter Roberson
on 14 Nov 2016
You have a problem. Each of the .dcm files has 72 slices stored in it. You can represent any one of them in 3D, but you would need to add another dimension to represent the series of 200 of them, such as if you were to use animation for them.
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
y = 200;
X = zeros(128, 128, 1, 72, y, 'uint8');
% Read the series of images.
for p=1:y
thisfile = sprintf('%d.dcm', p);
filename = fullfile( projectdir, thisfile );
imdata = dicomread(filename);
imsize = size(imdata);
if ~isequal( imsize, [128 128 1 72] )
fprintf('file is unexpected size %s instead of [128 128 1 72], skipping "%s"\n', mat2str(imsize), filename);
else
X(:, :, :, :, p) = imdata;
end
figure();
% Display the first image stack.
montage(X(:,:,:,:,1), [])
axis image
title('First file, all layers')
figure();
% Display the first layer of all of the stacks
montage( permute( X(:, :, :, 1, :), [1 2 3 5 4]) )
title('First layer of all files')
andhavarapu lokesh
on 14 Nov 2016
Error using dicomread>getFileDetails (line 1426) File "E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002\IM_144.dcm" not found.
Error in dicomread>newDicomread (line 172) fileDetails = getFileDetails(filename);
Error in dicomread (line 79) [X, map, alpha, overlays] = newDicomread(msgname, frames);
Error in Untitled7 (line 8) imdata = dicomread(filename); still iam getting error
Walter Roberson
on 14 Nov 2016
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
dicomFiles = dir( fullfile(projectdir, '*.dcm' ));
y = length(dicomFiles);
fnums = zeros(1,y);
for p = 1 : y
[~, basename, ~] = fileparts(dicomFiles(p).name);
fnums(p) = str2num(basename);
end
fnums = unique(fnums);
y = length(fnums);
X = zeros(128, 128, 1, 72, y, 'uint8');
% Read the series of images.
for p=1:y
thisfile = sprintf('%d.dcm', fnums(p));
filename = fullfile( projectdir, thisfile );
imdata = dicomread(filename);
imsize = size(imdata);
if ~isequal( imsize, [128 128 1 72] )
fprintf('file is unexpected size %s instead of [128 128 1 72], skipping "%s"\n', mat2str(imsize), filename);
else
X(:, :, :, :, p) = imdata;
end
figure();
% Display the first image stack.
montage(X(:,:,:,:,1), [])
axis image
title('First file, all layers')
figure();
% Display the first layer of all of the stacks
montage( permute( X(:, :, :, 1, :), [1 2 3 5 4]) )
title('First layer of all files')
fprintf('%d files loaded into X, with 72 slices each\n', y);
fprintf('You cannot meaningfully view everything together.\n');
fprintf('I do not know what you hope to be able to do with all of this images, but you have them now.\n');
andhavarapu lokesh
on 14 Nov 2016
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in Untitled8 (line 7) fnums(p) = str2num('basename');
Walter Roberson
on 14 Nov 2016
I said
fnums(p) = str2num(basename);
not
fnums(p) = str2num('basename');
andhavarapu lokesh
on 16 Nov 2016
Edited: Walter Roberson
on 16 Nov 2016
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
y = 15;
X = zeros(128, 128, 1, 72, y, 'uint8');
% Read the series of images.
for p=1:y
thisfile = sprintf('IM_%1d.dcm', p);
filename = fullfile( projectdir, thisfile );
imdata = dicomread(filename);
imsize = size(imdata);
if ~isequal( imsize, [128 128 1 72] )
fprintf('file is unexpected size %s instead of [128 128 1 72], skipping "%s"\n', mat2str(imsize), filename);
else
X(:, :, :, :, p) = imdata;
end
end
figure();
% Display the first image stack.
z=montage(X(:,:,:,:,p), []);
axis image
title('First file, all layers')
figure();
% Display the first layer of all of the stacks
montage( permute( X(:, :, :, 1, :), [1 2 3 5 4]) )
title('First layer of all files')
sir still iam not able to read a single slice from 72 slice of each dicom image
andhavarapu lokesh
on 25 Nov 2016
sir after reading the images i wanted to do volume rendering for the above code how to do please can you give me any code where i need to do find the leftventricle ejection fraction by calculating the end sistole and diastole volumes
Walter Roberson
on 25 Nov 2016
I suggest you get vol3d v2 from the file exchange to do the volume rendering on each squeeze(X(:, :, :, :, p))
I do not know anything about calculating volume fraction or isolating ventricles. I always fainted when they did the heart rendering where I worked.
More Answers (1)
Mostafa Hussien
on 18 Feb 2020
i have a folder its name Brain-Tumor-Progressionon Desktop its dicom file how can i read a file insid this folder called PGBM-001 please answer
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)