mne_bids.mark_channels#

mne_bids.mark_channels(bids_path, *, ch_names, status, descriptions=None, verbose=None)[source]#

Update status and description of channels in an existing BIDS dataset.

Parameters:
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.

ch_namesstr | list of str

The name(s) of the channel(s) to mark with a status (and optionally a description). The special value "all" will mark all channels.

Changed in version 0.16: The behavior of passing an empty list will change in version 0.17. In version 0.16 and older, an empty list would mark all channels. In version 0.17 and newer, an empty list will be a no-op (no channels will be marked/changed).

status‘good’ | ‘bad’ | list of str

The status of the channels (‘good’, or ‘bad’). If it is a list, then must be a list of ‘good’, or ‘bad’ that has the same length as ch_names.

descriptionsNone | str | list of str

Descriptions of the reasons that lead to the marking (‘good’ or ‘bad’) of the channel(s). If a list, it must match the length of ch_names. If None, no descriptions are added.

verbosebool | str | int | None

Control verbosity of the logging output. If None, use the default verbosity level. See the logging documentation and mne.verbose() for details. Should only be passed as a keyword argument.

Notes

If the ‘status’ or ‘status_description’ columns were not present in the corresponding tsv file before using this function, they may be created with default values (‘good’ for status, ‘n/a’ for status_description) for all channels that are not differently specified (by using ch_names, status, and descriptions).

Examples

Mark a single channel as bad.

>>> root = Path('./mne_bids/tests/data/tiny_bids').absolute()
>>> bids_path = BIDSPath(subject='01', task='rest', session='eeg',
...                      datatype='eeg', root=root)
>>> mark_channels(bids_path=bids_path, ch_names='C4', status='bad',
...               verbose=False)

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

>>> bads = ['C3', 'PO10']
>>> descriptions = ['very noisy', 'continuously flat']
>>> mark_channels(bids_path, ch_names=bads, status='bad',
...               descriptions=descriptions, verbose=False)

Mark all channels with a new description, while keeping them as a “good” channel.

>>> descriptions = ['resected', 'resected']
>>> mark_channels(bids_path=bids_path, ch_names=['C3', 'C4'],
...               descriptions=descriptions, status='good',
...               verbose=False)

Examples using mne_bids.mark_channels#

03. Interactive data inspection and bad channel selection

03. Interactive data inspection and bad channel selection