|
74 | 74 | rmdir(folderName,'s'); %clean up |
75 | 75 | end |
76 | 76 |
|
| 77 | + |
| 78 | +function test_TopasMCdoseCalcBasicRBE |
| 79 | +% test if all the necessary output files are written vor a couple of cases. |
| 80 | +% i am not using the default number of histories for testing her, insted 1e6. |
| 81 | +% Because the files are just writen and not simulated so we dont care about simulation time. |
| 82 | +% To few histories may result in wierd behavior in the topas interface, i.e if a beam |
| 83 | +% recieves no histories because there are not enough to be distributed accros the spots, |
| 84 | +% it causes an error |
| 85 | +radModes = DoseEngines.matRad_TopasMCEngine.possibleRadiationModes; |
| 86 | +matRad_cfg = MatRad_Config.instance(); |
| 87 | + |
| 88 | +if moxunit_util_platform_is_octave |
| 89 | + confirm_recursive_rmdir(false,'local'); |
| 90 | +end |
| 91 | + |
| 92 | +for i = 2:numel(radModes) |
| 93 | + switch radModes{i} |
| 94 | + case 'protons' |
| 95 | + RBEmodel = {'mcn', 'wed'}; |
| 96 | + case {'helium', 'carbon'} |
| 97 | + RBEmodel ={'libamtrack','lem'}; |
| 98 | + end |
| 99 | + matRad_cfg = MatRad_Config.instance(); |
| 100 | + load([radModes{i} '_testData.mat']); |
| 101 | + |
| 102 | + pln.propDoseCalc.engine = 'TOPAS'; |
| 103 | + pln.propDoseCalc.externalCalculation = 'write'; |
| 104 | + pln.propDoseCalc.numHistoriesDirect = 1e6; |
| 105 | + pln.propDoseCalc.scorer.RBE = true; |
| 106 | + pln.propDoseCalc.scorer.RBE_model = RBEmodel; |
| 107 | + pln.bioModel = matRad_bioModel(radModes{i},'none'); |
| 108 | + resultGUI = matRad_calcDoseForward(ct,cst,stf,pln, ones(1,sum([stf(:).totalNumOfBixels]))); |
| 109 | + |
| 110 | + folderName = [matRad_cfg.primaryUserFolder filesep 'TOPAS' filesep]; |
| 111 | + folderName = [folderName stf(1).radiationMode,'_',stf(1).machine,'_',datestr(now, 'dd-mm-yy')]; |
| 112 | + %check of outputfolder exists |
| 113 | + assertTrue(isfolder(folderName)); |
| 114 | + %check if file in folder existi |
| 115 | + assertTrue(isfile([folderName filesep 'matRad_cube.dat'])); |
| 116 | + assertTrue(isfile([folderName filesep 'matRad_cube.txt'])); |
| 117 | + assertTrue(isfile([folderName filesep 'MCparam.mat'])); |
| 118 | + for j = 1:pln.propStf.numOfBeams |
| 119 | + assertTrue(isfile([folderName filesep 'beamSetup_matRad_plan_field' num2str(j) '.txt'])); |
| 120 | + assertTrue(isfile([folderName filesep 'matRad_plan_field' num2str(j) '_run1.txt'])); |
| 121 | + end |
| 122 | + rmdir(folderName,'s'); %clean up |
| 123 | +end |
| 124 | + |
77 | 125 | function test_TopasMCdoseCalcMultRuns |
78 | 126 | numOfRuns = 5; |
79 | 127 | radModes = DoseEngines.matRad_TopasMCEngine.possibleRadiationModes; |
|
138 | 186 | confirm_recursive_rmdir(false,'local'); |
139 | 187 | end |
140 | 188 |
|
| 189 | +% physical Dose |
| 190 | +for i = 1:numel(radModes) |
| 191 | + if ~strcmp(radModes{i},'photons') |
| 192 | + load([radModes{i} '_testData.mat']); |
| 193 | + [ct,cst] = matRad_addMovement(ct, cst,5, numOfPhases,[0 3 0],'dvfType','pull'); |
| 194 | + pln.bioModel = matRad_bioModel(radModes{i},'none'); |
| 195 | + resultGUI.w = ones(1,sum([stf(:).totalNumOfBixels]))'; |
| 196 | + timeSequence = matRad_makeBixelTimeSeq(stf, resultGUI); |
| 197 | + timeSequence = matRad_makePhaseMatrix(timeSequence, ct.numOfCtScen, ct.motionPeriod, 'linear'); |
| 198 | + pln.propDoseCalc.engine = 'TOPAS'; |
| 199 | + pln.propDoseCalc.externalCalculation = 'write'; |
| 200 | + pln.propDoseCalc.calc4DInterplay = true; |
| 201 | + pln.propDoseCalc.calcTimeSequence = timeSequence; |
| 202 | + pln.propDoseCalc.numHistoriesDirect = 1e6; |
| 203 | + resultGUI = matRad_calcDoseForward(ct,cst,stf,pln, resultGUI.w); |
| 204 | + |
| 205 | + folderName = [matRad_cfg.primaryUserFolder filesep 'TOPAS' filesep]; |
| 206 | + folderName = [folderName stf(1).radiationMode,'_',stf(1).machine,'_',datestr(now, 'dd-mm-yy')]; |
| 207 | + %check of outputfolder exists |
| 208 | + assertTrue(isfolder(folderName)); |
| 209 | + %check if file in folder existi |
| 210 | + assertTrue(isfile([folderName filesep 'MCparam.mat'])); |
| 211 | + for j = 1:pln.propStf.numOfBeams |
| 212 | + assertTrue(isfile([folderName filesep 'beamSetup_matRad_plan_field' num2str(j) '.txt'])); |
| 213 | + assertTrue(isfile([folderName filesep 'matRad_plan_field' num2str(j) '_run1.txt'])); |
| 214 | + assertTrue(isfile([folderName filesep 'matRad_cube_field' num2str(j) '.txt'])); |
| 215 | + for k = 1:numOfPhases |
| 216 | + assertTrue(isfile([folderName filesep 'matRad_cube' num2str(k) '.dat'])); |
| 217 | + end |
| 218 | + end |
| 219 | + rmdir(folderName,'s'); %clean up |
| 220 | + end |
| 221 | +end |
| 222 | +%RBExDose |
141 | 223 | for i = 1:numel(radModes) |
| 224 | + switch radModes{i} |
| 225 | + case 'protons' |
| 226 | + RBEmodel = {'mcn', 'wed'}; |
| 227 | + case {'helium', 'carbon'} |
| 228 | + RBEmodel ={'libamtrack','lem'}; |
| 229 | + end |
142 | 230 | if ~strcmp(radModes{i},'photons') |
143 | 231 | load([radModes{i} '_testData.mat']); |
144 | 232 | [ct,cst] = matRad_addMovement(ct, cst,5, numOfPhases,[0 3 0],'dvfType','pull'); |
|
151 | 239 | pln.propDoseCalc.calc4DInterplay = true; |
152 | 240 | pln.propDoseCalc.calcTimeSequence = timeSequence; |
153 | 241 | pln.propDoseCalc.numHistoriesDirect = 1e6; |
| 242 | + pln.propDoseCalc.scorer.RBE = true; |
| 243 | + pln.propDoseCalc.scorer.RBE_model = RBEmodel; |
154 | 244 | resultGUI = matRad_calcDoseForward(ct,cst,stf,pln, resultGUI.w); |
155 | 245 |
|
156 | 246 | folderName = [matRad_cfg.primaryUserFolder filesep 'TOPAS' filesep]; |
|
0 commit comments