Is there a way to pad data after using raw.resample?

:question: If you have a question or issue with MNE-Python, please include the following info:

  • MNE version: e.g. 1.8
  • Windows 10

I’m not sure if I need to add code for this, since this is a more general question, but let me know if I should share some code!

I’m working with some pretty big data sets, so resampling the data saves me a lot of time. However, when I resample prior to anything else in the preprocessing routine, I of course run into the expected issue of my epochs being too short and therefore dropped. Is there a way to pad the data after resampling? I realize that raw.resample includes some padding calls, but as far as I’ve read, those are only temporary. Please correct me if I’m wrong! Any advice here regarding speeding up processing is greatly appreciated, and again, happy to share code if needed.

A little code example would help, yes, so here I’m just guessing. If you do not have enough data before the first and after the last event of interest, these epochs will be dropped. Did you extract events before or after downsampling? If you used mne.find_events() before downsampling, you will have to adjust your events (or extract them after downsampling). If your events are based on annotations though, I think these should automatically be downsampled as well.

1 Like

this is why you can pass your events array to raw.resample like this:

resampled_raw, resampled_events = raw.resample(new_sfreq, events=events)
3 Likes

Ah yes, but if there’s not enough data then epochs will still be dropped as I’ve mentioned.

1 Like

Ohhhhh! This makes a lot of sense. I switched to downsampling before loading the events and that fixed everything. Thank you so much!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.