|
| 1 | +function test_suite = test_Analytical |
| 2 | + |
| 3 | +test_functions=localfunctions(); |
| 4 | + |
| 5 | +initTestSuite; |
| 6 | + |
| 7 | +function test_getAnalyticalEngineFromPln |
| 8 | + % Single gaussian lateral model |
| 9 | + protonDummyPln = struct('radiationMode','protons','machine','Generic'); |
| 10 | + protonDummyPln.propDoseCalc.engine = 'AnalyticalPB'; |
| 11 | + engine = DoseEngines.matRad_ParticleAnalyticalBortfeldEngine.getEngineFromPln(protonDummyPln); |
| 12 | + assertTrue(isa(engine,'DoseEngines.matRad_ParticleAnalyticalBortfeldEngine')); |
| 13 | + |
| 14 | + % Double Gaussian lateral model |
| 15 | + % If you don't have my clusterDose basedata you cannot try this :P |
| 16 | + %{ |
| 17 | + protonDummyPln = struct('radiationMode','protons','machine','Generic_clusterDose'); |
| 18 | + protonDummyPln.propDoseCalc.engine = 'AnalyticalPB'; |
| 19 | + engine = DoseEngines.matRad_ParticleAnalyticalBortfeldEngine.getEngineFromPln(protonDummyPln); |
| 20 | + assertTrue(isa(engine,'DoseEngines.matRad_ParticleAnalyticalBortfeldEngine')); |
| 21 | + %} |
| 22 | + |
| 23 | +function test_loadMachineForAnalytical |
| 24 | + possibleRadModes = DoseEngines.matRad_ParticleAnalyticalBortfeldEngine.possibleRadiationModes; |
| 25 | + for i = 1:numel(possibleRadModes) |
| 26 | + machine = DoseEngines.matRad_ParticleAnalyticalBortfeldEngine.loadMachine(possibleRadModes{i},'Generic'); |
| 27 | + assertTrue(isstruct(machine)); |
| 28 | + assertTrue(isfield(machine, 'meta')); |
| 29 | + assertTrue(isfield(machine.meta, 'radiationMode')); |
| 30 | + assertTrue(strcmp(machine.meta.radiationMode, 'protons')); |
| 31 | + end |
| 32 | + |
| 33 | +function test_calcDoseAnalytical |
| 34 | + matRad_cfg = MatRad_Config.instance(); |
| 35 | + |
| 36 | + protonDummyPln = struct('radiationMode','protons','machine','Generic'); |
| 37 | + protonDummyPln.propDoseCalc.engine = 'AnalyticalPB'; |
| 38 | + |
| 39 | + load([protonDummyPln.radiationMode '_' protonDummyPln.machine]); |
| 40 | + |
| 41 | + load BOXPHANTOM.mat |
| 42 | + |
| 43 | + stf = matRad_generateStf(ct, cst, protonDummyPln); |
| 44 | + |
| 45 | + resultGUI = matRad_calcDoseForward(ct, cst, stf, protonDummyPln, ones([1, stf(:).totalNumOfBixels])); |
| 46 | + |
| 47 | + assertTrue(isfield(resultGUI, 'physicalDose')); |
| 48 | + assertTrue(isfield(resultGUI, 'w')); |
| 49 | + assertTrue(isequal(size(ct.cube{1}), size(resultGUI.physicalDose))) |
| 50 | + |
| 51 | +function test_nonSupportedSettings |
| 52 | + % Radiation mode other than protons not implemented |
| 53 | + carbonDummyPln = struct('radiationMode','carbon','machine','Generic'); |
| 54 | + carbonDummyPln.propDoseCalc.engine = 'AnalyticalPB'; |
| 55 | + engine = DoseEngines.matRad_ParticleAnalyticalBortfeldEngine.getEngineFromPln(carbonDummyPln); |
| 56 | + assertTrue(~isa(engine,'DoseEngines.matRad_ParticleAnalyticalBortfeldEngine')); |
| 57 | + |
| 58 | + % Biological models, LET, other lateral models not implemented |
| 59 | + protonDummyPln = struct('radiationMode','protons','machine','Generic'); |
| 60 | + protonDummyPln.propDoseCalc.engine = 'AnalyticalPB'; |
| 61 | + protonDummyPln.propDoseCalc.calcLET = true; |
| 62 | + protonDummyPln.propDoseCalc.calcBioDose = true; |
| 63 | + protonDummyPln.propDoseCalc.lateralModel = 'double'; |
| 64 | + engine = DoseEngines.matRad_ParticleAnalyticalBortfeldEngine.getEngineFromPln(protonDummyPln); |
| 65 | + assertTrue(isa(engine,'DoseEngines.matRad_ParticleAnalyticalBortfeldEngine')); |
| 66 | + load BOXPHANTOM.mat |
| 67 | + stf = matRad_generateStf(ct, cst, protonDummyPln); |
| 68 | + resultGUI = matRad_calcDoseForward(ct, cst, stf, protonDummyPln, ones([1, stf(:).totalNumOfBixels])); |
| 69 | + assertTrue(~engine.calcLET) |
| 70 | + %assertTrue(~engine.calcBioDose) % Access protected property |
| 71 | + |
| 72 | + % Invalid machine without radiation mode field |
| 73 | + matRad_cfg = MatRad_Config.instance(); |
| 74 | + protonDummyPln = struct('radiationMode','protons','machine','Empty'); |
| 75 | + protonDummyPln.propDoseCalc.engine = 'AnalyticalPB'; |
| 76 | + machine = []; |
| 77 | + assertExceptionThrown(@() DoseEngines.matRad_ParticleAnalyticalBortfeldEngine.isAvailable(protonDummyPln, machine)); |
| 78 | + |
| 79 | + |
| 80 | + |
0 commit comments