Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sampling rate is not accurate when data record duration is not 1 second #199

Open
eric-nextsense opened this issue May 5, 2023 · 5 comments · May be fixed by #232
Open

sampling rate is not accurate when data record duration is not 1 second #199

eric-nextsense opened this issue May 5, 2023 · 5 comments · May be fixed by #232

Comments

@eric-nextsense
Copy link

I opened an EDF file where the data record duration was set to 2 seconds.

In the signal headers, it said that the channels frequency was 512, which is incorrect as it is actually 256 samples per second. It seems like it returns the number of samples per data record and not per second. Is that intended? I did not find a way to read the data record duration using pyedflib so i don't see a way to get the real sampling rate per second in this situation.

If i open the file with mne, it returns 256 as the 'sfreq' property which is correct as an example.

@DimitriPapadopoulos
Copy link
Contributor

It would help to be able to reproduce the problem with an actual file. Can you provide one?

I believe this is related to the underlying EDFlib library. And indeed the documentation states:

Sets the sample frequency of signal edfsignal. In reality, it sets the number of samples in a datarecord
which equals the sample frequency only when the datarecords have a duration of one second.
The effective sample frequency is: samplefrequency / datarecord duration

Since pyedflib is a wrapper around EDFlib, it follows the same definition. However, I agree this warrants a clarification in the pyedflib documentation.

@eric-nextsense
Copy link
Author

The file i have is not one i could share.

Could you provide a way to get the record duration? With that it would be possible to calculate the sampling rate per second.

@DimitriPapadopoulos
Copy link
Contributor

The effective sample frequency is: samplefrequency / datarecord duration

@eric-nextsense
Copy link
Author

eric-nextsense commented Jul 3, 2023 via email

@DimitriPapadopoulos
Copy link
Contributor

Does EdfReader.getFileDuration help?

@DimitriPapadopoulos DimitriPapadopoulos linked a pull request Jul 3, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants