Time-shift epochs per epoch individually

Hi! I have epoched and cleaned data which at the moment is stimulus-locked. What I would like to do now is to make the data response-locked. Because the epochs have been cleaned already, I would like to not go back to the raw data to make new epochs. Rather, I’m looking into options to time-shift the current epoch dataset so it is centered around the response instead of the stimulus.

In the metadata file I have the information of the reaction times of each epoch. My question is: is it possible to time-shift each epoch individually? I am able to change one epoch, but then it doesn’t save.

For example, for the first epoch:
epochs_cor[0].shift_time(epochs_cor.metadata[‘RT’].iloc[0], relative=True)

Another approach could be to remake the epochs based on the events datastructure. Is that perhaps also a possibility?

  • MNE version: 1.1
  • operating system: Windows 10

Hello,

what does that mean?

Creating fresh epochs time-locked to the response event the easiest and cleanest approach IMHO, so I’d suggest you go this route if you can.

Best wishes,
Richard

Hi, thanks for the response!

What I mean with that it doesn’t save, is that there is no in place modification of the epoch after the following line of code:
epochs_cor[0].shift_time(epochs_cor.metadata[‘RT’].iloc[0], relative=True)

Creating fresh epochs would be incredibly time-consuming though since I have done all the pre-processing on epoched data. So to keep it consistent I would have to re-run the whole pre-processing pipeline (including autocorrect) with response-locked instead of stimulus-locked data. What I meant with that line is that I am able to change the events datastructure of the epochs file, is there a way then to re-map the epochs themselves to the new events datastructure.

Indexing epochs like this (epochs_cor[0]) creates a copy, so you’re operating on a copy and not on the original data.

You could loop over your epochs one by one, apply shift_time(), crop all epochs to the same time range, and concatenate them again into a single epochs object via mne.concatenate_epochs().

Good luck,
Richard

2 Likes