nrrd2ROI.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. function Geometry=nrrd2ROI(Geometry, patient_dir)
  2. %% -----===== Get ROI mask =====-----
  3. while true
  4. newRoi = questdlg('Do you want to load another ROI?','New ROI','Yes','No','No');
  5. switch newRoi
  6. case 'Yes'
  7. [ROI_in, ROI_path, filterIdx] = uigetfile([{'*.nrrd'; '*.am'}], 'Select ROI image', Geometry.data_dir);
  8. switch filterIdx
  9. case 0
  10. warning('No file selected, aborting!')
  11. return
  12. case 1
  13. [ROI_img, meta]=nrrdread([ROI_path, ROI_in]);
  14. disp('NRRD file loaded!')
  15. case 2
  16. ROI_img = am2mat([ROI_path, ROI_in]);
  17. ROI_img = permute(ROI_img.data, [2,1,3]);
  18. disp('AM file loaded!')
  19. case 3
  20. error('please do not select *all* in file selection')
  21. otherwise
  22. error('You should never see this.')
  23. end
  24. WiscPlan_preferences.patientDataPath = Geometry.patient_dir;
  25. save(which('WiscPlan_preferences.mat'), 'WiscPlan_preferences');
  26. Geometry.ROIS{end+1}.ind = find(ROI_img>0);
  27. str = inputdlg('Enter ROI name:')
  28. Geometry.ROIS{end}.name= str{1};
  29. save(fullfile(Geometry.patient_dir, 'matlab_files', 'Geometry.mat'), 'Geometry');
  30. case 'No'
  31. break
  32. end
  33. end
  34. end