Merge EEG and EMG data filtered differently in one raw object

  • MNE version: 0.24.0
  • operating system: macOS 12

Assumed that I have two raw objects. One named raw_eeg contains EEG data band-passed in 1-45 Hz, and the other one named raw_emg contains EMG data band-passed in 10-200 Hz.

It is required raw_eeg.info[‘highness’] == raw_emg.info[‘highness’] if I want to merge these concurrently recorded data by using raw_eeg.addchannels([raw_emg])

If I try to manually set raw_emg.info[‘highness’] as raw_eeg.info[‘highness’], a warning message appeared “DeprecationWarning: highpass cannot be set directly. Please use methods inst.filter() instead. This warning will turn into an error after 0.24”

I would like to know what is the best way to merge EEG and EMG data that are filtered differently

Thanks

Hello,

I think this is a bug in the concatenation because you should be able to filter differently for different channels. For instance, this code snippet creates a valid raw instance with different filters applied to both channel types:

import numpy as np
from mne import create_info
from mne.io import RawArray


n_ch, n_times = 3, 1000
data = np.random.RandomState(0).randn(n_ch, n_times)
info = create_info(n_ch, 1000., ['eeg', 'eeg', 'emg'])
raw = RawArray(data, info)
raw.filter(l_freq=1, h_freq=10, picks='eeg')
raw.filter(l_freq=20, h_freq=200, picks='emg')
raw.plot(scalings=dict(eeg=4, emg=4))

Providing force_update_info=True does force the concatenation:

import numpy as np
from mne import create_info
from mne.io import RawArray


data = np.random.RandomState(0).randn(2, 1000)
info = create_info(2, 1000., 'eeg')
raw = RawArray(data, info)
raw.filter(l_freq=1, h_freq=10, picks='eeg')


data = np.random.RandomState(0).randn(1, 1000)
info = create_info(['emg1'], 1000., 'emg')
raw_emg = RawArray(data, info)
raw_emg.filter(l_freq=20, h_freq=200, picks='emg')

raw.add_channels([raw_emg], force_update_info=True)
raw.plot(scalings=dict(eeg=4, emg=4))

I will have a look to the concatenation of raw instances with different filters when I have the time.

Mathieu

Thank you Mathieu, force_update_info does the trick.