nbara / python-meegkit

🔧🧠 MEEGkit: MEG & EEG processing toolkit in Python
https://nbara.github.io/python-meegkit/
BSD 3-Clause "New" or "Revised" License
182 stars 50 forks source link

dimension error when detrending with higher order polynomial #34

Closed OleBialas closed 3 years ago

OleBialas commented 3 years ago

I am trying to do a detrending of my raw data in two steps with a linear and a higher order polynomial detrending, like this:

y, _, _ = meegkit.detrend.detrend(x, 1) y, _, _ = meegkit.detrend.detrend(y, 5)

where x is raw data of shape (289120, 64) The first detrending works just fine but during the second one I get a ValueError in line 209 of the regress function, saying that the array c could not be broadcast into the matrix b due to a mismatch in dimensions. It seems the matrix b has the shape (n_channels, n_channels) while c has the shape (order, 1).

Maybe something has changed in the underlying scipy functions? I am using:

python 3.9.2 numpy 1.20.2 scipy 1.6.2

Thanks for the nice package btw:) Cheers, Ole

nbara commented 3 years ago

Hi, thanks for reporting this. Seems like a bug indeed. I will have a look this week!

On 7 Apr 2021, at 09:09, Ole Bialas @.***> wrote:

 I am trying to do a detrending of my raw data in two steps with a linear and a higher order polynomial detrending, like this:

y, , = meegkit.detrend.detrend(x, 1) y, , = meegkit.detrend.detrend(y, 5)

where x is raw data of shape (289120, 64) The first detrending works just fine but during the second one I get a ValueError in line 209 of the regress function, saying that the array c could not be broadcast into the matrix b due to a mismatch in dimensions. It seems the matrix b has the shape (n_channels, n_channels) while c has the shape (order, 1).

Maybe something has changed in the underlying scipy functions? I am using:

python 3.9.2 numpy 1.20.2 scipy 1.6.2

Thanks for the nice package btw:) Cheers, Ole

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

nbara commented 3 years ago

@OleBialas can you try the code in https://github.com/nbara/python-meegkit/pull/36 and see if it fixes your issue?

OleBialas commented 3 years ago

Yes now everything seems to work. Thank you for the quick support!

nbara commented 3 years ago

Great. Next step will be to support trial-weighted detrending (cf #35) and piece-wise detrending (for really long datasets)