Open
Description
When processing a recent brainvision recording with FCz as the reference (which means it's not in the recording), I wanted to recover this channel in the data, use an average ref proj, and eventually source localize. So I wanted to do:
raw_eeg = mne.io.read_raw_brainvision(eeg_fname).load_data()
raw_eeg.rename_channels(eeg_renames) # numbers to standard 1020 names
mne.add_reference_channels(raw_eeg, "FCz", copy=False) # add all-zero channel
raw_eeg.set_montage("standard_1020") # set locations
raw_eeg.set_eeg_reference(["FCz"]) # set the reference information explicitly
raw_eeg.set_eeg_reference(projection=True) # switch to an average reference using projection
and have source loc etc. work. However, doing this we end up with two problems for source loc:
raw_eeg.info["custom_ref_applied"] == 1
raw_eeg.info["chs"][ii]["loc"][3:6]
is all zeros
Correct behavior here I think would be to have each EEG channel's ch["loc"][3:6]
be FCz's ch["loc"][:3]
, and have custom_ref_applied
be set to "off", i.e.:
with raw_eeg.info._unlock():
for ch in raw_eeg.info["chs"]:
ch["loc"][3:6] = raw_eeg.info["chs"][-1]["loc"][3:6]
raw_eeg.info["custom_ref_applied"] = 0
So concretely, I propose that in cases where set_eeg_reference
is called with a single channel name and that channel name has a meaningful position (ch["loc"][:3]"
), we set custom_ref_applied
to False and set ch["loc"][3:6]
for all EEG channels properly.