sappelhoff / pyprep

A Python implementation of the Preprocessing Pipeline (PREP) for EEG data
https://pyprep.readthedocs.io/en/latest/
MIT License
128 stars 30 forks source link

Computation of window size based on cutoff frequency in local detrend method #125

Open danibene opened 1 year ago

danibene commented 1 year ago

Hello :)

I was wondering if it is normal that frequencies below the detrendCutoff in removeTrend() are not completely attenuated, see e.g.: https://gist.github.com/danibene/e3ed1200a75ea72a3c52bfb0ac248a2c

If not, maybe this has something to do with how the windowSize is computed? https://github.com/sappelhoff/pyprep/blob/master/pyprep/removeTrend.py#L92

For more context you can also see https://github.com/neuropsychology/NeuroKit/pull/734#issuecomment-1283520550

sappelhoff commented 1 year ago

Hi, thanks for the report!

PyPREP is a port of PREP in MATLAB (https://github.com/VisLab/EEG-Clean-Tools), and I believe the way we calculate the window size has been taken directly from the original PREP code, see:

https://github.com/VisLab/EEG-Clean-Tools/blob/9ac9ea0c21d44b57f9e9f93b62ca727c7b75c73e/PrepPipeline/utilities/removeTrend.m#L79

It's entirely possible that it's wrong in the original PREP code ... if so, I would be open to fixing it here, and documenting it as one further deviation from the original code, as the other listed here: https://pyprep.readthedocs.io/en/latest/matlab_differences.html

Also, you could consider raising this issue at the original PREP repository that I mention above, ... if they also recognize this as an error, they might fix it there, and we can mirror the fix here, without an entry to the "matlab differences" section in the docs that I linked above.