# excluding bad epochs after autoreject and saving the file

**URL:** <https://mne.discourse.group/t/excluding-bad-epochs-after-autoreject-and-saving-the-file/3664>\
**Category:** Support & Discussions\
**Tags:** eeg, epochs, autoreject\
**Created:** [September 7, 2021, 5:08am UTC](https://mne.discourse.group/t/excluding-bad-epochs-after-autoreject-and-saving-the-file/3664 "2021-09-07T05:08:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![apoorva6262](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@apoorva6262](https://mne.discourse.group/u/apoorva6262)\
**Post date:** [September 7, 2021, 5:08am UTC](https://mne.discourse.group/t/excluding-bad-epochs-after-autoreject-and-saving-the-file/3664/1 "2021-09-07T05:08:43Z")

</div>

Hi,

I am working on this EEG data where I have epoched the data and ran autoreject (global). However, there are still some epochs that are noisy. So I annotated/marked them as ‘bad\_epochs’ on the plot. Now, how do I save this file to include only the ‘good\_epochs’?

```python
epochs = mne.make_fixed_length_epochs(raw_set, duration=1, preload=True)
reject = autoreject.get_rejection_threshold(epochs)
ar = autoreject.AutoReject(n_interpolate=[1,2,3,4], random_state=11,
                           n_jobs=1, verbose='tqdm')
ar.fit(epochs) 
epochs_ar, reject_log = ar.transform(epochs, return_log=True)
epochs[reject_log.bad_epochs].plot(scalings=dict(eeg=1e-4))
epochs_ar.plot()

```

Thanks,  
Apoorva.

---

<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:** [September 7, 2021, 7:23am UTC](https://mne.discourse.group/t/excluding-bad-epochs-after-autoreject-and-saving-the-file/3664/2 "2021-09-07T07:23:27Z")

</div>

Hello @apoorva6262,

after marking epochs as bad in the plot window and closing the plot, these epochs are automatically removed. Simply save the epochs to disk and you’ll be fine.

Best wishes,  
Richard
