Reputation: 19
I want to display all dicom files in a folder. When I run the following code to show all dcm files then MATLAB displays blank windows with all pixel values zero. Sub1 folder contains 150 dcm files.
EDITED: The problem is not with the code. I just tried this code on another set of DCM images which were 256x256 and it worked. But its not working with one specific set of dcm files which are 512x512. Could there be a resolution issue? Thanks
projectdir = 'F:\MS Study\Thesis\Implementation\Dataset\Dcm\Sub1';
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 );
Y = dicominfo(filename);
Y2 = dicomread(Y);
imshow(Y2, []);
end
Upvotes: 0
Views: 298
Reputation: 2065
I would recommend this:
projectdir = 'F:\MS Study\Thesis\Implementation\Dataset\Dcm\Sub1\';
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 ]);
Y = dicominfo(filename);
Y2 = dicomread(Y);
imshow(Y2, []);
end
Upvotes: 1
Reputation: 673
set your project directory like the following example:
projectdir = ['F:\MS Study\Thesis\Implementation\Dataset\Dcm\Sub1' filesep];
dicomFiles = dir( fullfile(projectdir, '*.dcm' ));;
Upvotes: 0