when I use mne.Epochs(),I got wrong time samples number

  • MNE version: e.g. 1.6.0
  • operating system: Windows 11
    when I run 250hz & 0~4.5s mne.Epochs,I cant get correct time samples number,In this line epochs['feet'].get_data()I should get(epochs,chanlles,1125),but I got(epochs,chanlles,1126).I cant understand the reason about these error If you know how to fix this error I will very gratitude.
raw_gdf = mne.io.read_raw_edf(path+'/train/'+str(subject_id)+'.edf', preload=True)

    electrode_channels = ['EEG FCz','EEG FT8','EEG P7','EEG Pz','EEG O1','EEG Fp2','EEG F3','EEG FT7','EEG T8','EEG TP8','EEG PO8','EEG Oz',
     'EEG C3','EEG Cz','EEG C4','EEG CP3','EEG CPz','EEG CP4','EEG Fz','EEG F1','EEG F2','EEG F3',
    'EEG F4','EEG FC3','EEG FC4','EEG T7','EEG T8','EEG P3','EEG P4']
    raw_gdf.pick_channels(electrode_channels)
    raw_gdf.filter(l_freq=4, h_freq=36)
    raw_gdf.resample(sfreq=250)
    tmin = 0
    tmax  = 4.5
    events, event_dict = mne.events_from_annotations(raw_gdf, verbose=False)
    epochs = mne.Epochs(raw_gdf, events, event_id=event_dict, tmin=tmin, tmax=tmax, reject_by_annotation=True, proj=True,
                        baseline=(0, 0), preload=True, detrend=None, verbose=True, event_repeated='merge'
                        )
    feet_data = epochs['feet'].get_data()

Since both tmin and tmax are inclusive, you get exactly (4.5 - 0) * 250 + 1 samples. This is like saying you want all integers from 0 to 10, which results in 11 numbers. If you want epochs with 1125 samples, you could use tmax=4.5 - 1/sfreq.

1 Like

thanks you very much :grin:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.