Cannot plot raw data

  • MNE version: 1.6.1
  • operating system: macOS 12 (running in VSCode)

I’m trying to plot my continuous EEG data. Here’s my code:

import mne

file_path = 'file_path/filename.gdf'

raw = mne.io.read_raw_gdf(file_path, preload=True)

print(raw.info)

raw.filter(1, 50, fir_design="firwin")

print(f"lowpass filter:{raw.info['lowpass']}")

raw.plot()

I get the following error:

Traceback (most recent call last):
    raw.plot()
  File "...MNE-Python/1.6.1_0/.mne-python/lib/python3.11/site-packages/mne/io/base.py", line 1808, in plot
    return plot_raw(
           ^^^^^^^^^
  File "<decorator-gen-157>", line 12, in plot_raw
  File "...MNE-Python/1.6.1_0/.mne-python/lib/python3.11/site-packages/mne/viz/raw.py", line 258, in plot_raw
    decim, picks_data = _handle_decim(info, decim, lowpass)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...MNE-Python/1.6.1_0/.mne-python/lib/python3.11/site-packages/mne/viz/utils.py", line 1987, in _handle_decim
    decim = max(int(info["sfreq"] / (lp * 3) + 1e-6), 1)
                    ~~~~~~~~~~~~~~^~~~~~~~~~
ZeroDivisionError: float division by zero

My sampling frequency is 512.0 Hz (from raw.info).
I noticed that the lowpass filter doesn’t update after raw.filter() (it remains zero), even though highpass filter is updated to 1. I also get the following message when loading my data:

<ipython-input-2-f238b083ba6e>:4: RuntimeWarning: Channels contain different highpass filters. Highest filter setting will be stored.
  raw = mne.io.read_raw_gdf(file_path, preload=True)
<ipython-input-2-f238b083ba6e>:4: RuntimeWarning: Channels contain different lowpass filters. Lowest filter setting will be stored.
  raw = mne.io.read_raw_gdf(file_path, preload=True)

Before filtering, both high and lowpass are 0, and raw.plot() creates the same error. And I get the same error after removing all but eeg channels.

Appreciate any help! :slight_smile:

1 Like

This is weird. Even before filtering, the lowpass should be set to the Nyquist frequency. Can you show the output of raw.info before and after filtering?

Sure! Here’s before:

<Info | 8 non-empty values
 bads: []
 ch_names: FP1, FPZ, FP2, F7, F3, FZ, F4, F8, FC5, FC1, FC2, FC6, M1, T7, ...
 chs: 67 EEG, 1 Stimulus
 custom_ref_applied: False
 highpass: 0.0 Hz
 lowpass: 0.0 Hz
 meas_date: 2024-02-28 19:14:52 UTC
 nchan: 68
 projs: []
 sfreq: 512.0 Hz
 subject_info: 4 items (dict)
>

Here’s after:

<Info | 8 non-empty values
 bads: []
 ch_names: FP1, FPZ, FP2, F7, F3, FZ, F4, F8, FC5, FC1, FC2, FC6, M1, T7, ...
 chs: 67 EEG, 1 Stimulus
 custom_ref_applied: False
 highpass: 1.0 Hz
 lowpass: 0.0 Hz
 meas_date: 2024-02-28 19:14:52 UTC
 nchan: 68
 projs: []
 sfreq: 512.0 Hz
 subject_info: 4 items (dict)
>

And here’s the filter output if that helps: Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 50 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
<ipython-input-4-4639bfb5ae1d>:4: RuntimeWarning: Channels contain different highpass filters. Highest filter setting will be stored.
  raw = mne.io.read_raw_gdf(file_path, preload=True)
<ipython-input-4-4639bfb5ae1d>:4: RuntimeWarning: Channels contain different lowpass filters. Lowest filter setting will be stored.
  raw = mne.io.read_raw_gdf(file_path, preload=True)
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 50.00 Hz
- Upper transition bandwidth: 12.50 Hz (-6 dB cutoff frequency: 56.25 Hz)
- Filter length: 1691 samples (3.303 s)
1 Like

This looks like a bug in our GDF reader. Could you open an issue and also share the file with us?

2 Likes

The issue is being tracked here: