mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.72k stars 1.32k forks source link

Missing documentation for onset, duration, description attributes in Annotations class? #12379

Open scott-huberty opened 9 months ago

scott-huberty commented 9 months ago

Proposed documentation enhancement

A colleague of mine who is a bit of an MNE power user had no idea that you can do something like raw.annotations.onset to retrieve an array of the onsets of all individual annotations:

import mne

annot = mne.Annotations(onset=[1, 3, 5], duration=[1, 1, 1], description=['a', 'b', 'c'])
annot.onset 
# array([1., 3., 5.])

As far as I can tell we don't document the onset, duration, description attributes in the API documentation. Should we?

larsoner commented 9 months ago

Yeah we could add them. I think we get them for free (maybe?) if we do:

def __init__(self, ...)
    ...
    self._onset, self._duration, ... = ...

@property
def onset(self):
    """..."""
    return self._onset

@onset.setter
def onset(self, onset)
    self._onset[:] = onset

Or something like this

scott-huberty commented 9 months ago

Ok I'll test it out and open a PR when I have some time.

hoechenberger commented 9 months ago

(Still thinking these should all be pluralized but this is a different discussion I suppose)