excluding bad epochs after autoreject and saving the file

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’?

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.

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