<div dir="ltr">Hi all,<div><br></div><div>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.</div><div><br></div><div>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.</div><div><br>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.<br>if 64-65 is replaced with</div><div>" fseek(fid, hdr.NumberOfChannels*samplesize*(begsample-1), <u>'bof'</u>);</div><div> dat = fread(fid, [hdr.NumberOfChannels, (endsample-begsample+1)], sampletype)<br><u>dat = dat(chanindx,:)</u>;"</div><div>
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">where underlined are the changes.</span> the code should run whether or not chanindx is empty.<br><br>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?<br>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 <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">at 216 trls for 30 subs</span>]</div><div><br>Is my assumption correct? why is the for-loop at line 78 running though the channels backwards? </div><div><br></div><div>Best regards,</div><div>John Nguyen<br><br></div><div><br></div></div>