# Unify(stack) two EDF files

**URL:** https://mne.discourse.group/t/unify-stack-two-edf-files/7763
**Category:** Support & Discussions
**Tags:** preprocessing
**Created:** [October 30, 2023, 6:47am UTC](https://mne.discourse.group/t/unify-stack-two-edf-files/7763 "2023-10-30T06:47:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mishashev](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mishashev/32/3136_2.png) [@mishashev](https://mne.discourse.group/u/mishashev)
#### Post date: [October 30, 2023, 6:47am UTC](https://mne.discourse.group/t/unify-stack-two-edf-files/7763/1 "2023-10-30T06:47:29Z")

</div>

Dear MNE community! I have two EDF files with different channels, which belong to the same subject. I’d like to concatenate the files “horizontally” such that the result will be single file with all the channels from two EDF files and all the annotations from two EDF files.  
I’m considering writing code with pyEDFlib, to manually stack numpy arrays(signals) and merge annotations dictionaries. But before that I was wandering if MNE already put their hand on it 🙂 Thanks!!

---

<div class="post-metadata">

### Author: ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)
#### Post date: [October 30, 2023, 8:16am UTC](https://mne.discourse.group/t/unify-stack-two-edf-files/7763/2 "2023-10-30T08:16:37Z")

</div>

MNE has `mne.concatenate_raws()` for this purpose, but you need to take care that both data sets have the same set of channels. If your goal is to export a single EDF file with the combined signals, I think pyEDFlib is currently your best option.

---

<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: [October 30, 2023, 7:09pm UTC](https://mne.discourse.group/t/unify-stack-two-edf-files/7763/3 "2023-10-30T19:09:46Z")

</div>

I think actually you don’t want `concatenate_raws()` (which will not work if the channels are different) but rather `raw1.add_channels([raw2])`. Off the top of my head I don’t know if it handles annotations elegantly. If you try it, please report back if it worked or if you encountered difficulties.
