-
Notifications
You must be signed in to change notification settings - Fork 54
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Hello! I am trying to apply ASR to some EEG data recorded at our lab with EEGLAB. We are using MNE for the analyses and we wanted to incorporate ASR as a preprocessing step. I was currently running the asr example code:
# Get data array for ASR
raw_array = raw.get_data()
# Train ASR
asr = ASR(method='euclid')
train_idx = np.arange(0 * sfreq, 30 * sfreq, dtype=int) # 30s period
_, sample_mask = asr.fit(raw_array[:, train_idx])
# Apply a sliding window to the data
X = sliding_window(raw_array, window=int(sfreq), step=int(sfreq))
Y = np.zeros_like(X)
for i in range(X.shape[1]):
Y[:, i, :] = asr.transform(X[:, i, :])
And I got the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-63-b37fc0c9f43f> in <module>
11 Y = np.zeros_like(X)
12 for i in range(X.shape[1]):
---> 13 Y[:, i, :] = asr.transform(X[:, i, :])
~/gitrepos/python-meegkit/meegkit/asr.py in transform(self, X, y, **kwargs)
221 # Yulewalk-filtered data (optional).
222 X_filt, self.zi_ = yulewalk_filter(
--> 223 X, sfreq=self.sfreq, ab=self.ab_, zi=self.zi_)
224
225 if not self._fitted:
~/gitrepos/python-meegkit/meegkit/utils/asr.py in yulewalk_filter(X, sfreq, zi, ab, axis)
317 if zi is None:
318 zi = signal.lfilter_zi(B, A)
--> 319 out, zf = signal.lfilter(B, A, X, zi=zi[:, None] * X[:, 0], axis=axis)
320 else:
321 out, zf = signal.lfilter(B, A, X, zi=zi, axis=axis)
~/anaconda3/envs/mne/lib/python3.7/site-packages/scipy/signal/signaltools.py in lfilter(b, a, x, axis, zi)
1907 return sigtools._linear_filter(b, a, x, axis)
1908 else:
-> 1909 return sigtools._linear_filter(b, a, x, axis, zi)
1910
1911
ValueError: Unexpected shape for zi: expected (32,8), found (8,32).
My understanding of the analysis is not very deep, but after looking around in scipy documentation and the repo's code I found that this 'zi' parameter is calculated automatically before being passed to the lfilter function. Being so, I am a bit confused by the fact that it has unexpected shape. Any ideas? Thanks!
marcpabst
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working