Hi everyone,
My question is why does mne.minimum_norm.apply_inverse_raw() call _check_reference() even if I set eeg to False when computing the forward solution? mne.minimum_norm.apply_inverse_epochs_gen() does not call _check_reference().
For context: I am currently working with HCP data and MNE-HCP and for some reason when I load the data using:
files = hcp.io.file_mapping.get_file_paths(subject=subj, data_type='rest',
output='raw', hcp_path=hcp_dir, run_index=0)
raw = mne.io.read_raw_bti(files[0], head_shape_fname=None, convert=False, preload=True)
all reference channels are set to ecg. Furthermore, I would like to use ica.find_bads_ecg() etc. to automatically detect ECG and EOG components. However, for the HCP data the channels were split into ‘ECG+’ and ‘ECG-’ and the same is true for VEOG and HEOG. Therefore, I made the following function to rename the channels and combine the +/- channels:
def set_ecg_eog_channels(raw):
"""
Set correct channel type for EEG/ECG/EOG channels.
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)
However, this sets the custom_ref_applied flag to True and as a result I cannot use apply_inverse_raw(). I am not really sure what the EEG reference is used for when I am only interested in MEG channels so can I simply set the flag to False using the following function? Or is there a reason why this would be a bad idea? I also was wondering if I maybe should call mne.set_eeg_reference() as well?
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
Maybe @larsoner could have a look?
Thanks!
- MNE version: 1.0.3
- operating system: macOS