Create Filter: picks < n_channels(64) got 64 -ERROR

  • MNE-Python version: 0.23.0
  • operating system: Windows 10 Pro, 64-bit

I load data from the brainvision format (.vhdr) into a raw object and try to filter it using mne.filter.create_filter.

The code is:

raw = mne.io.read_raw_brainvision(filepath, preload=True)

raw_resampled = raw.resample(256)

#highpass filter (all channels, cut off: 0.1 Hz, butterworth, 2.order, (DC removal?))
params = dict(order=2,ftype='butter',btype='highpass')

raw_hp = mne.filter.create_filter(data=raw_resampled,sfreq=256,method='iir',iir_params=params,h_freq=0.1,l_freq=None)

#lowpass filter (all channels, cut off: 40 Hz, butterworth, 4.order, (DC removal?))
params = dict(order=4,ftype='butter')

raw_lp = mne.filter.create_filter(data=raw_hp,sfreq=256,method='iir',iir_params=params,l_freq=40,h_freq=None)

And the error message says:

Exception has occurred: ValueError
All picks must be < n_channels (64), got 64
  File "C:\Users\jojo_\Documents\GitHub\bachelorthesis\load_preproc.py", line 56, in <module>
    raw_hp = mne.filter.create_filter(data=raw_resampled,sfreq=256,method='iir',iir_params=params,h_freq=0.1,l_freq=None)

I don’t know how to solve this and would be really thankful if someone could help me!! :slight_smile:

It is easier if you filter your data using raw.filter(0.1, 40). You can tweak the filter type and order if you really need the specific filter from your example. Does this solve the issue?

1 Like

Thank you, i think it is working correctly now! :heart_eyes: