From dae8c3d08619e90d964358479d11c3110c68c2ac Mon Sep 17 00:00:00 2001 From: Lisa Seckler Date: Fri, 28 Nov 2025 10:29:47 +0100 Subject: [PATCH] Warning gantry and couch angles + correct displayed progress Warning for different numbers of gantry and couch angles + correct progress displaying of the stf calculation --- ...Rad_StfGeneratorExternalRayBixelAbstract.m | 8 ++-- matRad/util/matRad_progress.m | 41 +++++++++++-------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/matRad/steering/matRad_StfGeneratorExternalRayBixelAbstract.m b/matRad/steering/matRad_StfGeneratorExternalRayBixelAbstract.m index 524cf6490..aecd9d67d 100644 --- a/matRad/steering/matRad_StfGeneratorExternalRayBixelAbstract.m +++ b/matRad/steering/matRad_StfGeneratorExternalRayBixelAbstract.m @@ -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('There are more gantry angles than couch angles. They have to have the same size.') end end @@ -67,9 +67,11 @@ function setDefaults(this) if ~this.lockAngleUpdate this.lockAngleUpdate = true; if numel(this.gantryAngles) > numel(this.couchAngles) + 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.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); @@ -239,7 +241,7 @@ function initialize(this) % Show progress if matRad_cfg.logLevel > 2 - matRad_progress(i,length(this.gantryAngles)); + matRad_progress(i,length(this.gantryAngles),1); end %% visualization @@ -384,7 +386,7 @@ function initialize(this) % Show progress if matRad_cfg.logLevel > 2 - matRad_progress(i,length(this.gantryAngles)); + matRad_progress(i,length(this.gantryAngles),2); end end end diff --git a/matRad/util/matRad_progress.m b/matRad/util/matRad_progress.m index 9cc357a3b..7037751ce 100644 --- a/matRad/util/matRad_progress.m +++ b/matRad/util/matRad_progress.m @@ -1,4 +1,4 @@ -function matRad_progress(currentIndex, totalNumberOfEvaluations) +function matRad_progress(currentIndex, totalNumberOfEvaluations,scen) % matRad progress bar % % call @@ -27,23 +27,30 @@ function matRad_progress(currentIndex, totalNumberOfEvaluations) % LICENSE file. % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -% If it's not the first step, erase the stuff printed before -if (currentIndex == 1) - fprintf('Progress: '); + +persistent isInitialized + +if isempty(isInitialized) + isInitialized = true; end - -if (currentIndex > 1) - Length = numel(sprintf('%3.2f %%',(currentIndex-1)/totalNumberOfEvaluations*100)); - fprintf(repmat('\b',1,Length)); + +percent = (currentIndex / totalNumberOfEvaluations) * 100; + +% --- first part of the progress --- +if scen == 1 + % new line + fprintf('\rProgress: %6.2f %%', percent); end - -% Print the progress tool -fprintf('%3.2f %%',currentIndex/totalNumberOfEvaluations*100); - -% After the last iteration print a newline command -if (currentIndex == totalNumberOfEvaluations) - fprintf('\n'); + +% --- for scenario 2, same line --- +if scen == 2 + fprintf(' Progress: %6.2f %%', percent); end - + +% --- finish line after the last angle --- +if currentIndex == totalNumberOfEvaluations && scen == 2 + fprintf('\n'); + clear isInitialized end + +