You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.add_reference_channels sends unexpected log about locations #12959
"Location for this channel is unknown; consider calling "
"set_montage() after adding new reference channels if needed. "
"Applying a montage will only set locations of channels that "
"exist at the time it is applied."
)
MWE 👇
# %%# Importsimportmne# %%# Get some test datasample=mne.datasets.sample.data_path()
raw=mne.io.read_raw(sample/"MEG"/"sample"/"sample_audvis_raw.fif")
raw.pick("eeg") # for simplicityraw.set_montage(None) # remove all locationsraw.load_data()
# %%# This logs:# Location for this channel is unknown;# consider calling set_montage() after adding new reference channels if needed.# Applying a montage will only set locations of channels that exist at the time it is applied.raw.add_reference_channels("ZZZ")
# ... I find that unexpected / unneeded: This log should only occur for raw objects that# already have SOME locations. NOT for raw objects that do not have any locations anyhow.# %%
☝️ IMHO we should only send this log if some locations were already applied at some point.
I actually find the code a bit confusing and do not really know what to remove:
# only do this if we actually have digitisation pointsifinst.info.get("dig", None) isnotNone:
# "zeroth" EEG electrode dig points is referenceref_dig_loc= [
dlfordlininst.info["dig"]
if (dl["kind"] ==FIFF.FIFFV_POINT_EEGanddl["ident"] ==0)
]
iflen(ref_channels) >1orlen(ref_dig_loc) !=len(ref_channels):
ref_dig_array=np.full(12, np.nan)
warn("The locations of multiple reference channels are ignored.")
else: # n_ref_channels == 1 and a single ref digitization existsref_dig_array=np.concatenate(
(ref_dig_loc[0]["r"], ref_dig_loc[0]["r"], np.zeros(6))
)
# Replace the (possibly new) Ref location for each channelforidxinpick_types(inst.info, meg=False, eeg=True, exclude=[]):
inst.info["chs"][idx]["loc"][3:6] =ref_dig_loc[0]["r"]
else:
# Ideally we'd fall back on getting the location from a montage, but# locations for non-present channels aren't stored, so location is# unknown. Users can call set_montage() again if needed.ref_dig_array=np.full(12, np.nan)
logger.info(
"Location for this channel is unknown; consider calling ""set_montage() after adding new reference channels if needed. ""Applying a montage will only set locations of channels that ""exist at the time it is applied."
)
☝️ does this mean that sometimes we CAN set a channel location for an added reference channel?
Else I would simply suggest to entirely remove the logger.info call from the else clause above.
Activity
larsoner commentedon Nov 12, 2024
Makes sense to me!
sappelhoff commentedon Nov 20, 2024
I actually find the code a bit confusing and do not really know what to remove:
☝️ does this mean that sometimes we CAN set a channel location for an added reference channel?
Else I would simply suggest to entirely remove the
logger.infocall from theelseclause above.larsoner commentedon Nov 22, 2024
Yes I think so, assuming it is the one ref channel present in the dataset and there is an existing dig point for it