All EEG and EOG channels have type 'ecg' when reading HCP data using read_raw_bti()
This bug report is based on this discussion in the MNE group.
I am using MNE and MNE-HCP to analyze HCP data. When I use the following function to read the HCP data, all ECG, EOG, and EEG channels have type 'ecg':
files = hcp.file_mapping.get_file_paths(subject=subj, data_type=datatype,
output='raw', hcp_path=hcp_dir, run_index=run_index)
# read the raw data
raw = mne.io.read_raw_bti(files[0], head_shape_fname=None, convert=False, preload=True)
The same also happens when I simply use hcp.read_raw(). Here are the info files for the two variants.
mne.io.read_raw_bti:
<Info | 8 non-empty values bads: [] ch_names: MEG 001, MEG 002, MEG 003, MEG 004, MEG 005, MEG 006, MEG 007, ... chs: 248 Magnetometers, 2 Stimulus, 23 Reference Magnetometers, 13 ECG, 1 misc custom_ref_applied: False dev_ctf_t: CTF MEG device -> CTF/4D/KIT head transform highpass: 0.0 Hz lowpass: 1017.3 Hz meas_date: 2014-05-21 14:38:37 UTC nchan: 287 projs: [] sfreq: 2034.5 Hz
hcp.read_raw:
<Info | 8 non-empty values bads: [] ch_names: TRIGGER, RESPONSE, MLzA, MLyA, MLzaA, MLyaA, MLxA, A22, MLxaA, ... chs: 2 Stimulus, 23 Reference Magnetometers, 248 Magnetometers, 13 ECG, 1 misc custom_ref_applied: False dev_ctf_t: CTF MEG device -> CTF/4D/KIT head transform highpass: 0.0 Hz lowpass: 1017.3 Hz meas_date: 2014-05-21 14:38:37 UTC nchan: 287 projs: [] sfreq: 2034.5 Hz
Furthermore, when using mne.io.read_raw_bti(), the ECG+ and ECG- channels are not named correctly anymore. I am currently using these functions as a workaround:
def _set_custom_ref_to_off(raw):
from mne.io.constants import FIFF
with raw.info._unlock():
raw.info['custom_ref_applied'] = FIFF.FIFFV_MNE_CUSTOM_REF_OFF
def set_ecg_eog_channels(raw):
"""
Set correct channel type for EEG/ECG/EOG channels and re-reference
ECG, VEOG, and HEOG channels using a bipolar referencing scheme.
Operates in place.
"""
# somehow all channels have type ECG -> set to EEG first
ecg_picks = mne.pick_types(raw.info, ecg=True)
for pick in ecg_picks:
ch_name = raw.info['ch_names'][pick]
raw.set_channel_types({ch_name: 'eeg'})
# set correct channel names for ECG
ecg_ch_mapping = {'EEG 001': 'ECG+', 'EEG 004': 'ECG-'}
mne.channels.rename_channels(raw.info, ecg_ch_mapping)
# combine ECG+/-, VEOG+/-, and HEOG+/- into three channels
# and set appropriate channel types
hcp.preprocessing.set_eog_ecg_channels(raw)
# hcp.preprocessing.set_eog_ecg_channels() results in flag custom_ref_applied
# being set to True -> set back to False to avoid errors
# when calling mne.minimum_norm.apply_inverse_raw()
_set_custom_ref_to_off(raw)
Versions: MNE-HCP: 0.1.dev12 MNE: 1.03