mne.read_annotations#
- mne.read_annotations(fname, sfreq='auto', uint16_codec=None, encoding='utf8', ignore_marker_types=False) Annotations [source]#
Read annotations from a file.
This function reads a
.fif
,.fif.gz
,.vmrk
,.amrk
,.edf
,.txt
,.csv
,.cnt
,.cef
, or.set
file and makes anmne.Annotations
object.- Parameters:
- fnamepath-like
The filename.
- sfreq
float
|'auto'
The sampling frequency in the file. This parameter is necessary for *.vmrk, *.amrk, and *.cef files as Annotations are expressed in seconds and *.vmrk/*.amrk/*.cef files are in samples. For any other file format,
sfreq
is omitted. If set to ‘auto’ then thesfreq
is taken from the respective info file of the same name with according file extension (*.vhdr/*.ahdr for brainvision; *.dap for Curry 7; *.cdt.dpa for Curry 8). So data.vmrk/amrk looks for sfreq in data.vhdr/ahdr, data.cef looks in data.dap and data.cdt.cef looks in data.cdt.dpa.- uint16_codec
str
|None
This parameter is only used in EEGLAB (*.set) and omitted otherwise. If your *.set file contains non-ascii characters, sometimes reading it may fail and give rise to error message stating that “buffer is too small”.
uint16_codec
allows to specify what codec (for example:'latin1'
or'utf-8'
) should be used when reading character arrays and can therefore help you solve this problem.- encoding
str
Encoding of annotations channel(s). Default is “utf8” (the only correct encoding according to the EDF+ standard). Only used when reading EDF annotations.
- ignore_marker_typesbool
If
True
, ignore marker types in BrainVision files (and only use their descriptions). Defaults toFalse
.
- Returns:
- annotinstance of
Annotations
The annotations.
- annotinstance of
Notes
The annotations stored in a
.csv
require the onset columns to be timestamps. If you have onsets as floats (in seconds), you should use the.txt
extension.
Examples using mne.read_annotations
#
Sleep stage classification from polysomnography (PSG) data