function Geometry=nrrd2ROI(Geometry, patient_dir) %% -----===== Get ROI mask =====----- while true newRoi = questdlg('Do you want to load another ROI?','New ROI','Yes','No','No'); switch newRoi case 'Yes' [ROI_in, ROI_path, filterIdx] = uigetfile([{'*.nrrd'; '*.am'}], 'Select ROI image', Geometry.data_dir); switch filterIdx case 0 warning('No file selected, aborting!') return case 1 [ROI_img, meta]=nrrdread([ROI_path, ROI_in]); disp('NRRD file loaded!') case 2 ROI_img = am2mat([ROI_path, ROI_in]); ROI_img = permute(ROI_img.data, [2,1,3]); disp('AM file loaded!') case 3 error('please do not select *all* in file selection') otherwise error('You should never see this.') end WiscPlan_preferences.patientDataPath = Geometry.patient_dir; save(which('WiscPlan_preferences.mat'), 'WiscPlan_preferences'); Geometry.ROIS{end+1}.ind = find(ROI_img>0); str = inputdlg('Enter ROI name:') Geometry.ROIS{end}.name= str{1}; save(fullfile(Geometry.patient_dir, 'matlab_files', 'Geometry.mat'), 'Geometry'); case 'No' break end end end