mne_bids.mark_bad_channels

mne_bids.mark_bad_channels(ch_names, descriptions=None, *, bids_path, overwrite=False, verbose=True)[source]

Update which channels are marked as “bad” in an existing BIDS dataset.

Parameters
ch_namesstr | list of str

The names of the channel(s) to mark as bad. Pass an empty list in combination with overwrite=True to mark all channels as good.

descriptionsNone | str | list of str

Descriptions of the reasons that lead to the exclusion of the channel(s). If a list, it must match the length of ch_names. If None, no descriptions are added.

bids_pathBIDSPath

The recording to update. The mne_bids.BIDSPath instance passed here must have the .root attribute set. The .datatype attribute may be set. If .datatype is not set and only one data type (e.g., only EEG or MEG data) is present in the dataset, it will be selected automatically.

overwritebool

If False, only update the information of the channels passed via ch_names, and leave the rest untouched. If True, update the information of all channels: mark the channels passed via ch_names as bad, and all remaining channels as good, also discarding their descriptions.

verbosebool

The verbosity level.

Examples

Mark a single channel as bad.

>>> mark_bad_channels('MEG 0112', bids_path=bids_path)

Mark multiple channels as bad.

>>> bads = ['MEG 0112', 'MEG 0131']
>>> mark_bad_channels(bads, bids_path=bids_path)

Mark channels as bad, and add a description as to why.

>>> ch_names = ['MEG 0112', 'MEG 0131']
>>> descriptions = ['Only produced noise', 'Continuously flat']
>>> mark_bad_channels(bads, descriptions, bbids_path=bids_path)

Mark two channels as bad, and mark all others as good by setting overwrite=True.

>>> bads = ['MEG 0112', 'MEG 0131']
>>> mark_bad_channels(bads, bids_path=bids_path, overwrite=True)

Mark all channels as good by passing an empty list of bad channels, and setting overwrite=True.

>>> mark_bad_channels([], bids_path=bids_path, overwrite=True)

Examples using mne_bids.mark_bad_channels