Is there epochs.set_data() function?

Dear MNE users,

I used the function as follows,

epochs = mne.make_fixed_length_epochs(raw, duration=1, preload=False, overlap=0.8)

Then, I can get epoched data using
epoched_data = epochs.get_data()
epoched_data (1531, 19, 250)

I want to do some signal processing with epoched_data, but I do not know how to push back epoched_data to the original epochs structure. Is there any function like epochs.set_data()?

Best,
Kyu

Hello @kyuwanchoi,

you can use epoched_data.apply_function(...)

Best wishes,
Richard

Hi Richard, thanks for your support! My goal is to enter epoched_data into the original epochs. In this case, how can I use the apply_function?

I tried the code as follow, but it does not work

epochs.apply_function(epoched_data)

Hello, sorry, that was a typo; of course, the correct call is epochs.apply_function(…)

The trick here is that you pass a function to apply_function; this function will retrieve the data, can apply transformations, and needs to return the transformed data. Then, apply_function will take this result and replace the existing data in epochs with the transformed data. That way, you don’t have to manually first extract the data, transform it, and then somehow squeeze it back into your epochs (which is what you’ve been trying to do so far — it’s error-prone and can be difficult!)

I’m afraid currently there are no examples for this method in our documentation, but the API docs I linked to above should contain all the information you need.

Let me know how it goes for you!

Best wishes,
Richard