How do I set a good threshold for EMG?

Hi!
In this code, I found the 2 EMG channels from the FilteredData, and saved them in Raw_subset, then I epoched the Raw_subset (epochs_emg1). I want to find the epochs with EMG activity, and drop those epochs because during the task, the participants were required to imagine hand movement, so I want to drop the epochs they had actual movement.
The current reject and flat criteria, I have in this code, is not reliable because when I plot epochs_emg1, I can see some epochs with EMG that they were not selected or epochs without EMG being selected. How can I find a reliable reject and flat criteria for detecting epochs with EMG activity?

vemg_ch_right = 'VEMG_right'
vemg_ch_left= 'VEMG_left'
channels_to_plot = ['VEMG_right','VEMG_left']

mne.set_bipolar_reference(FilteredData,
                    anode='EXG3',
                    cathode='EXG4',
                    ch_name=vemg_ch_left,
                    drop_refs=False,  
                    copy=False)
mne.set_bipolar_reference(FilteredData,
                    anode='EXG5',
                    cathode='EXG6',
                    ch_name=vemg_ch_right, 
                    drop_refs=False,  
                    copy=False)

#Raw_subset contains the data for 2 EMG channels one for the right hand and one for the left hand.

Raw_subset = FilteredData.copy().pick_channels(channels_to_plot)

Raw_subset.set_channel_types({'VEMG_right' :'eeg' , 'VEMG_left' : 'eeg'})

epochs_emg1 = mne.Epochs(Raw_subset, events=imr_events_np, tmin=-1.0, tmax=7.5, event_id={'imr':event_dict['imr']},
                    baseline=None, preload=True)
 
indexes_before_criteria1 = epochs_emg1.selection


reject_criteria = dict(eeg=1e-3)
flat_criteria = dict(eeg=0)

epochs_emg1_criteria = mne.Epochs(Raw_subset, events=imr_events_np, tmin=-1.0, tmax=7.5, event_id={'imr':event_dict['imr']}, reject= reject_criteria, flat= flat_criteria, baseline=None, preload=True)

epochs_emg1_criteria.drop_bad()

# Get indexes of epochs after applying criteria
indexes_after_criteria1 = epochs_emg1_criteria.selection


Hi, you should change the channel type of the EMG channels to emg and then set a reject threshold for those channels when creating your epochs.

Best wishes,
Richard