Use of 'parfor' loops in LIMO - LIMO-EEG-Toolbox/limo_tools GitHub Wiki
By default, several functions in the LIMO toolbox attempt to execute loop iterations across parallel clusters of workers. This is achieved through the use of 'parfor' loops in combination with PSOM software. Functions that utilise 'parfor' loops include 'limo_batch' and 'limo_random_effect' (and many more).
However, upon running any LIMO function which utilises 'parfor' loops, you may encounter an error message along the lines of the following:
Error using limo_batch (line 333) The source code (C:\Program Files\MATLAB\R2016a\toolbox\eeglab_current\eeglab13_5_4b\plugins\limo_eeg-master\limo_batch.m) for the parfor loop that is trying to execute on the worker could not be found
This error occurs because the LIMO functions called within the loop are not on the path of any of the workers on the parallel pool (which is automatically opened by executing 'parfor'). This problem can be solved by opening up a parallel pool (by calling 'parpool') and adding the LIMO toolbox (or the folder containing LIMO) to the path of each worker prior to executing the function requiring parallel processing (or prior to opening the limo_eeg GUI). For instance, the following code should achieve this if you specify the path to the folder which contains LIMO:
parpool; addAttachedFiles(gcp,'C:\Program Files\MATLAB\R2016a\toolbox\eeglab_current\eeglab13_5_4b\');
Alternatively, you could add the 2nd line of the above code to the final line of the parpool.m script itself, in which case the chosen folder will be automatically added to the paths of all workers every time 'parpool' is called by any function.