Skip to content

Commit

Permalink
Debugged cat_progress_bar.
Browse files Browse the repository at this point in the history
Corrected older call of cat_progress_bar but also added code to avoid errors with this older input.
  • Loading branch information
robdahn committed Sep 25, 2024
1 parent 4a5b1ea commit 62459ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions cat_progress_bar.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ function cat_progress_bar(action,varargin)
if ~nargin, help cat_progress_bar; return; end

if strcmpi(action,'init')
if nargin > 2, bartype = varargin{3}; else, bartype = 'bar'; end
if nargin > 2
% catch possible errors of older calls with additional field, eg.
% cat_progress_bar('Init', 10 ,'CAT-Preprocessing','Volumes Complete');
switch varargin{3}
case {'bar','cmd','cmd%'}
bartype = varargin{3};
otherwise
bartype = 'bar';
end
else
bartype = 'bar';
end
elseif strcmpi(action,'off') || strcmpi(action,'silent') || strcmpi(action,'quite') || strcmpi(action,'')
return
else
Expand All @@ -63,6 +74,16 @@ function cat_progress_bar(action,varargin)
%-------------------------------------------------------------------
case 'init'
n_iterations = varargin{1};

% from older versions that were not printed
%{
if nargin > 2
arg3 = varargin{2};
else
arg3 = '';
end
%}

if nargin > 1
arg2 = varargin{2};
if ~strcmp(bartype,'bar') && arg2(end)~=':'
Expand Down Expand Up @@ -155,7 +176,7 @@ function cat_progress_bar(action,varargin)
error('Unknown action string');
end
otherwise
error('error:cat_progress_bar:bartype',fprintf('Unknown bartype %s',bartype));
error('error:cat_progress_bar:bartype',sprintf('Unknown bartype "%s"',bartype));
end

return
Expand Down
2 changes: 1 addition & 1 deletion cat_run.m
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@
else
%% conclusion without filelist
spm_clf('Interactive');
cat_progress_bar('Init', sum( numel(job_data) ) ,'CAT-Preprocessing','Volumes Complete');
cat_progress_bar('Init', sum( numel(job_data) ) ,'CAT-Preprocessing');

fprintf('\nStarted %d jobs with the following PIDs:\n',job.nproc);
for i=1:job.nproc
Expand Down

0 comments on commit 62459ed

Please sign in to comment.