Skip to content

Commit

Permalink
Removed indexing of VOI
Browse files Browse the repository at this point in the history
VOI are no longer assigned an index on initialization.
-> No need to clear all at the start of  a script if rerunning
  • Loading branch information
tobiasbecher committed Jun 30, 2023
1 parent c12f5e8 commit d474f09
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion PhantomBuilder/matRad_PhantomVOIBox.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
end
end

cst{obj.idx,4}{1} = find(VOIHelper);
cst{end,4}{1} = find(VOIHelper);


end
Expand Down
2 changes: 1 addition & 1 deletion PhantomBuilder/matRad_PhantomVOISphere.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
end
end

cst{obj.idx,4}{1} = find(VOIHelper);
cst{end,4}{1} = find(VOIHelper);

end
end
Expand Down
46 changes: 24 additions & 22 deletions PhantomBuilder/matRad_PhantomVOIVolume.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

properties
idx;
name;
type;
TissueClass = 1;
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -87,23 +84,28 @@

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};
else
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
Expand Down
2 changes: 1 addition & 1 deletion examples/matRad_example1_phantomBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d474f09

Please sign in to comment.