ENH: [raw|epochs|evoked].get_data() specify tmin, tmax in seconds to get that segment
See original GitHub issueI often find myself wanting data from epochs in a certain time window, such as from -0.1 to 0.3 seconds. I don’t want to look at epochs.times
and compute the corresponding sample index every time, so I usually do something like epochs.copy().crop(tmin, tmax).get_data()
. But copying the epochs is of course memory (and time) intensive.
I suggest we add two new parameters to the get_data
method for raw, epochs, and evoked (evoked still needs the get_data method to be implemented, see #9244): tstart
and tstop
(or tmin
, and tmax
)
The get_data
method for raw already has start
and stop
parameters, based on sample indices. The corresponding tstart
/tstop
params would operate the same way, but in seconds.
Adding something like tstart
and tstop
(in seconds) would also mean that we should add a return_times=True|False
parameter to the epochs.get_data (and evoked.get_data, once we have it). That param is already there for raw.
Finally, maybe this would be a good opportunity to make the get_data
interface equal between raw, epochs, and evoked.
epochs and evoked would then need to get the following that are already present in raw:
- units (#8473)
- start, stop (in samples)
- reject_by_annotation
What do you think?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
+1 for adding tmin and tmax.
epochs.get_data()[..., idxs[0]:idxs[1]]
is difficult to explain to a new user.I’d be in favor of having
tmin
andtmax
params 😃