neuromodulation / perceive

This repository contains MATLAB code to extract data from the Medtronic Percept bidirectional brain computer interface device for adaptive deep brain stimulation.
http://icneuromodulation.org
Apache License 2.0
34 stars 16 forks source link

Huge memory requirements in ECG artifact removal #12

Open tsieger opened 3 years ago

tsieger commented 3 years ago

ECG artifact removal does not scale with BSTD signal length. It is quadratic in signal length. For long signals (hours and more), the code does not finish in several hours or simply crashes by requesting too much memory:

...running cross-correlation on 8104 segments...
...ecg template 1 generated...
Error using bsxfun
Out of memory. Type "help memory" for your options.
Error in corr>corrPearson (line 297)
    x = bsxfun(@minus,x,sum(x,1)/n);  % Remove mean
Error in corr (line 212)
        coef = corrFun(rows,tail,x,y);
Error in perceive_ecg (line 49)
r = corr(corrdata,ecg.proc.template1').^2;
Error in perceive (line 521)
                            d.ecg{e} = perceive_ecg(raw(e,:));
neumann-wj commented 3 years ago

Interesting, I would not have believed anyone would record/stream for hours. That must cause a huge battery drain for the patients? Would you be able to share such a file, so I can try to improve performance?

neumann-wj commented 3 years ago

It would probably make sense to include ECG processing into the options. Run ECG, but also whether the original signal should be replaced by cleaned data could be an option there.