Skip to content

ENH: [raw|epochs|evoked].get_data() specify tmin, tmax in seconds to get that segment #9548

@sappelhoff

Description

@sappelhoff

I 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:

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions