mne.
Annotations
(onset, duration, description, orig_time=None)[source]¶Annotation object for annotating segments of raw data.
Parameters: |
|
---|
Notes
Annotations are added to instance of mne.io.Raw
as the attribute
raw.annotations
.
To reject bad epochs using annotations, use annotation description starting with ‘bad’ keyword. The epochs with overlapping bad segments are then rejected automatically by default.
To remove epochs with blinks you can do:
>>> eog_events = mne.preprocessing.find_eog_events(raw) # doctest: +SKIP
>>> n_blinks = len(eog_events) # doctest: +SKIP
>>> onset = eog_events[:, 0] / raw.info['sfreq'] - 0.25 # doctest: +SKIP
>>> duration = np.repeat(0.5, n_blinks) # doctest: +SKIP
>>> description = ['bad blink'] * n_blinks # doctest: +SKIP
>>> annotations = mne.Annotations(onset, duration, description) # doctest: +SKIP
>>> raw.set_annotations(annotations) # doctest: +SKIP
>>> epochs = mne.Epochs(raw, events, event_id, tmin, tmax) # doctest: +SKIP
orig_time
If orig_time
is None, the annotations are synced to the start of the
data (0 seconds). Otherwise the annotations are synced to sample 0 and
raw.first_samp
is taken into account the same way as with events.
When setting annotations, the following alignments
between raw.info['meas_date']
and annotation.orig_time
take place:
----------- meas_date=XX, orig_time=YY -----------------------------
| +------------------+
|______________| RAW |
| | |
| +------------------+
meas_date first_samp
.
. | +------+
. |_________| ANOT |
. | | |
. | +------+
. orig_time onset[0]
.
| +------+
|___________________| |
| | |
| +------+
orig_time onset[0]'
----------- meas_date=XX, orig_time=None ---------------------------
| +------------------+
|______________| RAW |
| | |
| +------------------+
. N +------+
. o_________| ANOT |
. n | |
. e +------+
.
| +------+
|________________________| |
| | |
| +------+
orig_time onset[0]'
----------- meas_date=None, orig_time=YY ---------------------------
N +------------------+
o______________| RAW |
n | |
e +------------------+
| +------+
|_________| ANOT |
| | |
| +------+
[[[ CRASH ]]]
----------- meas_date=None, orig_time=None -------------------------
N +------------------+
o______________| RAW |
n | |
e +------------------+
. N +------+
. o_________| ANOT |
. n | |
. e +------+
.
N +------+
o________________________| |
n | |
e +------+
orig_time onset[0]'
Methods
__add__ (other) |
Add (concatencate) two Annotation objects. |
__hash__ ($self, /) |
Return hash(self). |
__len__ () |
Return the number of annotations. |
append (onset, duration, description) |
Add an annotated segment. |
copy () |
Return a deep copy of self. |
crop ([tmin, tmax, emit_warning]) |
Remove all annotation that are outside of [tmin, tmax]. |
delete (idx) |
Remove an annotation. |
save (fname) |
Save annotations to FIF, CSV or TXT. |
__hash__
($self, /)¶Return hash(self).
append
(onset, duration, description)[source]¶Add an annotated segment. Operates inplace.
Parameters: |
|
---|---|
Returns: |
|
crop
(tmin=None, tmax=None, emit_warning=False)[source]¶Remove all annotation that are outside of [tmin, tmax].
The method operates inplace.
Parameters: |
|
---|---|
Returns: |
|
delete
(idx)[source]¶Remove an annotation. Operates inplace.
Parameters: |
|
---|
save
(fname)[source]¶Save annotations to FIF, CSV or TXT.
Typically annotations get saved in the FIF file for raw data
(e.g., as raw.annotations
), but this offers the possibility
to also save them to disk separately in different file formats
which are easier to share between packages.
Parameters: |
|
---|