# Concatenating Epochs objects in Python?

**URL:** <https://mne.discourse.group/t/concatenating-epochs-objects-in-python/705>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [April 3, 2014, 1:42pm UTC](https://mne.discourse.group/t/concatenating-epochs-objects-in-python/705 "2014-04-03T13:42:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 3, 2014, 1:42pm UTC](https://mne.discourse.group/t/concatenating-epochs-objects-in-python/705/1 "2014-04-03T13:42:22Z")

</div>

Hi,

Is it possible to concatenate multiple Epochs objects in Python? For  
example, if I load one raw fif file and create an object (let's call it  
epochs1) with three epochs A, B, and C, and then I load another raw fif  
file and create epochs2 with three epochs D, E, and F, what I would like to  
do is combine them into a single object with six epochs A, B, C, D, E, F.

I can't find a method for this in the reference and all I see online is  
this github discussion  
[https://github.com/mne-tools/mne-python/issues/120where](https://github.com/mne-tools/mne-python/issues/120where) it seems like  
this was ultimately not done. Loading multiple raw fif  
files is not a good option for me because my files are very large and I  
don't have the memory to handle it. I suppose another thing I could do is  
load one raw fif file at a time and save its epochs to a new fif file, and  
then load the separate epoched .fif files together (if mne.read\_epochs  
allows this) but I am hoping to avoid saving a bunch of files, I'd rather  
just create and concatenate the epochs on the fly if that is possible.

Thank you,  
Steve

Stephen Politzer-Ahles  
New York University, Abu Dhabi  
Neuroscience of Language Lab  
[http://www.nyu.edu/projects/politzer-ahles/](http://www.nyu.edu/projects/politzer-ahles/)  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20140403/01480b6d/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140403/01480b6d/attachment.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 3, 2014, 2:12pm UTC](https://mne.discourse.group/t/concatenating-epochs-objects-in-python/705/2 "2014-04-03T14:12:06Z")

</div>

Hi Steve,

Yes, you are right, concatenating Epochs is currently not supported.  
Unless you use "preload=True", it won't actually load the data of the  
raw file when creating a Raw object. So you should be able to just use a  
list of file names when creating Raw and it should work.

The only time you need "preload=True" is when you want to modify the raw  
data, e.g., using filtering. In this case, you could load each raw file,  
filter it, save it, and then create a new Raw instance that combines all  
the files. Like that, you will only need enough RAM to have a single raw  
file fully loaded.

HTH,

Martin

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 3, 2014, 2:20pm UTC](https://mne.discourse.group/t/concatenating-epochs-objects-in-python/705/3 "2014-04-03T14:20:29Z")

</div>

Thanks for the input! I do indeed need to do some filtering as well, so I  
guess in this case saving extra raw [filtered] files will be unavoidable.

Thanks,  
Steve

Stephen Politzer-Ahles  
New York University, Abu Dhabi  
Neuroscience of Language Lab  
[http://www.nyu.edu/projects/politzer-ahles/](http://www.nyu.edu/projects/politzer-ahles/)
