clc
clear all;
close all;
warning off
myFolder='your dicom root';
filePattern = fullfile(myFolder,'*.dcm');
dcmfiles = dir(filePattern);
flen=length(dcmfiles);
for k = 1:flen
baseFileName =dcmfiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
a = dicomread(fullFileName);
dcm_vlm(:,:,k)=a;
end
%% To view 3d volume
volshow(squeeze(dcm_vlm));