% read the whole files
patient_paths='patient_paths';
patient_names=dir(patient_paths);
for ii=3:length(patient_names) % start from 3
patient_name=patient_names(ii).name;
patient_path=fullfile(patient_paths,patient_name);
% read the files end with '.nii'
patient_paths='patient_paths';
patient_names=dir([patient_paths, '/*.nii']);
for ii=1:length(patient_names) % start from 1
patient_name=patient_names(ii).name;
patient_path=fullfile(patient_paths,patient_name);