Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,16 @@ function setDefaults(this)
end


function progressUpdate(this,pos,total)
function progressUpdate(this,pos,total,linereset)
% This function updates the progress of the dose calculation process.
% It can handle both absolute and relative progress updates.
% If only one argument is provided, it assumes a relative progress
% update from 0 to 1000. If two arguments are provided, it uses the
% actual values to calculate the progress percentage.

if nargin < 4
linereset = false;
end

% Default total value handling
if nargin < 3
pos = pos*1000; % Assume pos is a relative progress if total is not provided
Expand All @@ -348,7 +351,7 @@ function progressUpdate(this,pos,total)
% Log progress if the log level is high enough
% This allows for detailed tracking of the calculation progress in logs
if matRad_cfg.logLevel > 2
matRad_progress(pos,total); % Log the progress
matRad_progress(pos,total,linereset); % Log the progress
end

% Update the waitbar with the current progress if it exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function setDefaults(this)

%Initialize Beam Geometry
currBeam = this.initBeam(dij,ct,cst,scenStf,i);
progressLineReset = true;

%Keep tabs on bixels computed in this beam
bixelBeamCounter = 0;
Expand Down Expand Up @@ -151,7 +152,8 @@ function setDefaults(this)
% Progress Update & Bookkeeping
bixelCounter = bixelCounter + currRay.numOfBixels;
bixelBeamCounter = bixelBeamCounter + currRay.numOfBixels;
this.progressUpdate(bixelCounter,dij.totalNumOfBixels);
this.progressUpdate(bixelCounter,dij.totalNumOfBixels,progressLineReset);
progressLineReset = false;
end
end
end
Expand Down
11 changes: 5 additions & 6 deletions matRad/steering/matRad_StfGeneratorExternalRayBixelAbstract.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function setDefaults(this)
nBeams = numel(this.gantryAngles);
if nBeams ~= numel(this.couchAngles)
matRad_cfg = MatRad_Config.instance();
matRad_cfg.dispWarning('For some reason, we have a different number of beam and couch angles!');
matRad_cfg.dispError('The number of gantry angles and couch angles must be equal.');
end
end

Expand All @@ -67,9 +67,13 @@ function setDefaults(this)
if ~this.lockAngleUpdate
this.lockAngleUpdate = true;
if numel(this.gantryAngles) > numel(this.couchAngles)
matRad_cfg = MatRad_Config.instance();
matRad_cfg.dispError('There are more gantry angles than couch angles. They have to have the same size.');
%Append Couch angles with zeros
this.couchAngles = [this.couchAngles zeros(1,numel(this.gantryAngles)-numel(this.couchAngles))];
elseif numel(this.couchAngles) > numel(this.gantryAngles)
matRad_cfg = MatRad_Config.instance();
matRad_cfg.dispError('There are more couch angles than gantry angles. They have to have the same size.');
%Try to identify the removed beam angles
[removedAngles,ix] = setdiff(oldAngles,this.gantryAngles);

Expand Down Expand Up @@ -381,11 +385,6 @@ function initialize(this)
pause(1);
end


% Show progress
if matRad_cfg.logLevel > 2
matRad_progress(i,length(this.gantryAngles));
end
end
end

Expand Down
24 changes: 14 additions & 10 deletions matRad/util/matRad_progress.m
Comment thread
wahln marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function matRad_progress(currentIndex, totalNumberOfEvaluations)
% matRad progress bar
function matRad_progress(currentIndex, totalNumberOfEvaluations, linereset)
%
Comment thread
wahln marked this conversation as resolved.
% call:
% matRad_progress(currentIndex, totalNumberOfEvaluations)
%
% input:
% currentIndex: current iteration index
% totalNumberOfEvaluations: maximum iteration index
% linereset: (optional) reset output to new line
%
% output:
% graphical display of progess. make sure there is no other output
Expand All @@ -27,15 +27,17 @@ function matRad_progress(currentIndex, totalNumberOfEvaluations)
% LICENSE file.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


if nargin < 3
linereset = false;
end

% If it's not the first step, erase the stuff printed before
if (currentIndex == 1)
if (currentIndex == 1 || linereset)
fprintf('Progress: ');
end

if (currentIndex > 1)
Length = numel(sprintf('%3.2f %%',(currentIndex-1)/totalNumberOfEvaluations*100));
fprintf(repmat('\b',1,Length));
else
length = numel(sprintf('%3.2f %%',(currentIndex-1)/totalNumberOfEvaluations*100));
fprintf(repmat('\b',1,length));
end

% Print the progress tool
Expand All @@ -45,5 +47,7 @@ function matRad_progress(currentIndex, totalNumberOfEvaluations)
if (currentIndex == totalNumberOfEvaluations)
fprintf('\n');
end

end


Loading