-
Notifications
You must be signed in to change notification settings - Fork 126
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
'sample_rate'
is deprecated, but pyedflib still uses it internally
#198
Comments
How to reproduce this warning? I tried with the attached https://gist.github.com/DimitriPapadopoulos/599ccc16b294d22e833e566176ed3caf |
I cannot reproduce it either, I just tried on Linux. Let me try if this was specific to macOS later today, otherwise I'll close this issue. |
I still get the error by running |
So that would be def test_read_shhs(tmp_path):
"""Basic sanity checks for records read via read_shhs."""
durations = [0.1, 0.2] # hours
valid_stages = {int(s) for s in SleepStage}
_create_dummy_shhs(data_dir=tmp_path, durations=durations)
records = list(read_shhs(data_dir=tmp_path, heartbeats_source="ecg", offline=True))
assert len(records) == 4
for rec in records:
assert rec.sleep_stage_duration == 30
assert set(rec.sleep_stages) - valid_stages == set() Function read_shhs currently calls rec = read_raw_edf(edf_filepath, verbose=False) But Which version of sleepecg did you use to reproduce the problem? |
I'm using the dev version of SleepECG, but that should be pretty much identical to the latest release v0.5.5. The problem is in the previous line, which calls |
If you want to reproduce this, don't forget to comment out this line first. |
What's weird is that I cannot reproduce this outside of this SleepECG test, for example with this snippet: from pyedflib.highlevel import make_signal_headers, write_edf
from scipy.datasets import electrocardiogram
ecg = electrocardiogram()
headers = make_signal_headers(["ECG"], sample_frequency=360)
write_edf("test.edf", [ecg], headers) @hofaflo do you have any ideas? Are you seeing the |
Could it depend on the version of pyedflib, with a different version used in either cases? |
Perhaps the problem is here is in make_signal_header: signal_header = {'label': label,
'dimension': dimension,
'sample_rate': sample_rate,
'sample_frequency': sample_frequency,
'physical_min': physical_min,
'physical_max': physical_max,
'digital_min': digital_min,
'digital_max': digital_max,
'transducer': transducer,
'prefilter': prefiler}
return signal_header I guess def make_signal_header(label, dimension='uV', sample_rate=256, sample_frequency=None, |
I just checked, I'm using the latest version 0.1.33.
I tried popping that dict key before writing the EDF, this didn't have any effect on the warning. |
Additionally, I have discovered that the documentation of |
That's the first point of failure. There must be a second one, perhaps in for i in np.arange(self.n_channels):
if self.file_type == FILETYPE_BDFPLUS or self.file_type == FILETYPE_BDF:
self.channels.append({'label': f'ch{i}', 'dimension': 'mV', 'sample_rate': 100,
'sample_frequency': None, 'physical_max': 1.0, 'physical_min': -1.0,
'digital_max': 8388607,'digital_min': -8388608,
'prefilter': '', 'transducer': ''})
elif self.file_type == FILETYPE_EDFPLUS or self.file_type == FILETYPE_EDF:
self.channels.append({'label': f'ch{i}', 'dimension': 'mV', 'sample_rate': 100,
'sample_frequency': None, 'physical_max': 1.0, 'physical_min': -1.0,
'digital_max': 32767, 'digital_min': -32768,
'prefilter': '', 'transducer': ''})
self.sample_buffer.append([]) |
Could you give #231 a try? |
I am a bit concerned that we cannot come up with a minimal reproducible example, and that the warning only occurs in the SleepECG test... |
Yes. But make sure to disable the warning filter in |
Branch :make_signal_header does work for me. Commits 35e5ed7 and 5aebc8e are sufficient to fix this particular warning. |
As for why you see the warning with
|
But do you see the warning? |
With
|
Yes, I can confirm that your branch fixes the issue! |
We will first need to decide how we want to handle Any way, in the short term, you should probably ignore that warning in your tests. |
IMO the problem is that even if users write an EDF and only pass |
Indeed, the warning should be emitted when writing and explicitly passing It should not be emitted when reading, unless of course The question remains whether we should write |
Agreed! Just to be clear, the warning we're seeing here is emitted when writing. The question of whether or not to write |
I am using
highlevel.write_edf()
in my tests, and even though I am passingsample_frequency
instead ofsample_rate
, I still get aDeprecationWarning
:Currently, users cannot really prevent that warning even if they have already switched to the new
sample_frequency
.The text was updated successfully, but these errors were encountered: