Skip to content

Commit

Permalink
[MRG] Improve error message raised on channels missing from DigMontage (
Browse files Browse the repository at this point in the history
mne-tools#11472)

Co-authored-by: Daniel McCloy <[email protected]>
  • Loading branch information
mscheltienne and drammock authored Feb 15, 2023
1 parent 62c5e42 commit 449ad99
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions mne/channels/montage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,14 +1183,17 @@ def _backcompat_value(pos, ref_pos):
missing = np.where([use not in ch_pos for use in info_names_use])[0]
if len(missing): # DigMontage is subset of info
missing_names = [info_names[ii] for ii in missing]
pl = _pl(missing)
are_is = "are" if pl else "is"
missing_coord_msg = (
'DigMontage is only a subset of info. There are '
f'{len(missing)} channel position{_pl(missing)} '
'not present in the DigMontage. The required channels are:\n\n'
f'{missing_names}.\n\nConsider using inst.set_channel_types '
'if these are not EEG channels, or use the on_missing '
'parameter if the channel positions are allowed to be unknown '
'in your analyses.'
f"DigMontage is only a subset of info. There {are_is} "
f"{len(missing)} channel position{pl} not present in the "
f"DigMontage. The channel{pl} missing from the montage {are_is}:"
f"\n\n{missing_names}.\n\nConsider using inst.rename_channels to "
"match the montage nomenclature, or inst.set_channel_types if "
f"{'these' if pl else 'this'} {are_is} not {'' if pl else 'an '}"
f"EEG channel{pl}, or use the on_missing parameter if the channel "
f"position{pl} {are_is} allowed to be unknown in your analyses."
)
_on_missing(on_missing, missing_coord_msg)

Expand Down

0 comments on commit 449ad99

Please sign in to comment.