Using Parallel Computation Toolbox from Matlab

If you have the Parallel Computation Toolbox (PCT) from Matlab, you can use its power and ease of use to run neuroimaging analysis in parallel. Read more here and here for more information on this toolbox. The trick is to use multiple CPU cores on your machine for running analysis in parallel. For example, when I am running some analysis on every participant, I can use PCT to launch the analysis on 6-8 participants in parallel, which cuts down the run time to about 5 times or so.

To use this toolbox, first open the matlab pool as follows

matlabpool open  % to use all the available CPU cores OR

matlabpool open 2 % to open just two of them

Then just  change the for loop (e.g., over each participant) to

parfor p = 1:1:npart

% calculation here

end

And closing the pool in the end,

matlabpool close;

 

Hope that helps!

Leave a comment