From d474f094683a629e6a74244d69eec1e2a0def67f Mon Sep 17 00:00:00 2001 From: Tobias Becher <44724749+tobiasbecher@users.noreply.github.com> Date: Fri, 30 Jun 2023 14:33:25 +0200 Subject: [PATCH] Removed indexing of VOI VOI are no longer assigned an index on initialization. -> No need to clear all at the start of a script if rerunning --- PhantomBuilder/matRad_PhantomVOIBox.m | 2 +- PhantomBuilder/matRad_PhantomVOISphere.m | 2 +- PhantomBuilder/matRad_PhantomVOIVolume.m | 46 ++++++++++++----------- examples/matRad_example1_phantomBuilder.m | 2 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/PhantomBuilder/matRad_PhantomVOIBox.m b/PhantomBuilder/matRad_PhantomVOIBox.m index 681e694bd..c60443069 100644 --- a/PhantomBuilder/matRad_PhantomVOIBox.m +++ b/PhantomBuilder/matRad_PhantomVOIBox.m @@ -53,7 +53,7 @@ end end - cst{obj.idx,4}{1} = find(VOIHelper); + cst{end,4}{1} = find(VOIHelper); end diff --git a/PhantomBuilder/matRad_PhantomVOISphere.m b/PhantomBuilder/matRad_PhantomVOISphere.m index f917d7f9f..deb46b415 100644 --- a/PhantomBuilder/matRad_PhantomVOISphere.m +++ b/PhantomBuilder/matRad_PhantomVOISphere.m @@ -53,7 +53,7 @@ end end - cst{obj.idx,4}{1} = find(VOIHelper); + cst{end,4}{1} = find(VOIHelper); end end diff --git a/PhantomBuilder/matRad_PhantomVOIVolume.m b/PhantomBuilder/matRad_PhantomVOIVolume.m index c2f71bba2..40cdf5819 100644 --- a/PhantomBuilder/matRad_PhantomVOIVolume.m +++ b/PhantomBuilder/matRad_PhantomVOIVolume.m @@ -20,7 +20,6 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% properties - idx; name; type; TissueClass = 1; @@ -34,7 +33,7 @@ objectives = {}; colors = [[1,0,0];[0,1,0];[0,0,1];[1,1,0];[1,0,1];[0,1,1];[1,1,1]]; end - +%{ methods (Static, Access = private) function oldValue = getOrIncrementCount(increment) %used to automatically index the objectives @@ -49,26 +48,24 @@ end end end - - methods (Static) + methods (Static) function value = getInstanceCount() % Public access to the counter cannot increment it value = cldef.getOrIncrementCount(); end end +%} methods function obj = matRad_PhantomVOIVolume(name,type,p) %p is the input parser used in the child classes to check for additional variables % Increment the counter in the constructor - matRad_PhantomVOIVolume.getOrIncrementCount(1); - obj.idx = matRad_PhantomVOIVolume.getOrIncrementCount(); - if obj.idx <= size(obj.colors,1) - obj.visibleColor = obj.colors(obj.idx,:); - else - obj.visibleColor = [1 1 1]; - end - obj.Priority = obj.idx; + %matRad_PhantomVOIVolume.getOrIncrementCount(1); + %obj.idx = matRad_PhantomVOIVolume.getOrIncrementCount(); + %if obj.idx <= size(obj.colors,1) + % obj.visibleColor = obj.colors(obj.idx,:); + %end + %obj.Priority = obj.idx; obj.name = name; obj.type = type; obj.offset = p.Results.offset; @@ -87,15 +84,20 @@ function cst = initializeParameters(obj,cst) %initialize entry for this VOI in cst - cst{obj.idx,1} = obj.idx-1; - cst{obj.idx,2} = obj.name; - cst{obj.idx,3} = obj.type; - cst{obj.idx,5}.TissueClass = obj.TissueClass; - cst{obj.idx,5}.alphaX = obj.alphaX; - cst{obj.idx,5}.betaX = obj.betaX; - cst{obj.idx,5}.Priority = obj.Priority; - cst{obj.idx,5}.Visible = obj.Visible; - cst{obj.idx,5}.visibleColor = obj.visibleColor; + nxIdx = size(cst,1)+1; + cst{nxIdx,1} = nxIdx-1; + cst{nxIdx,2} = obj.name; + cst{nxIdx,3} = obj.type; + cst{nxIdx,5}.TissueClass = obj.TissueClass; + cst{nxIdx,5}.alphaX = obj.alphaX; + cst{nxIdx,5}.betaX = obj.betaX; + cst{nxIdx,5}.Priority = nxIdx; + cst{nxIdx,5}.Visible = obj.Visible; + + if nxIdx <= size(obj.colors,1) + obj.visibleColor = obj.colors(nxIdx,:); + end + cst{nxIdx,5}.visibleColor = obj.visibleColor; if ~iscell(obj.objectives) %should be redundant DoseObjectives = {obj.objectives}; @@ -103,7 +105,7 @@ DoseObjectives = obj.objectives; end for i = 1:numel(DoseObjectives) - cst{obj.idx,6} {i}= DoseObjectives{i}; + cst{nxIdx,6} {i}= DoseObjectives{i}; end end end diff --git a/examples/matRad_example1_phantomBuilder.m b/examples/matRad_example1_phantomBuilder.m index ba80a406d..68dbdd50b 100644 --- a/examples/matRad_example1_phantomBuilder.m +++ b/examples/matRad_example1_phantomBuilder.m @@ -19,7 +19,7 @@ % (iii) generate a treatment plan for this phantom %% set matRad runtime configuration -clear all; %somewhat needed for the phantom builder +%clear all; %somewhat needed for the phantom builder matRad_rc; %If this throws an error, run it from the parent directory first to set the paths %% Create a CT image series