Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple progress bar #614

Open
Edouard2laire opened this issue Apr 18, 2023 · 0 comments
Open

Multiple progress bar #614

Edouard2laire opened this issue Apr 18, 2023 · 0 comments

Comments

@Edouard2laire
Copy link
Contributor

Edouard2laire commented Apr 18, 2023

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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant