question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ASR transform fails (unexpected zi shape)

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nbaracommented, Nov 4, 2020

Glad to hear this ! Sorry for taking more than a month to reply (I usually get notifications for issues but this one slipped by)

1reaction
nbaracommented, Nov 4, 2020

Nevermind, I think I have a fix in #15. Can you please try to checkout nb/fix-issue-10 and report back if it solves your issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

NeMo/ASR_with_NeMo.ipynb at main · NVIDIA/NeMo - GitHub
ASR, or Automatic Speech Recognition, refers to the problem of getting a program to automatically transcribe spoken language (speech-to-text).
Read more >
Fine-Tune Wav2Vec2 for English ASR with Transformers
The pretrained Wav2Vec2 checkpoint maps the speech signal to a sequence of context representations as illustrated in the figure above. A fine- ...
Read more >
Configure and Capture Embedded Packet on Software - Cisco
This document describes the Embedded Packet Capture (EPC) feature in Cisco IOS® software.
Read more >
TensorRT 8.0.1 release notes - NVIDIA Documentation Center
In some rare cases when converting a MatrixMultiply layer to a Convolution layer for optimization purposes, the shapes may fail to inference.
Read more >
ASR Evaluation - CS @ Columbia
How to evaluate the 'goodness' of a word string output by a speech recognizer? Terms: ASR hypothesis: ASR output; Reference transcription: ground truth...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found