Skip to content

Commit

Permalink
AppendResultGUI now creates consistent fieldnames
Browse files Browse the repository at this point in the history
  • Loading branch information
wahln committed Jun 7, 2023
1 parent c5dd9eb commit 3e7952a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
14 changes: 8 additions & 6 deletions examples/matRad_example12_simpleParticleMonteCarlo.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
pln.numOfFractions = 1;

% beam geometry settings
pln.propStf.bixelWidth = 10; % [mm] / also corresponds to lateral spot spacing for particles
pln.propStf.longitudinalSpotSpacing = 10;
pln.propStf.bixelWidth = 5; % [mm] / also corresponds to lateral spot spacing for particles
pln.propStf.longitudinalSpotSpacing = 3;
pln.propStf.gantryAngles = 0; % [?]
pln.propStf.couchAngles = 0; % [?]
pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles);
Expand Down Expand Up @@ -73,6 +73,9 @@
%up the low-range region)
pln.propStf.useRangeShifter = true;

%Enable LET calculation
pln.propDoseCalc.calcLET = true;

% Enable/Disable local computation with TOPAS. Enabling this will generate
% the necessary TOPAS files to run the simulation on any machine or server.
% pln.propMC.externalCalculation = true;
Expand All @@ -94,14 +97,13 @@
resultGUI_MC = matRad_calcDoseDirectMC(ct,stf,pln,cst,resultGUI.w);

%% Compare Dose (number of histories not sufficient for accurate representation)
resultGUI = matRad_appendResultGUI(resultGUI,resultGUI_MC,0,'MC');
matRad_compareDose(resultGUI.physicalDose, resultGUI.physicalDose_MC, ct, cst, [1, 1, 0] , 'off', pln, [2, 2], 1, 'global');
resultGUI = matRad_appendResultGUI(resultGUI,resultGUI_MC,true,pln.propMC.engine);
matRad_compareDose(resultGUI.physicalDose, resultGUI.(['physicalDose_' pln.propMC.engine]), ct, cst, [1, 1, 0] , 'off', pln, [2, 2], 3, 'global');


%% Compare LET
if isfield(resultGUI,'LET') && isfield(resultGUI_MC,'LET')
matRad_compareDose(resultGUI.LET, resultGUI_MC.LET, ct, cst, [1, 1, 0] , 'off', pln, [2, 2], 1, 'global');
resultGUI.LET_MC = resultGUI_MC.LET;
matRad_compareDose(resultGUI.LET, resultGUI.(['LET_' pln.propMC.engine]), ct, cst, [1, 1, 0] , 'off', pln, [2, 2], 1, 'global');
end

%% GUI
Expand Down
38 changes: 22 additions & 16 deletions tools/matRad_appendResultGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,41 @@
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2018 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
% Copyright 2018 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.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if ~exist('Identifier','var')
Identifier = '';
else
Identifier = ['_' Identifier];
end

if ~exist('boolOverwrite','var')
boolOverwrite = false;
end

if ~exist('Identifier','var')
Identifier = '2';
end
matRad_cfg = MatRad_Config.instance();

caFieldnames = fieldnames(resultGUItoAppend);

for i = 1:numel(caFieldnames)

if boolOverwrite
resultGUI.(caFieldnames{i,1}) = resultGUItoAppend.(caFieldnames{i,1});
else
resultGUI.([caFieldnames{i,1} '_' Identifier]) = resultGUItoAppend.(caFieldnames{i,1});
end

currFieldName = caFieldnames{i,1};
fullFieldName = [caFieldnames{i,1} Identifier];

if boolOverwrite || ~isfield(resultGUI,fullFieldName)
resultGUI.(fullFieldName) = resultGUItoAppend.(currFieldName);
else
matRad_cfg.dispWarning('Field ''%s'' exists and overwriting was disabled. Results will not be appended to resultGUI!',fullFieldName);
end
end

% group similar fields together
Expand Down

0 comments on commit 3e7952a

Please sign in to comment.