Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/dev/12379.other.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document :attr:`~mne.Annotations.onset`, :attr:`~mne.Annotations.duration`, :attr:`~mne.Annotations.description`, and :attr:`~mne.Annotations.ch_names` attributes of :class:`mne.Annotations`, by `Famous077 <https://github.com/Famous077>`__.
76 changes: 75 additions & 1 deletion mne/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def __init__(
f"' '. Got: {orig_time}. Defaulting `orig_time` to None.",
RuntimeWarning,
)
self.onset, self.duration, self.description, self.ch_names, self._extras = (
self._onset, self._duration, self._description, self._ch_names, self._extras = (
_check_o_d_s_c_e(onset, duration, description, ch_names, extras)
)
self._sort() # ensure we're sorted
Expand All @@ -415,6 +415,80 @@ def orig_time(self):
"""The time base of the Annotations."""
return self._orig_time

@property
def onset(self):
"""Onset of each annotation (in seconds).

Returns
-------
onset : array of shape (n_annotations,)
The onset of each annotation in seconds from the start of
the recording.

See Also
--------
duration, description
"""
return self._onset

@onset.setter
def onset(self, onset):
self._onset = np.atleast_1d(np.array(onset, dtype=float))

@property
def duration(self):
"""Duration of each annotation (in seconds).

Returns
-------
duration : array of shape (n_annotations,)
The duration of each annotation in seconds.

See Also
--------
onset, description
"""
return self._duration

@duration.setter
def duration(self, duration):
self._duration = duration

@property
def description(self):
"""Description of each annotation.

Returns
-------
description : array of shape (n_annotations,)
A string description for each annotation (e.g., event
label or condition name).

See Also
--------
onset, duration
"""
return self._description

@description.setter
def description(self, description):
self._description = description

@property
def ch_names(self):
"""Channel names associated with each annotation.

Returns
-------
ch_names : list of tuple
Channel names associated with each annotation.
"""
return self._ch_names

@ch_names.setter
def ch_names(self, ch_names):
self._ch_names = ch_names

@property
def extras(self):
"""The extras of the Annotations.
Expand Down