Skip to content

Commit

Permalink
small update to photons phasespace
Browse files Browse the repository at this point in the history
- set phasespace file as changable in config to maybe be implemented as a variable.
- check is performed to see if phaseSpaceFile is available
- Info is output if externalCalculation is turned on (manually place phaseSpace file)
  • Loading branch information
HomolkaN committed Oct 26, 2022
1 parent 0c2094d commit 0af8238
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
33 changes: 25 additions & 8 deletions topas/MatRad_TopasConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@

useOrigBaseData = false; % base data of the original matRad plan will be used?
beamProfile = 'biGaussian'; %'biGaussian' (emittance); 'simple'

useEnergySpectrum = false;

%Not yet implemented
%beamletMode = false; %In beamlet mode simulation will be performed for a dose influence matrix (i.e., each beamlet simulates numHistories beamlets)

pencilBeamScanning = true; %This should be always true (enables deflection)
pencilBeamScanning = true; %This should be always true except when using photons (enables deflection)

%Image
materialConverter = struct('mode','HUToWaterSchneider',... %'RSP','HUToWaterSchneider';
Expand Down Expand Up @@ -1180,25 +1181,31 @@ function writeStfFields(obj,ct,stf,pln,w,baseData)
fname = fullfile(obj.thisFolder,obj.infilenames.beam_biGaussian);
TOPAS_beamSetup = fileread(fname);
matRad_cfg.dispInfo('Reading ''%s'' Beam Characteristics from ''%s''\n',obj.beamProfile,fname);

case 'simple'
fname = fullfile(obj.thisFolder,obj.infilenames.beam_generic);
TOPAS_beamSetup = fileread(fname);
matRad_cfg.dispInfo('Reading ''%s'' Beam Characteristics from ''%s''\n',obj.beamProfile,fname);

case 'phasespace'
fname = fullfile(obj.thisFolder,obj.infilenames.beam_phasespace);
TOPAS_beamSetup = fileread(fname);
obj.pencilBeamScanning = 0 ;
matRad_cfg.dispInfo('Reading ''%s'' Beam Characteristics from ''%s''\n',obj.beamProfile,fname);
matRad_cfg.dispInfo('Reading ''%s'' Beam Characteristics from ''%s''\n',obj.beamProfile,fname);

case 'virtualGaussian'
fname = fullfile(obj.thisFolder,obj.infilenames.beam_virtualGaussian);
TOPAS_beamSetup = fileread(fname);
matRad_cfg.dispInfo('Reading ''%s'' Beam Characteristics from ''%s''\n',obj.beamProfile,fname)
matRad_cfg.dispInfo('Reading ''%s'' Beam Characteristics from ''%s''\n',obj.beamProfile,fname);

case 'uniform'
fname = fullfile(obj.thisFolder,obj.infilenames.beam_uniform);
TOPAS_beamSetup = fileread(fname);
matRad_cfg.dispInfo('Reading ''%s'' Beam Characteristics from ''%s''\n',obj.beamProfile,fname);

otherwise
matRad_cfg.dispError('Beam Type ''%s'' not supported for photons',obj.beamProfile);

end

% Set variables for loop over beams
Expand Down Expand Up @@ -1557,11 +1564,11 @@ function writeStfFields(obj,ct,stf,pln,w,baseData)
fprintf(fileID,'\n');

if isfield(pln.propStf, 'collimation')
%Use field width for now
% Use field width for now
fprintf(fileID,'d:So/PencilBeam/BeamPositionSpreadX = %d mm\n', pln.propStf.collimation.fieldWidth);
fprintf(fileID,'d:So/PencilBeam/BeamPositionSpreadY = %d mm\n', pln.propStf.collimation.fieldWidth);
else
%Set some default value
% Set some default value
fprintf(fileID,'d:So/PencilBeam/BeamPositionSpreadX = %d mm\n', 30);
fprintf(fileID,'d:So/PencilBeam/BeamPositionSpreadY = %d mm\n', 30);
end
Expand All @@ -1574,18 +1581,28 @@ function writeStfFields(obj,ct,stf,pln,w,baseData)
fprintf(fileID,'\n');

if isfield(pln.propStf, 'collimation')
%Use field width for now
% Use field width for now
fprintf(fileID,'d:So/PencilBeam/BeamPositionCutoffX = %d mm\n', pln.propStf.collimation.fieldWidth/2);
fprintf(fileID,'d:So/PencilBeam/BeamPositionCutoffY = %d mm\n', pln.propStf.collimation.fieldWidth/2);
else
%Set some default value
% Set some default value
fprintf(fileID,'d:So/PencilBeam/BeamPositionCutoffX = %d mm\n', 15);
fprintf(fileID,'d:So/PencilBeam/BeamPositionCutoffY = %d mm\n', 15);
end

case 'phasespace'
fprintf(fileID,'d:Sim/GantryAngle = %f deg\n',stf(beamIx).gantryAngle); %just one beam angle for now
fprintf(fileID,'d:Sim/CouchAngle = %f deg\n',stf(beamIx).couchAngle);
fprintf(fileID,'d:Sim/CouchAngle = %f deg\n',stf(beamIx).couchAngle);
% Here the phasespace file is loaded and referenced in the beamSetup file
phaseSpaceFileName = 'SIEMENS_PRIMUS_6.0_0.10_15.0x15.0';
if obj.externalCalculation
matRad_cfg.dispWarning(['External calculation and phaseSpace selected, manually place ' phaseSpaceFileName '.header and ' phaseSpaceFileName '.phsp into your simulation directory.']);
else
if length(dir([obj.thisFolder filesep 'beamSetup' filesep 'phasespace' filesep phaseSpaceFileName '*'])) < 2
matRad_cfg.dispError([phaseSpaceFileName ' header or phsp file could not be found in beamSetup/phasespace folder.']);
end
end
fprintf(fileID,'s:So/Phasespace/PhaseSpaceFileName = "%s"\n', [obj.thisFolder filesep 'beamSetup' filesep 'phasespace' filesep phaseSpaceFileName]);

end

Expand Down
1 change: 0 additions & 1 deletion topas/beamSetup/TOPAS_beamSetup_Phasespace.txt.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
s:So/Phasespace/Type = "PhaseSpace"
s:So/Phasespace/PhaseSpaceFileName = "SIEMENS_PRIMUS_6.0_0.10_15.0x15.0"
s:So/Phasespace/Component = "Nozzle"
#b:So/Example/LimitedAssumeFirstParticleIsNewHistory = "true"
#b:So/Example/LimitedAssumeEveryParticleIsNewHistory = "true"
Expand Down

0 comments on commit 0af8238

Please sign in to comment.