dicomrt_checkinput.m 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. function [moutput,type,label,PatientPositionCODE]=dicomrt_checkinput(minput,force)
  2. % dicomrt_checkinput(minput,force)
  3. %
  4. % Check the validity of the input variable.
  5. % Returns the input variable, type, label and patient orientation.
  6. %
  7. % minput is the input dataset
  8. % force is a parameter which force, if existing and different from 0, the function to check
  9. % for PatientPosition.
  10. %
  11. % See also: dicomrt_loaddose, dicomrt_loadct, dicomrt_loadmcdose
  12. %
  13. % Copyright (C) 2002 Emiliano Spezi (emiliano.spezi@physics.org)
  14. % Check number of argument
  15. error(nargchk(1,2,nargin))
  16. if nargin==1
  17. force=0;
  18. end
  19. if iscell(minput) == 1 & size(minput,1) == 3 % OK accepted input
  20. try
  21. header=minput{1,1}{1};
  22. catch
  23. header=minput{1,1};
  24. end
  25. modality=header.Modality;
  26. if isequal(modality,'CT') % CT data
  27. type='ct';
  28. label='CT units [Houns]';
  29. PatientPositionCODE=dicomrt_getPatientPosition(header);
  30. moutput=minput;
  31. elseif isequal(modality,'RTSTRUCT') % VOI data
  32. type='voi';
  33. label='VOI';
  34. PatientPositionCODE=-1; % N/A
  35. moutput=minput;
  36. elseif isequal(modality,'RTPLAN') % TPS or MC dose
  37. RTPLabel=header.RTPlanLabel;
  38. if strfind(RTPLabel,'-MCDOSE');
  39. % this is a MC DOSE
  40. if iscell(minput{2,1}) == 1 % this is a MC dose and contains segments contribution
  41. disp('Input variable is a MC dose containing segments contribution. Adding segment''s dose');
  42. totaldose=dicomrt_addmcdose(minput{2,1}); %add segments' contribution in a 3D minput
  43. moutput=minput;
  44. moutput{2,1}=totaldose;
  45. else
  46. moutput=minput;
  47. end
  48. type='mc';
  49. label='MC dose map [Gy]';
  50. PatientPositionCODE=dicomrt_getPatientPosition(header);
  51. elseif strfind(RTPLabel,'-DDIFF');
  52. % this is a dose difference
  53. moutput=minput;
  54. type='ddiff';
  55. label='Dose difference';
  56. PatientPositionCODE=dicomrt_getPatientPosition(header);
  57. elseif strfind(RTPLabel,'-DRATIO');
  58. % this is a dose ratio
  59. moutput=minput;
  60. type='dratio';
  61. label='Dose ratio';
  62. PatientPositionCODE=dicomrt_getPatientPosition(header);
  63. else
  64. % this is a TPS DOSE
  65. moutput=minput;
  66. type='RTPLAN';
  67. label='RTPLAN dose map [Gy]';
  68. PatientPositionCODE=dicomrt_getPatientPosition(header);
  69. end
  70. end
  71. elseif isnumeric(minput)==1 % this is a simple 3D matrix
  72. moutput=minput;
  73. type='other';
  74. label=[inputname(1),' matrix'];
  75. if force==0
  76. warning('dicomrt_checkinput: The input variable is a 3D matrix. Unable to determine Patient Position.');
  77. PatientPosition=input('dicomrt_checkinput: Please specify Patient Position: HFS(default),FFS,HFP,FFP: ','s');
  78. if isempty(PatientPosition)==1
  79. PatientPosition='HFS';
  80. end
  81. if strcmpi(PatientPosition, 'HFS')
  82. PatientPositionCODE = 1;
  83. elseif strcmpi(PatientPosition, 'FFS')
  84. PatientPositionCODE = 2;
  85. elseif strcmpi(PatientPosition, 'HFP')
  86. PatientPositionCODE = 3;
  87. elseif strcmpi(PatientPosition, 'FFP')
  88. PatientPositionCODE = 4;
  89. end
  90. end
  91. else
  92. error('dicomrt_checkinput: Input matrix does not have a supported format. Exit now !');
  93. end