From ab2516826c4b3492f1246db978791207ad7f66d7 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Mon, 23 Sep 2024 22:33:23 +0200 Subject: [PATCH] DOC: clean up ECG ICA docstrs (#12866) --- mne/preprocessing/ecg.py | 8 +++----- mne/preprocessing/ica.py | 13 ++++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/mne/preprocessing/ecg.py b/mne/preprocessing/ecg.py index 1c808867312..d8b220ed8ee 100644 --- a/mne/preprocessing/ecg.py +++ b/mne/preprocessing/ecg.py @@ -185,8 +185,8 @@ def find_ecg_events( %(filter_length_ecg)s return_ecg : bool Return the ECG data. This is especially useful if no ECG channel - is present in the input data, so one will be synthesized. Defaults to - ``False``. + is present in the input data, so one will be synthesized (only works if MEG + channels are present in the data). Defaults to ``False``. %(reject_by_annotation_all)s .. versionadded:: 0.18 @@ -325,8 +325,6 @@ def _get_ecg_channel_index(ch_name, inst): if len(ecg_idx) == 0: return None - # raise RuntimeError('No ECG channel found. Please specify ch_name ' - # 'parameter e.g. MEG 1531') if len(ecg_idx) > 1: warn( @@ -487,7 +485,7 @@ def _make_ecg(inst, start, stop, reject_by_annotation=False, verbose=None): """Create ECG signal from cross channel average.""" if not any(c in inst for c in ["mag", "grad"]): raise ValueError( - "Generating an artificial ECG channel can only be done for MEG data" + "Generating an artificial ECG channel can only be done for MEG data." ) for ch in ["mag", "grad"]: if ch in inst: diff --git a/mne/preprocessing/ica.py b/mne/preprocessing/ica.py index d1b0e1b0456..d00d854fb4d 100644 --- a/mne/preprocessing/ica.py +++ b/mne/preprocessing/ica.py @@ -1616,17 +1616,16 @@ def find_bads_ecg( Cross-trial phase statistics :footcite:`DammersEtAl2008` or Pearson correlation can be used for detection. - .. note:: If no ECG channel is available, routine attempts to create - an artificial ECG based on cross-channel averaging. + .. note:: If no ECG channel is available, an artificial ECG channel will be + created based on cross-channel averaging of ``"mag"`` or ``"grad"`` + channels. If neither of these channel types are available in + ``inst``, artificial ECG channel creation is impossible. Parameters ---------- inst : instance of Raw, Epochs or Evoked Object to compute sources from. - ch_name : str - The name of the channel to use for ECG peak detection. - The argument is mandatory if the dataset contains no ECG - channels. + %(ch_name_ecg)s threshold : float | 'auto' Value above which a feature is classified as outlier. See Notes. @@ -1696,7 +1695,7 @@ def find_bads_ecg( idx_ecg = _get_ecg_channel_index(ch_name, inst) if idx_ecg is None: - ecg, times = _make_ecg( + ecg, _ = _make_ecg( inst, start, stop, reject_by_annotation=reject_by_annotation ) else: