From 0f70809e7388efeb2555eb356baefceabeb04e8c Mon Sep 17 00:00:00 2001 From: Famous Date: Tue, 24 Feb 2026 19:35:27 +0530 Subject: [PATCH 1/6] DOC: document onset, duration, description, ch_names attrs of Annotations --- doc/changes/dev/12379.other.rst | 1 + mne/annotations.py | 80 +++++++++++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 doc/changes/dev/12379.other.rst diff --git a/doc/changes/dev/12379.other.rst b/doc/changes/dev/12379.other.rst new file mode 100644 index 00000000000..ce6a11f15a9 --- /dev/null +++ b/doc/changes/dev/12379.other.rst @@ -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 `Famous Raj Bhat`_. \ No newline at end of file diff --git a/mne/annotations.py b/mne/annotations.py index e298e80918c..678791b1347 100644 --- a/mne/annotations.py +++ b/mne/annotations.py @@ -405,15 +405,89 @@ def __init__( f"' '. Got: {orig_time}. Defaulting `orig_time` to None.", RuntimeWarning, ) - self.onset, self.duration, self.description, self.ch_names, self._extras = ( - _check_o_d_s_c_e(onset, duration, description, ch_names, 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 @property 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 = onset + + @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): From 31c138e42ed327b21124014222874fbd2584c231 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 14:11:11 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/annotations.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mne/annotations.py b/mne/annotations.py index 678791b1347..9989bb5dd0d 100644 --- a/mne/annotations.py +++ b/mne/annotations.py @@ -406,15 +406,15 @@ def __init__( RuntimeWarning, ) self._onset, self._duration, self._description, self._ch_names, self._extras = ( - _check_o_d_s_c_e(onset, duration, description, ch_names, extras) -) + _check_o_d_s_c_e(onset, duration, description, ch_names, extras) + ) self._sort() # ensure we're sorted @property def orig_time(self): """The time base of the Annotations.""" return self._orig_time - + @property def onset(self): """Onset of each annotation (in seconds). From 6cef5a60d9755d829c4b0aab1e6f84c075f1fa57 Mon Sep 17 00:00:00 2001 From: Famous Date: Tue, 24 Feb 2026 23:43:26 +0530 Subject: [PATCH 3/6] DOC: trigger CircleCI build From 0de9d786971df146d8ade9d5fb08da523fa655f1 Mon Sep 17 00:00:00 2001 From: Famous Date: Wed, 25 Feb 2026 00:00:23 +0530 Subject: [PATCH 4/6] DOC: add validation to onset, duration, description setters --- mne/annotations.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/mne/annotations.py b/mne/annotations.py index 9989bb5dd0d..60c58876e5c 100644 --- a/mne/annotations.py +++ b/mne/annotations.py @@ -433,8 +433,48 @@ def onset(self): @onset.setter def onset(self, onset): + onset = np.atleast_1d(np.array(onset, dtype=float)) + if len(onset) != len(self._duration): + raise ValueError( + f"onset length ({len(onset)}) must match " + f"duration length ({len(self._duration)})." + ) self._onset = onset + @property + def duration(self): + """Duration of each annotation (in seconds). + ... + """ + return self._duration + + @duration.setter + def duration(self, duration): + duration = np.atleast_1d(np.array(duration, dtype=float)) + if len(duration) != len(self._onset): + raise ValueError( + f"duration length ({len(duration)}) must match " + f"onset length ({len(self._onset)})." + ) + self._duration = duration + + @property + def description(self): + """Description of each annotation. + ... + """ + return self._description + + @description.setter + def description(self, description): + description = np.atleast_1d(np.array(description, dtype=str)) + if len(description) != len(self._onset): + raise ValueError( + f"description length ({len(description)}) must match " + f"onset length ({len(self._onset)})." + ) + self._description = description + @property def duration(self): """Duration of each annotation (in seconds). From bd5e6ab12efcc34adb0a77f4f1c6b4f22828b6ec Mon Sep 17 00:00:00 2001 From: Famous Date: Wed, 25 Feb 2026 12:07:28 +0530 Subject: [PATCH 5/6] DOC: remove length validation from setters to avoid internal conflicts --- mne/annotations.py | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/mne/annotations.py b/mne/annotations.py index 60c58876e5c..c014108d075 100644 --- a/mne/annotations.py +++ b/mne/annotations.py @@ -433,47 +433,7 @@ def onset(self): @onset.setter def onset(self, onset): - onset = np.atleast_1d(np.array(onset, dtype=float)) - if len(onset) != len(self._duration): - raise ValueError( - f"onset length ({len(onset)}) must match " - f"duration length ({len(self._duration)})." - ) - self._onset = onset - - @property - def duration(self): - """Duration of each annotation (in seconds). - ... - """ - return self._duration - - @duration.setter - def duration(self, duration): - duration = np.atleast_1d(np.array(duration, dtype=float)) - if len(duration) != len(self._onset): - raise ValueError( - f"duration length ({len(duration)}) must match " - f"onset length ({len(self._onset)})." - ) - self._duration = duration - - @property - def description(self): - """Description of each annotation. - ... - """ - return self._description - - @description.setter - def description(self, description): - description = np.atleast_1d(np.array(description, dtype=str)) - if len(description) != len(self._onset): - raise ValueError( - f"description length ({len(description)}) must match " - f"onset length ({len(self._onset)})." - ) - self._description = description + self._onset = np.atleast_1d(np.array(onset, dtype=float)) @property def duration(self): From 1edf047007fd27b77b1eba2edd58cd172cca8dfc Mon Sep 17 00:00:00 2001 From: Famous Date: Wed, 25 Feb 2026 13:24:23 +0530 Subject: [PATCH 6/6] DOC: fix contributor name format in changelog --- doc/changes/dev/12379.other.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/dev/12379.other.rst b/doc/changes/dev/12379.other.rst index ce6a11f15a9..eb16cb5e4a7 100644 --- a/doc/changes/dev/12379.other.rst +++ b/doc/changes/dev/12379.other.rst @@ -1 +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 `Famous Raj Bhat`_. \ No newline at end of file +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 `__. \ No newline at end of file