question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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:

  • units (#8473)
  • start, stop (in samples)
  • reject_by_annotation

What do you think?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rob-lukecommented, Jul 10, 2021

+1 for adding tmin and tmax. epochs.get_data()[..., idxs[0]:idxs[1]] is difficult to explain to a new user.

0reactions
hoechenbergercommented, Jul 10, 2021

, unless you (and others) think that it’d still be good to add tmin and tmax to *.get_data().

I’d be in favor of having tmin and tmax params 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found