Skip to content

Commit 33c5b55

Browse files
committed
add photon dose calc test and adapt dose engine for tracking weights in bixel struct
1 parent ab401ce commit 33c5b55

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

matRad/doseCalc/+DoseEngines/matRad_PhotonPencilBeamSVDEngine.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ function setDefaults(this)
295295

296296
bixel = struct();
297297

298+
if this.calcDoseDirect
299+
bixel.weight = currRay.weight;
300+
end
301+
298302
if isfield(this.tmpMatrixContainers,'physicalDose')
299303
bixel.physicalDose = this.calcSingleBixel(currRay.SAD,...
300304
this.machine.data.m,...

test/doseCalc/test_SVDPB.m

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
function test_suite = test_SVDPB
2+
3+
test_functions=localfunctions();
4+
5+
initTestSuite;
6+
7+
function test_getSVDPBEngineFromPln
8+
% Single gaussian lateral model
9+
testData.pln = struct('radiationMode','photons','machine','Generic');
10+
testData.pln.propDoseCalc.engine = 'SVDPB';
11+
engine = DoseEngines.matRad_PhotonPencilBeamSVDEngine.getEngineFromPln(testData.pln);
12+
assertTrue(isa(engine,'DoseEngines.matRad_PhotonPencilBeamSVDEngine'));
13+
14+
function test_loadMachineForSVDPB
15+
possibleRadModes = DoseEngines.matRad_PhotonPencilBeamSVDEngine.possibleRadiationModes;
16+
for i = 1:numel(possibleRadModes)
17+
machine = DoseEngines.matRad_PhotonPencilBeamSVDEngine.loadMachine(possibleRadModes{i},'Generic');
18+
assertTrue(isstruct(machine));
19+
assertTrue(isfield(machine, 'meta'));
20+
assertTrue(isfield(machine.meta, 'radiationMode'));
21+
assertTrue(strcmp(machine.meta.radiationMode, possibleRadModes{i}));
22+
end
23+
24+
function test_calcDoseSVDPBphotons
25+
testData = load('photons_testData.mat');
26+
27+
assertTrue(DoseEngines.matRad_PhotonPencilBeamSVDEngine.isAvailable(testData.pln));
28+
29+
testData.pln.propDoseCalc.engine = 'SVDPB';
30+
testData.pln.propDoseCalc.dosimetricLateralCutOff = 0.995;
31+
testData.pln.propDoseCalc.geometricLateralCutOff = 50;
32+
testData.pln.propDoseCalc.kernelCutOff = Inf;
33+
resultGUI = matRad_calcDoseForward(testData.ct, testData.cst, testData.stf, testData.pln, ones(sum([testData.stf(:).totalNumOfBixels]),1));
34+
35+
assertTrue(isequal(fieldnames(resultGUI),fieldnames(testData.resultGUI)));
36+
assertTrue(isequal(testData.ct.cubeDim, size(resultGUI.physicalDose)));
37+
assertElementsAlmostEqual(resultGUI.physicalDose,testData.resultGUI.physicalDose,'relative',1e-2);
38+
39+
40+
function test_nonSupportedSettings
41+
% Radiation mode other than photons not implemented
42+
testData = load('protons_testData.mat');
43+
testData.pln.propDoseCalc.engine = 'SVDPB';
44+
assertFalse(DoseEngines.matRad_PhotonPencilBeamSVDEngine.isAvailable(testData.pln));
45+
46+
% Invalid machine without radiation mode field
47+
testData.pln.machine = 'Empty';
48+
testData.pln.propDoseCalc.engine = 'SVDPB';
49+
assertExceptionThrown(@() DoseEngines.matRad_PhotonPencilBeamSVDEngine.isAvailable(testData.pln));
50+
assertFalse(DoseEngines.matRad_PhotonPencilBeamSVDEngine.isAvailable(testData.pln,[]));
51+
52+
53+
54+

0 commit comments

Comments
 (0)