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_names
str
|list
ofstr
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.- descriptions
None
|str
|list
ofstr
Descriptions of the reasons that lead to the exclusion of the channel(s). If a list, it must match the length of
ch_names
. IfNone
, no descriptions are added.- bids_path
mne_bids.BIDSPath
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 viach_names
, and leave the rest untouched. IfTrue
, update the information of all channels: mark the channels passed viach_names
as bad, and all remaining channels as good, also discarding their descriptions.- verbosebool
The verbosity level.
- ch_names
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_bad_channels('C4', bids_path=bids_path, verbose=False) Processing channel C4: status: bad description: n/a
Mark multiple channels as bad, and add a description as to why.
>>> bads = ['C3', 'PO10'] >>> descriptions = ['very noisy', 'continuously flat'] >>> mark_bad_channels(bads, descriptions, bids_path=bids_path, ... verbose=False) Processing channel C3: status: bad description: very noisy Processing channel PO10: status: bad description: continuously flat
Mark two channels as bad, and mark all others as good by setting
overwrite=True
.>>> bads = ['C3', 'C4'] >>> mark_bad_channels(bads, bids_path=bids_path, ... overwrite=True, verbose=False)
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, ... verbose=False) Resetting status and description for all channels.