mne.io.read_raw_bdf#
- mne.io.read_raw_bdf(input_fname, eog=None, misc=None, stim_channel='auto', exclude=(), infer_types=False, include=None, preload=False, units=None, encoding='utf8', *, verbose=None)[source]#
Reader function for BDF files.
- Parameters:
- input_fnamepath-like
Path to the BDF file.
- eog
list
ortuple
Names of channels or list of indices that should be designated EOG channels. Values should correspond to the electrodes in the file. Default is None.
- misc
list
ortuple
Names of channels or list of indices that should be designated MISC channels. Values should correspond to the electrodes in the file. Default is None.
- stim_channel
'auto'
|str
|list
ofstr
|int
|list
ofint
Defaults to
'auto'
, which means that channels named'status'
or'trigger'
(case insensitive) are set to STIM. If str (or list of str), all channels matching the name(s) are set to STIM. If int (or list of ints), channels corresponding to the indices are set to STIM.- exclude
list
ofstr
|str
Channel names to exclude. This can help when reading data with different sampling rates to avoid unnecessary resampling. A str is interpreted as a regular expression.
- infer_types
bool
If True, try to infer channel types from channel labels. If a channel label starts with a known type (such as ‘EEG’) followed by a space and a name (such as ‘Fp1’), the channel type will be set accordingly, and the channel will be renamed to the original label without the prefix. For unknown prefixes, the type will be ‘EEG’ and the name will not be modified. If False, do not infer types and assume all channels are of type ‘EEG’.
New in version 0.24.1.
- include
list
ofstr
|str
Channel names to be included. A str is interpreted as a regular expression. ‘exclude’ must be empty if include is assigned.
New in version 1.1.
- preload
bool
orstr
(defaultFalse
) Preload data into memory for data manipulation and faster indexing. If True, the data will be preloaded into memory (fast, requires large amount of memory). If preload is a string, preload is the file name of a memory-mapped file which is used to store the data on the hard drive (slower, requires less memory).
- units
dict
|str
The units of the channels as stored in the file. This argument is useful only if the units are missing from the original file. If a dict, it must map a channel name to its unit, and if str it is assumed that all channels have the same units.
- encoding
str
Encoding of annotations channel(s). Default is “utf8” (the only correct encoding according to the EDF+ standard).
- verbose
bool
|str
|int
|None
Control verbosity of the logging output. If
None
, use the default verbosity level. See the logging documentation andmne.verbose()
for details. Should only be passed as a keyword argument.
- Returns:
- rawinstance of RawEDF
The raw instance. See
mne.io.Raw
for documentation of attributes and methods.
See also
mne.io.read_raw_edf
Reader function for EDF and EDF+ files.
mne.io.read_raw_gdf
Reader function for GDF files.
mne.io.Raw
Documentation of attributes and methods of RawEDF.
Notes
Biosemi devices trigger codes are encoded in 16-bit format, whereas system codes (CMS in/out-of range, battery low, etc.) are coded in bits 16-23 of the status channel (see http://www.biosemi.com/faq/trigger_signals.htm). To retrieve correct event values (bits 1-16), one could do:
>>> events = mne.find_events(...) >>> events[:, 2] &= (2**16 - 1)
The above operation can be carried out directly in
mne.find_events()
using themask
andmask_type
parameters (seemne.find_events()
for more details).It is also possible to retrieve system codes, but no particular effort has been made to decode these in MNE. In case it is necessary, for instance to check the CMS bit, the following operation can be carried out:
>>> cms_bit = 20 >>> cms_high = (events[:, 2] & (1 << cms_bit)) != 0
It is worth noting that in some special cases, it may be necessary to shift event values in order to retrieve correct event triggers. This depends on the triggering device used to perform the synchronization. For instance, in some files events need to be shifted by 8 bits:
>>> events[:, 2] >>= 8
TAL channels called ‘BDF Annotations’ are parsed and extracted annotations are stored in raw.annotations. Use
mne.events_from_annotations()
to obtain events from these annotations.If channels named ‘status’ or ‘trigger’ are present, they are considered as STIM channels by default. Use func:
mne.find_events
to parse events encoded in such analog stim channels.
Examples using mne.io.read_raw_bdf
#
Importing data from EEG devices