mne-tools / mne-python

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

ENH: EpochsArray #1272

Closed dengemann closed 10 years ago

dengemann commented 10 years ago

like RawArray but from 3D data cc @fraimondo @agramfort @Eric89GXL

larsoner commented 10 years ago

Should be very straightforward given the RawArray class and info-creation tool. +1

dengemann commented 10 years ago

If I'm not mistaken @fraimondo is hacking on this right now (just 5 meters away from my desk) ;-)

fraimondo commented 10 years ago
class EpochsArray(mne.epochs.Epochs):

    def __init__(self, data, info, events, event_id=None, time0=0):
        self.info = info
        self._data = data
        if event_id is None:  # convert to int to make typing-checks happy
            event_id = dict((str(e), int(e)) for e in np.unique(events[:, 2]))
        self.event_id = event_id
        self.events = events
        self.proj = None
        self.baseline = None
        self.preload = True
        self.reject = None
        self.decim = 0
        self.raw = None
        self.drop_log = []
        self.drop = True
        self.selection = np.arange(0, self.info['nchan'])
        self.picks = _check_type_picks(list(range(len(self.info['ch_names']))))
        self.times = np.arange(0, data.shape[2], dtype=np.float) / \
                     info['sfreq'] + time0
        self.tmin = self.times[0]
        self.tmax = self.times[-1]

This first draft looks like it works: saving, averaging, plotting.

dengemann commented 10 years ago

PR welcome!!!

We should briefly discuss the API. I would rename time0 t_zero or so. Apart from that the parameters make sense to me. A question is whether we can allow for other than preloaded / preprocessed data. Would actually be lovely to be able to use this constructor with unprocessed data. This would mean, however, to add the reject api and to declare somehow at the beginning whether the data is dropped / to be rejected or not.

Any thoughts @Eric89GXL @mluessi @agramfort ?

larsoner commented 10 years ago

I think tmin would be most appropriate, since that's used elsewhere. There could just be a reject=None parameter that, if it's not None, does rejection. (same with flat). Or even better, to avoid parameter bloat, just add a method for this class like reject(eeg=100e-6, ...) or something.

dengemann commented 10 years ago

I think tmin ...

yes indeed.

There could just be a reject=None parameter that, if it's not None, does rejection.

Yes.

@fraimondo PR? ^^

agramfort commented 10 years ago

+1 for the PR