# Convert epochs dataframe to epochs object

**URL:** <https://mne.discourse.group/t/convert-epochs-dataframe-to-epochs-object/5397>\
**Category:** Support & Discussions\
**Tags:** eeg, epochs\
**Created:** [August 9, 2022, 3:31pm UTC](https://mne.discourse.group/t/convert-epochs-dataframe-to-epochs-object/5397 "2022-08-09T15:31:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![isabelceo](https://avatars.discourse-cdn.com/v4/letter/i/3e96dc/32.png) [@isabelceo](https://mne.discourse.group/u/isabelceo)\
**Post date:** [August 9, 2022, 3:31pm UTC](https://mne.discourse.group/t/convert-epochs-dataframe-to-epochs-object/5397/1 "2022-08-09T15:31:47Z")

</div>

Hi MNE

I had to convert my epochs to dataframe in order to make an operation, but now a I want to convert again to epochs form with already did. is there a eay way? of do I have to creat the epochs again as show in the example [Creating MNE objects from data arrays — MNE 0.15 documentation](https://mne.tools/0.15/auto_examples/io/plot_objects_from_arrays.html?highlight=evoke%20array)?

- MNE version: e.g. 0.24.0
- operating system: Windows 10

Thank you

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [August 10, 2022, 2:42pm UTC](https://mne.discourse.group/t/convert-epochs-dataframe-to-epochs-object/5397/2 "2022-08-10T14:42:21Z")

</div>

As far as I know, that is not easy, and using `EpochsArray` would be the way to approach it. Probably _much_ easier is finding a way to do your operation _without converting to DataFrame_, probably using [epochs.apply\_function()](https://mne.tools/stable/generated/mne.Epochs.html#mne.Epochs.apply_function). Can you tell us more about what this operation is that you needed to perform on the data? We might be able to help you figure out how to do it using `apply_function()`.

Side note: you’re linking to documentation of **MNE version 0.15.** That was released in 2017, **more than 5 years ago.** If you are _actually using_ version 0.15, _please please please_ [update to the latest stable version](https://mne.tools/stable/install/updating.html).

---

<div class="post-metadata">

**Author:** ![isabelceo](https://avatars.discourse-cdn.com/v4/letter/i/3e96dc/32.png) [@isabelceo](https://mne.discourse.group/u/isabelceo)\
**Post date:** [August 10, 2022, 3:49pm UTC](https://mne.discourse.group/t/convert-epochs-dataframe-to-epochs-object/5397/3 "2022-08-10T15:49:28Z")

</div>

I convert to dataframe because I need to do a permutation, in order to obtain the p-value, an then thresholding the epochs data with values less than 0.05, according to pvalue. I already have the thresholding of the epochs, but for me I’ve been difficult to return into epochs as object. However, I don’t know if i could do this process without dataframe method.

Thank you in advance

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [August 11, 2022, 2:49pm UTC](https://mne.discourse.group/t/convert-epochs-dataframe-to-epochs-object/5397/4 "2022-08-11T14:49:06Z")

</div>

Hmm, OK. Doing a permutation might not be possible with `epochs.apply_function()` but it depends on exactly what you’re permuting… if you’re shuffling _time points_ it might work, but if you’re shuffling _epoch conditions_ then probably not. Can you clarify? (or better yet, provide reproducible example code?)

---

<div class="post-metadata">

**Author:** ![isabelceo](https://avatars.discourse-cdn.com/v4/letter/i/3e96dc/32.png) [@isabelceo](https://mne.discourse.group/u/isabelceo)\
**Post date:** [August 16, 2022, 3:29pm UTC](https://mne.discourse.group/t/convert-epochs-dataframe-to-epochs-object/5397/5 "2022-08-16T15:29:25Z")

</div>

Dear Dan,  
I already solved my problem with X=epochs.get\_data() and X= [:,:,0], I used the example of permutation\_t\_test.  
Thank you for you help.  
Greetings
