Skip to content

Commit

Permalink
Merge pull request #650 from piastammer/dev_varRBErobOpt
Browse files Browse the repository at this point in the history
minor bug fix and small documentation changes
  • Loading branch information
wahln authored Jul 21, 2023
2 parents ce9179d + 9cc05a8 commit e915ed6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 61 deletions.
2 changes: 1 addition & 1 deletion examples/matRad_example12_simpleParticleMonteCarlo.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

%% generate steering file
stf = matRad_generateStf(ct,cst,pln);
%stf = matRad_generateSingleBixelStf(ct,cst,pln); %Example to create a single beamlet stf
%stf = matRad_generateSingleBixelStf(ct,cst,pln); %Example to create a single beamlet stf, WARNING: this sometimes does not produce all required output files (TODO: check this)

%% analytical dose calculation
dij = matRad_calcParticleDose(ct, stf, pln, cst); %Calculate particle dose influence matrix (dij) with analytical algorithm
Expand Down
1 change: 1 addition & 0 deletions matRad_MCemittanceBaseData.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
else
obj.matRad_cfg.dispWarning('No information on BAMS to isocenter distance. Using generic value of 500mm');
obj.nozzleToIso = 500;
obj.machine.meta.BAMStoIsoDist = 500;
end

if all(isfield(machine.meta,{'SAD_x','SAD_y'}))
Expand Down
71 changes: 11 additions & 60 deletions topas/matRad_TopasConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,6 @@ function writeAllFiles(obj,ct,cst,pln,stf,machine,w)
% stf: matRad steering struct
% machine: machine to be used for calculation
% w: (optional) weights in case of calcDoseDirect
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2022 the matRad development team.
%
% This file is part of the matRad project. It is subject to the license
% terms in the LICENSE file found in the top-level directory of this
% distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
% of the matRad project, including this file, may be copied, modified,
% propagated, or distributed except according to the terms contained in the
% LICENSE file.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

matRad_cfg = MatRad_Config.instance(); %Instance of matRad configuration class

Expand Down Expand Up @@ -324,19 +311,7 @@ function writeAllFiles(obj,ct,cst,pln,stf,machine,w)
%
% output
% topasCube: struct with all read out subfields
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2022 the matRad development team.
%
% This file is part of the matRad project. It is subject to the license
% terms in the LICENSE file found in the top-level directory of this
% distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
% of the matRad project, including this file, may be copied, modified,
% propagated, or distributed except according to the terms contained in the
% LICENSE file.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Load in saved MC parameters
if isfile([folder filesep 'MCparam.mat'])
Expand Down Expand Up @@ -401,19 +376,6 @@ function writeAllFiles(obj,ct,cst,pln,stf,machine,w)
%
% EXAMPLE calls:
% topasCube = topasConfig.readExternal('pathToFolder')
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2022 the matRad development team.
%
% This file is part of the matRad project. It is subject to the license
% terms in the LICENSE file found in the top-level directory of this
% distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
% of the matRad project, including this file, may be copied, modified,
% propagated, or distributed except according to the terms contained in the
% LICENSE file.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% read in TOPAS files in dij
dij = obj.readFiles(folder);
Expand Down Expand Up @@ -452,19 +414,6 @@ function writeAllFiles(obj,ct,cst,pln,stf,machine,w)
%
% output
% topasCube: struct with all read out subfields
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2022 the matRad development team.
%
% This file is part of the matRad project. It is subject to the license
% terms in the LICENSE file found in the top-level directory of this
% distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
% of the matRad project, including this file, may be copied, modified,
% propagated, or distributed except according to the terms contained in the
% LICENSE file.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

matRad_cfg = MatRad_Config.instance(); %Instance of matRad configuration class

Expand Down Expand Up @@ -719,7 +668,7 @@ function writeAllFiles(obj,ct,cst,pln,stf,machine,w)
end

function dij = fillDij(obj,topasCubes,dij)

%TODO: Insert documentation
matRad_cfg = MatRad_Config.instance(); %Instance of matRad configuration class

% Load weights from parameter variable
Expand Down Expand Up @@ -862,7 +811,7 @@ function writeAllFiles(obj,ct,cst,pln,stf,machine,w)
end

function writeRunHeader(obj,fID,fieldIx,runIx,ctScen)

%TODO: Insert documentation
fprintf(fID,'s:Sim/PlanLabel = "%s"\n',obj.label);
if exist('ctScen','var')
fprintf(fID,'s:Sim/ScoreLabel = "score_%s_field%d_ct%d_run%d"\n',obj.label,fieldIx,ctScen,runIx);
Expand Down Expand Up @@ -897,13 +846,14 @@ function writeRunHeader(obj,fID,fieldIx,runIx,ctScen)
fprintf(fID,'\n');
fprintf(fID,['i:Ts/Seed = ',num2str(runIx),'\n']);

%TODO: remove or document
%fprintf(fID,'includeFile = %s/TOPAS_Simulation_Setup.txt\n',obj.thisFolder);
%fprintf(fID,'includeFile = %s/TOPAS_matRad_geometry.txt\n',obj.thisFolder);
%fprintf(fID,'includeFile = %s/TOPAS_scorer_surfaceIC.txt\n',obj.thisFolder);
end

function writeFieldHeader(obj,fID,ctScen)

%TODO: Insert documentation
matRad_cfg = MatRad_Config.instance(); %Instance of matRad configuration class

if ~strcmp(obj.beamProfile,'phasespace')
Expand Down Expand Up @@ -941,7 +891,7 @@ function writeFieldHeader(obj,fID,ctScen)
end

function writeScorers(obj,fID)

%TODO: Insert documentation
matRad_cfg = MatRad_Config.instance(); %Instance of matRad configuration class

obj.MCparam.outputType = obj.scorer.outputType;
Expand Down Expand Up @@ -1150,7 +1100,7 @@ function writeScorers(obj,fID)
end

function writeStfFields(obj,ct,stf,pln,w,baseData)

%TODO: Insert documentation
matRad_cfg = MatRad_Config.instance(); %Instance of matRad configuration class

isPhoton = false;
Expand Down Expand Up @@ -1776,7 +1726,7 @@ function writeStfFields(obj,ct,stf,pln,w,baseData)
obj.writeScorers(fileID);

% Write dij-related config lines
% We should discuss here if that's something that has to be available for photons as well
% TODO: move this to github issue/todo -> We should discuss here if that's something that has to be available for photons as well
if ~strcmp(obj.radiationMode,'photons')
if obj.scorer.calcDij
fprintf(fileID,'\n');
Expand Down Expand Up @@ -1992,7 +1942,7 @@ function writePatient(obj,ct,pln)
fprintf(fID,['iv:Ge/Patient/SchneiderHounsfieldUnitSections = %i',repmat(' %g',1,numel(densityCorrection.unitSections)),'\n'],numel(densityCorrection.unitSections),densityCorrection.unitSections);
fprintf(fID,['uv:Ge/Patient/SchneiderDensityOffset = %i',repmat(' %g',1,numel(densityCorrection.offset)),'\n'],numel(densityCorrection.offset),densityCorrection.offset);
% this is needed for a custom fprintf format which formats integers i to 'i.' and floats without trailing zeros
% this is potentially not necessary but was done to mimick the original TOPAS Schneider converter file
% TODO: check whether this can be removed -> this is potentially not necessary but was done to mimick the original TOPAS Schneider converter file
TOPASisFloat = mod(densityCorrection.factor,1)==0;
fprintf(fID,['uv:Ge/Patient/SchneiderDensityFactor = %i ',strjoin(cellstr(char('%1.01f '.*TOPASisFloat' + '%1.15g '.*~TOPASisFloat'))),'\n'],numel(densityCorrection.factor),densityCorrection.factor);
TOPASisFloat = mod(densityCorrection.factorOffset,1)==0;
Expand Down Expand Up @@ -2089,7 +2039,7 @@ function writePatient(obj,ct,pln)
end

function writeRangeShifter(~,fID,rangeShifter,sourceToNozzleDistance)

%TODO: Insert documentation
%Hardcoded PMMA range shifter for now
pmma_rsp = 1.165;
rsWidth = rangeShifter.eqThickness / pmma_rsp;
Expand All @@ -2107,6 +2057,7 @@ function writeRangeShifter(~,fID,rangeShifter,sourceToNozzleDistance)
end

function writeMCparam(obj)
%TODO: Insert documentation
%write MCparam file with basic parameters
MCparam = obj.MCparam;
save(fullfile(obj.workingDir,'MCparam.mat'),'MCparam','-v7');
Expand Down

0 comments on commit e915ed6

Please sign in to comment.