Skip to content

Commit

Permalink
DOC: clean up ECG ICA docstrs (mne-tools#12866)
Browse files Browse the repository at this point in the history
  • Loading branch information
sappelhoff authored Sep 23, 2024
1 parent dcb05a2 commit ab25168
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
8 changes: 3 additions & 5 deletions mne/preprocessing/ecg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 6 additions & 7 deletions mne/preprocessing/ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ab25168

Please sign in to comment.