Skip to content

Commit 8c421da

Browse files
committed
Merge branch 'pr/765' into pr/756
# Conflicts: # examples/matRad_example12_simpleParticleMonteCarlo.m
2 parents 842027e + b3251bd commit 8c421da

14 files changed

+86
-30
lines changed

examples/matRad_example12_simpleParticleMonteCarlo.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
% meta information for treatment plan
2525
pln.radiationMode = 'protons'; % either photons / protons / carbon
2626
pln.machine = 'Generic';
27+
2728
%Biology
2829
pln.bioModel = 'none';
2930
%Scenario Model
@@ -69,8 +70,8 @@
6970
stf = matRad_generateStf(ct,cst,pln);
7071

7172
%% analytical dose calculation
72-
pln.propDoseCalc.engine = 'MCsquare';
73-
pln.propDoseCalc.numHistoriesPerBeamlet = 1e4;
73+
pln.propDoseCalc.engine = 'HongPB';
74+
%pln.propDoseCalc.numHistoriesPerBeamlet = 1e6;
7475

7576
dij = matRad_calcDoseInfluence(ct, cst,stf, pln); %Calculate particle dose influence matrix (dij) with analytical algorithm
7677

@@ -84,7 +85,7 @@
8485
%pln.propDoseCalc.engine = 'TOPAS';
8586

8687
% set number of histories lower than default for this example (default: 1e8)
87-
pln.propDoseCalc.numHistoriesDirect = 1e3;
88+
pln.propDoseCalc.numHistoriesDirect = 5e6;
8889
%pln.propDoseCalc.externalCalculation = 'write';
8990
resultGUI_MC = matRad_calcDoseForward(ct,cst,stf,pln,resultGUI.w);
9091

examples/matRad_example13_fitAnalyticalParticleBaseData.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,18 @@
109109
pln.radiationMode = 'protons';
110110

111111
% create meta machine data
112-
machine.meta.machine = 'example'; %name of the machine
112+
machine.meta.name = 'example'; %name of the machine
113113
machine.meta.radiationMode = 'protons'; %modality
114114
machine.meta.dataType = 'singleGauss'; %singleGauss or doubleGauss
115115
machine.meta.created_on = date;
116116
machine.meta.created_by = 'matRad_example';
117117
machine.meta.SAD = (2218 + 1839) / 2; %This is the (virtual) source to axis distance
118118
machine.meta.BAMStoIsoDist = 420.0; %distance from beam nozzle ot isocenter
119-
machine.meta.LUT_bxWidthminFWHM = [0, Inf; 5 ,5]; %Specifies which minimum FWHM to use as spot sice for which ranges of lateral spot distance (here, each spot distance of 0 to to Inf gets at least 5mm wide spots
119+
machine.meta.LUTspotSize = [0, Inf; 5 ,5]; %Specifies which minimum FWHM to use as spot sice for which ranges of lateral spot distance (here, each spot distance of 0 to to Inf gets at least 5mm wide spots
120120
machine.meta.fitAirOffset = 420.0; %Tells matRad how much "air" was considered during fitting. Set this to 0 if the fit is obtained in vacuum and no air transport is simulated up to the phantom. matRad assumes that the phantom starts at the isocenter.
121121

122122
% Now add the example machine to the pln and then save it
123-
pln.machine = machine.meta.machine;
123+
pln.machine = machine.meta.name;
124124
pln.radiationMode = machine.meta.radiationMode;
125125
fileName = [pln.radiationMode '_' pln.machine];
126126
filePath = fullfile(matRad_cfg.userfolders{1},'machines',[fileName '.mat']);
632 KB
Binary file not shown.
579 KB
Binary file not shown.

matRad/doseCalc/+DoseEngines/matRad_ParticleAnalyticalBortfeldEngine.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ function calcLateralParticleCutOff(this,cutOffLevel,~)
372372
return;
373373
end
374374

375-
checkMeta = all(isfield(machine.meta,{'SAD','BAMStoIsoDist','LUT_bxWidthminFWHM','dataType'}));
375+
checkMeta = all(isfield(machine.meta,{'SAD','BAMStoIsoDist','dataType'}));
376+
377+
%Superseded names from older machine file versions
378+
checkMeta = checkMeta && any(isfield(machine.meta,{'LUTspotSize','LUT_bxWidthminFWHM'}));
376379

377380
dataType = machine.meta.dataType;
378381
if strcmp(dataType,'singleGauss')

matRad/doseCalc/+DoseEngines/matRad_ParticleFineSamplingPencilBeamEngine.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,10 @@ function setDefaults(this)
469469
return;
470470
end
471471

472-
checkMeta = all(isfield(machine.meta,{'SAD','BAMStoIsoDist','LUT_bxWidthminFWHM','dataType'}));
472+
checkMeta = all(isfield(machine.meta,{'SAD','BAMStoIsoDist','dataType'}));
473+
474+
%Superseded names from older machine file versions
475+
checkMeta = checkMeta && any(isfield(machine.meta,{'LUTspotSize','LUT_bxWidthminFWHM'}));
473476

474477
dataType = machine.meta.dataType;
475478
if strcmp(dataType,'singleGauss')

matRad/doseCalc/+DoseEngines/matRad_ParticleHongPencilBeamEngine.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@
131131
return;
132132
end
133133

134-
checkMeta = all(isfield(machine.meta,{'SAD','BAMStoIsoDist','LUT_bxWidthminFWHM','dataType'}));
134+
checkMeta = all(isfield(machine.meta,{'SAD','BAMStoIsoDist','dataType'}));
135+
136+
%Superseded names from older machine file versions
137+
checkMeta = checkMeta && any(isfield(machine.meta,{'LUTspotSize','LUT_bxWidthminFWHM'}));
135138

136139
dataType = machine.meta.dataType;
137140
if strcmp(dataType,'singleGauss')

matRad/doseCalc/+DoseEngines/matRad_ParticleMCsquareEngine.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,14 @@ function setDefaults(this)
150150
bdFile = this.forceBDL;
151151

152152
else
153+
% Newer machine files have "name" instead of "machine"
154+
if ~isfield(this.machine.meta,'machine')
155+
machineName = this.machine.meta.name;
156+
else
157+
machineName = this.machine.meta.machine;
158+
end
153159
% fit and create BDL file using selected machine file
154-
bdFile = [this.machine.meta.machine '.txt'];
160+
bdFile = [machineName '.txt'];
155161

156162
% Calculate MCsquare base data
157163
% Argument stf is optional, if given, calculation only for energies given in stf

matRad/doseCalc/+DoseEngines/matRad_ParticlePencilBeamEngineAbstract.m

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
calcLET = true; % Boolean which defines if LET should be calculated
2525
calcBioDose = false; % Boolean which defines if biological dose calculation shoudl be performed (alpha*dose and sqrt(beta)*dose)
2626
airOffsetCorrection = true; % Corrects WEPL for SSD difference to kernel database
27-
lateralModel = 'auto'; % Lateral Model used. 'auto' uses the most accurate model available (i.e. multiple Gaussians). 'single','double','multi' try to force a singleGaussian or doubleGaussian model, if available
27+
lateralModel = 'fast'; % Lateral Model used. 'auto' uses the most accurate model available (i.e. multiple Gaussians), 'fastest' uses the most simple model. 'single','double','multi' try to force a singleGaussian or doubleGaussian model, if available
2828

2929
cutOffMethod = 'integral'; % or 'relative' - describes how to calculate the lateral dosimetric cutoff
3030

@@ -69,23 +69,29 @@ function chooseLateralModel(this)
6969

7070
matRad_cfg = MatRad_Config.instance();
7171

72+
singleAvailable = all(arrayfun(fValidateSingle,this.machine.data));
73+
doubleAvailable = all(arrayfun(fValidateDouble,this.machine.data));
74+
multiAvailable = all(arrayfun(fValidateMulti,this.machine.data));
75+
76+
matRad_cfg.dispInfo('''%s'' selected for lateral beam model, checking machine...\n',this.lateralModel);
77+
7278
switch this.lateralModel
7379
case 'single'
74-
if ~all(arrayfun(fValidateSingle,this.machine.data))
80+
if ~singleAvailable
7581
matRad_cfg.dispWarning('Chosen Machine does not support a singleGaussian Pencil-Beam model!');
7682
this.lateralModel = 'auto';
7783
end
7884
case 'double'
79-
if ~all(arrayfun(fValidateDouble,this.machine.data))
85+
if ~doubleAvailable
8086
matRad_cfg.dispWarning('Chosen Machine does not support a doubleGaussian Pencil-Beam model!');
8187
this.lateralModel = 'auto';
8288
end
8389
case 'multi'
84-
if ~all(arrayfun(fValidateMulti,this.machine.data))
90+
if ~multiAvailable
8591
matRad_cfg.dispWarning('Chosen Machine does not support a multiGaussian Pencil-Beam model!');
8692
this.lateralModel = 'auto';
8793
end
88-
case 'auto'
94+
case {'auto','fast'}
8995
%Do nothing, will be handled below
9096
otherwise
9197
matRad_cfg.dispError('Lateral model ''%s'' not known!',this.lateralModel);
@@ -94,12 +100,24 @@ function chooseLateralModel(this)
94100
%Now check if we need tho chose the lateral model because it
95101
%was set to auto
96102
if strcmp(this.lateralModel,'auto')
97-
if all(arrayfun(fValidateMulti,this.machine.data))
103+
if multiAvailable
98104
this.lateralModel = 'multi';
99-
elseif all(arrayfun(fValidateDouble,this.machine.data))
105+
elseif doubleAvailable
100106
this.lateralModel = 'double';
101-
elseif all(arrayfun(fValidateSingle,this.machine.data))
107+
elseif singleAvailable
108+
this.lateralModel = 'single';
109+
else
110+
matRad_cfg.dispError('Invalid kernel model!');
111+
end
112+
end
113+
114+
if strcmp(this.lateralModel,'fast')
115+
if singleAvailable
102116
this.lateralModel = 'single';
117+
elseif doubleAvailable
118+
this.lateralModel = 'double';
119+
elseif multiAvailable
120+
this.lateralModel = 'multi';
103121
else
104122
matRad_cfg.dispError('Invalid kernel model!');
105123
end
@@ -566,7 +584,7 @@ function calcLateralParticleCutOff(this,cutOffLevel,stfElement)
566584
sigmaIni_sq = sigmaIni^2;
567585

568586
% consider range shifter for protons if applicable
569-
if strcmp(this.machine.meta.radiationMode,'protons') && rangeShifterLUT(i).eqThickness > 0 && ~strcmp(this.machine.meta.machine,'Generic')
587+
if strcmp(this.machine.meta.radiationMode,'protons') && rangeShifterLUT(i).eqThickness > 0
570588

571589
%get max range shift
572590
sigmaRashi = matRad_calcSigmaRashi(this.machine.data(energyIx).energy, ...

matRad/doseCalc/MCsquare/matRad_MCsquareBaseData.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
fileID = fopen(filepath,'w');
4848

4949
%Header
50-
%fprintf(fileID,'--matRad: Beam Model for machine %s (%s)--\n',machine.meta.machine,machine.meta.dataType);
5150
fprintf(fileID,'--UPenn beam model (double gaussian)--\n');
5251
fprintf(fileID,'# %s\n', obj.machine.meta.description);
5352
fprintf(fileID,'# created by %s on %s\n\n', obj.machine.meta.created_by, obj.machine.meta.created_on);

0 commit comments

Comments
 (0)