pyedflib icon indicating copy to clipboard operation
pyedflib copied to clipboard

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

Open Ari-PP opened this issue 3 years ago • 4 comments

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.

Ari-PP avatar Jun 17 '22 07:06 Ari-PP

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

skjerns avatar Jun 18 '22 19:06 skjerns

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/importlib_metadata/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

Ari-PP avatar Jun 20 '22 05:06 Ari-PP

That is strange :-/

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

skjerns avatar Jun 20 '22 09:06 skjerns

I will take a look and merge the open PR

holgern avatar Jul 08 '22 06:07 holgern

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.

jcbsv avatar Jan 16 '23 09:01 jcbsv

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

skjerns avatar Jan 16 '23 11:01 skjerns

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

DaveMtl avatar Jan 24 '23 15:01 DaveMtl

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

tecamenz avatar Feb 19 '23 11:02 tecamenz

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

skjerns avatar Feb 28 '23 19:02 skjerns

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

I can review it

gcathelain avatar Mar 02 '23 08:03 gcathelain

Merged and released 🥳 #159

skjerns avatar Apr 19 '23 07:04 skjerns