Skip to content

Commit

Permalink
small update to example script and standard setting for lateral model…
Browse files Browse the repository at this point in the history
… in dose calculation
  • Loading branch information
wahln committed Oct 15, 2024
1 parent cab5ce9 commit e969edb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
9 changes: 4 additions & 5 deletions examples/matRad_example12_simpleParticleMonteCarlo.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

% meta information for treatment plan
pln.radiationMode = 'protons'; % either photons / protons / carbon
%pln.machine = 'generic_TOPAS_cropped';
pln.machine = 'generic_MCsquare';
pln.machine = 'Generic';


pln.numOfFractions = 1;
Expand Down Expand Up @@ -78,8 +77,8 @@
stf = matRad_generateStf(ct,cst,pln);

%% analytical dose calculation
pln.propDoseCalc.engine = 'MCsquare';
pln.propDoseCalc.numHistoriesPerBeamlet = 1e4;
pln.propDoseCalc.engine = 'HongPB';
%pln.propDoseCalc.numHistoriesPerBeamlet = 1e6;

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

Expand All @@ -93,7 +92,7 @@
%pln.propDoseCalc.engine = 'TOPAS';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
calcLET = true; % Boolean which defines if LET should be calculated
calcBioDose = false; % Boolean which defines if biological dose calculation shoudl be performed (alpha*dose and sqrt(beta)*dose)
airOffsetCorrection = true; % Corrects WEPL for SSD difference to kernel database
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
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

visBoolLateralCutOff = false; % Boolean switch for visualization during+ LeteralCutOff calculation
end
Expand Down Expand Up @@ -65,23 +65,29 @@ function chooseLateralModel(this)

matRad_cfg = MatRad_Config.instance();

singleAvailable = all(arrayfun(fValidateSingle,this.machine.data));
doubleAvailable = all(arrayfun(fValidateDouble,this.machine.data));
multiAvailable = all(arrayfun(fValidateMulti,this.machine.data));

matRad_cfg.dispInfo('''%s'' selected for lateral beam model, checking machine...\n',this.lateralModel);

switch this.lateralModel
case 'single'
if ~all(arrayfun(fValidateSingle,this.machine.data))
if ~singleAvailable
matRad_cfg.dispWarning('Chosen Machine does not support a singleGaussian Pencil-Beam model!');
this.lateralModel = 'auto';
end
case 'double'
if ~all(arrayfun(fValidateDouble,this.machine.data))
if ~doubleAvailable
matRad_cfg.dispWarning('Chosen Machine does not support a doubleGaussian Pencil-Beam model!');
this.lateralModel = 'auto';
end
case 'multi'
if ~all(arrayfun(fValidateMulti,this.machine.data))
if ~multiAvailable
matRad_cfg.dispWarning('Chosen Machine does not support a multiGaussian Pencil-Beam model!');
this.lateralModel = 'auto';
end
case 'auto'
case {'auto','fast'}
%Do nothing, will be handled below
otherwise
matRad_cfg.dispError('Lateral model ''%s'' not known!',this.lateralModel);
Expand All @@ -90,12 +96,24 @@ function chooseLateralModel(this)
%Now check if we need tho chose the lateral model because it
%was set to auto
if strcmp(this.lateralModel,'auto')
if all(arrayfun(fValidateMulti,this.machine.data))
if multiAvailable
this.lateralModel = 'multi';
elseif all(arrayfun(fValidateDouble,this.machine.data))
elseif doubleAvailable
this.lateralModel = 'double';
elseif all(arrayfun(fValidateSingle,this.machine.data))
elseif singleAvailable
this.lateralModel = 'single';
else
matRad_cfg.dispError('Invalid kernel model!');
end
end

if strcmp(this.lateralModel,'fast')
if singleAvailable
this.lateralModel = 'single';
elseif doubleAvailable
this.lateralModel = 'double';
elseif multiAvailable
this.lateralModel = 'multi';
else
matRad_cfg.dispError('Invalid kernel model!');
end
Expand Down

0 comments on commit e969edb

Please sign in to comment.