# Is there epochs.set\_data() function?

**URL:** <https://mne.discourse.group/t/is-there-epochs-set-data-function/3839>\
**Category:** Support & Discussions\
**Tags:** epochs\
**Created:** [October 20, 2021, 6:37pm UTC](https://mne.discourse.group/t/is-there-epochs-set-data-function/3839 "2021-10-20T18:37:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyuwanchoi](https://avatars.discourse-cdn.com/v4/letter/k/a698b9/32.png) [@kyuwanchoi](https://mne.discourse.group/u/kyuwanchoi)\
**Post date:** [October 20, 2021, 6:37pm UTC](https://mne.discourse.group/t/is-there-epochs-set-data-function/3839/1 "2021-10-20T18:37:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 20, 2021, 7:07pm UTC](https://mne.discourse.group/t/is-there-epochs-set-data-function/3839/2 "2021-10-20T19:07:55Z")

</div>

Hello @kyuwanchoi,

you can use [`epoched_data.apply_function(...)`](https://mne.tools/stable/generated/mne.Epochs.html#mne.Epochs.apply_function)

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![kyuwanchoi](https://avatars.discourse-cdn.com/v4/letter/k/a698b9/32.png) [@kyuwanchoi](https://mne.discourse.group/u/kyuwanchoi)\
**Post date:** [October 20, 2021, 7:30pm UTC](https://mne.discourse.group/t/is-there-epochs-set-data-function/3839/3 "2021-10-20T19:30:47Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 21, 2021, 7:32am UTC](https://mne.discourse.group/t/is-there-epochs-set-data-function/3839/4 "2021-10-21T07:32:53Z")

</div>

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
