Number of samples when reading edf file

- MNE version: 1.6.0
- operating system:Ubuntu 22.04.3 LTS

I have an edf file which has 30 EEG channels and sampling frequency of 250 Hz. The total signal duration is 1216.996 seconds, so when I read the eeg signal I expect to get 250 * 1216.996 = 304249 samples, but I get 304250 samples, how mne library interprets this and what should I do to get the exact number of samples.

file = "/home/iva/Desktop/maborg/Zacasno/davidsusic/EEG/v3.0.0/edf/eval/abnormal/01_tcp_ar/aaaaabdo_s003_t000.edf"
signal =, preload='True')
signal_values = signal.get_data()

there is most likely a rounding error happening. Your data is “digitized”, and as such, a measure in a continuous format (time in seconds) is not very meaningful. In fact, wherever you have the “total signal duration” data from → this is most likely being calculated through the number of samples in the data and the sampling frequency of the data.

1 Like

Or in other words, the “error” of 0.04ms (=1/250Hz) is due to including time point 0.

1 Like

Can I force exactly to get the number of samples with signal duration of 1216.996 seconds not rounded to 1217 seconds?

You would have to make the signal exactly 1 sample longer. If you need to work with the file you have, then you cannot change the behavior. Why is this integer duration important for you?

I need to have exactly 15000 samples to fed to my neural network, some of the edf files have sampling frequency of 512 Hz and when I resample them and crop the signal to have just the 60 seconds I got exactly 15000 samples, but when the sampling frequency is 250 Hz, then I got for 60 second lasting signal 15001 sample and I want to get rid of that to not check manually if the sampling frequency is 512 Hz do not remove the last sample

When cropping a Raw object, you can set include_tmax=False. I think this should solve your problem.


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