[FieldTrip] Possibly speeding Up Preprocessing.

John Nguyen johnnguyen.education at gmail.com
Thu Apr 5 23:11:19 CEST 2018


Hi all,

I was running a lot of preprocessing and was finding that it was running
slower than I wanted despite good amount CPU/GPUS on board so I decided to
look more into the code. I think I found a way to improve the speed but I'm
not familiar with Github and pull requests so I just wanted to throw it out
there and get people's opinion.

In read_brainvision_eeg there is a for loop at line 79 using fseek and
fread to reposition the pointer and read the channel-specfic data. Using
tic-toc, I'm finding that it takes some time, around ~.27 secs for the loop
to finish.

When no channels are found, the same script runs fseek and fread only once
and I feel like this is the better way to go.
if 64-65 is replaced with
" fseek(fid, hdr.NumberOfChannels*samplesize*(begsample-1), *'bof'*);
    dat = fread(fid, [hdr.NumberOfChannels, (endsample-begsample+1)],
sampletype)
*dat = dat(chanindx,:)*;"
where underlined are the changes. the code should run whether or not
chanindx is empty.

tic-toc says it takes ~.05 sec and isequal says the two dat to be exactly
the same. This  could makes sense because it is not running fseek and fread
constantly which relies on hard drive speeds?
Though the timing seems to negligible, .27 sec per trial vs .05 per trial
comes out to be a lot in large number of trials. [29 minutes vs 4 mins at
216 trls for 30 subs]

Is my assumption correct? why is the for-loop at line 78 running though the
channels backwards?

Best regards,
John Nguyen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20180405/9c9e0610/attachment.html>


More information about the fieldtrip mailing list