holgern / pyedflib

pyedflib is a python library to read/write EDF+/BDF+ files based on EDFlib.
http://pyedflib.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
209 stars 121 forks source link

Wrong signal sample rate if duration of a data record in EDF header is not 1 second #179

Closed Ari-PP closed 1 year ago

Ari-PP commented 2 years ago

Sample code:

f = pyedflib.EdfReader( filename ) labels = f.getSignalLabels() SampleRate = f.getSignalHeader(labels.index("Audio Volume"))['sample_rate']

SampleRate is ok if "duration of a data record" in EDF header is 1. SampleRate is 10x real value if "duration of a data record" in EDF header is 10. SampleRate should be divided by "duration of a data record".

This seems to be broken in 0.1.23 and been broken ever since.

skjerns commented 2 years ago

This is probably due to a bug that was introduced recently

Does installing from this branch fix the issue for you? https://github.com/holgern/pyedflib/tree/issue148_samplerate2

Ari-PP commented 2 years ago

I can't test since issue148_samplerate2 did not install even if requirements-test.txt, Cython and compilers were installed. There is some problem with setuptools call when running "python setup.py build":

Traceback (most recent call last): File "setup.py", line 268, in setup( File "/home/ari/.local/lib/python3.8/site-packages/setuptools/init.py", line 86, in setup _install_setup_requires(attrs) File "/home/ari/.local/lib/python3.8/site-packages/setuptools/init.py", line 75, in _install_setup_requires dist = MinimalDistribution(attrs) File "/home/ari/.local/lib/python3.8/site-packages/setuptools/init.py", line 57, in init super().init(filtered) File "/home/ari/.local/lib/python3.8/site-packages/setuptools/dist.py", line 475, in init for ep in metadata.entry_points(group='distutils.setup_keywords'): File "/home/ari/.local/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/init.py", line 999, in entry_points return SelectableGroups.load(eps).select(**params) File "/home/ari/.local/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/init.py", line 449, in load ordered = sorted(eps, key=by_group) File "/home/ari/.local/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/init.py", line 996, in eps = itertools.chain.from_iterable( File "/home/ari/.local/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/_itertools.py", line 16, in unique_everseen k = key(element) File "/home/ari/.local/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/init.py", line 931, in _normalized_name return self._name_from_stem(stem) or super()._normalized_name File "/home/ari/.local/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/init.py", line 600, in _normalized_name return Prepared.normalize(self.name) File "/home/ari/.local/lib/python3.8/site-packages/setuptools/_vendor/importlibmetadata/init.py", line 855, in normalize return re.sub(r"[-.]+", "-", name).lower().replace('-', '_') File "/usr/lib/python3.8/re.py", line 210, in sub return _compile(pattern, flags).sub(repl, string, count) TypeError: expected string or bytes-like object

skjerns commented 2 years ago

That is strange :-/

pinging @holgern , maybe he can merge the issue soon and make a release?

holgern commented 2 years ago

I will take a look and merge the open PR

jcbsv commented 1 year ago

Is there a working fix for this issue? It is rather important to be able to get the sample rate when loading data from an EDF file.

skjerns commented 1 year ago

There is a fix in PR #159, if you install from that branch it should be fine.

@holgern would you have time to have a look and merge PR? It quite a major bug that should be addressed

DaveMtl commented 1 year ago

Hi, just adding my voice to this issue, would love to see it fixed.

tecamenz commented 1 year ago

Hi, I also would love to see this fixed! Any updates so fare?

skjerns commented 1 year ago

nope, not really. If anyone wants to review the PR and give it a go I'd be glad :)

gcathelain commented 1 year ago

nope, not really. If anyone wants to review the PR and give it a go I'd be glad :)

I can review it

skjerns commented 1 year ago

Merged and released 🥳 #159