can parfor be used with spectrogram?
1 view (last 30 days)
Show older comments
I have EEG data and am trying to calculate spectrograms on each channel, then store the data for each channel. It would be nice to use parfor to speed this up, as calculating the spectrogram for each EEG channel should be an independent operation. But, I am getting the error that (for f, t, and p below) "the variable is nondeterministic". Is there some way to fix my code to get this to work, or is the problem with the spectrogram function (part of the signal processing toolbox)?
parfor this_channel = 1:num_channels
[~,f,t,p] = spectrogram(eeg_data(this_channel,:), win_length, num_overlap, nfft, samp_rate);
f_store(this_channel, :) = f;
t_store(this_channel, :) = t;
p_store(:,:, this_channel) = p;
end
2 Comments
Jeremy
on 29 Oct 2013
I don't currently have the PCT, but what you have looks correct. I have never had really much success with parfor in matlab, however I have seen some dramatic results using the GPU, and this might be a good task for the GPU, especially if "eeg_data" is very large in both dimensions. you could try using cellfun, it would still be single threaded, but it might be faster:
d=num2cell(randn(100000,5),1);
[~,t,f,p]=cellfun(@(x) ... spectrogram(x,hanning(1000),500,1000,1000),d,'uniformoutput',0);
Imola Fodor
on 21 Jul 2021
i had the spectrograms different when i generated them through parfor for a batch of audio files, than from a for loop
Answers (0)
See Also
Categories
Find more on EEG/MEG/ECoG in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!