Skip to content

Multiple progress bar #614

Open
Open
@Edouard2laire

Description

Hello,

it would be great to have brainstorm handle multiple progress bar.

Use case

When we lunch a pipleline on a set of files, it would be great to have a progress bar indicating the how many subject have been process while still allowing the executed process to have their own progress bar (case for some process being long to execute such as MEM).

Toy example:

bst_progress('start', 'External Loop', '', 0, 10);
for iSubject = 1:10
    
    internal_loop();
    bst_progress('inc', 1);
end
bst_progress('stop');


function internal_loop()

    N = 20;    
    bst_progress('start', 'Internal Loop', '', 0, N);
    for i = 1:N
        pause(1)
       bst_progress('inc', 1);
    end

    bst_progress('stop');

end

Suggestions:

-> bst_progress('start', ...) is always creating a new windows; and store it as a vector in GlobalData.Program.ProgressBar
-> all following function call are updating the latest created windows: pBar = GlobalData.Program.ProgressBar(end);
-> bst_progress('stop'); remove the delete the windows and remove it from GlobalData.Program.ProgressBar

It's working, the only issue is that there is one window per progress bar, but I guess that's ok as we are not expecting to have more than 2 or 3 progress bars active simultaneously. I can open a PR if you want -- Edouard2laire@dc00dcd :)
If we want only one window, we might use this toolbox: https://www.mathworks.com/matlabcentral/fileexchange/26589-multiwaitbar

HS :

In case, that's helpful for anyone; here is how the current progress bar can be used with parfor:

    N = 20;
    q = parallel.pool.DataQueue;
    afterEach(q, @(x) bst_progress('inc', 1));
    
    bst_progress('start', 'Internal Loop', '', 0, N);
    parfor i = 1:N
        pause(1+1.2*abs(randn()))
        send(q, i); 
    end

    bst_progress('stop');

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions