@@ -256,7 +256,7 @@ def test_2f(self):
256
256
"""
257
257
# Uniform sample rates
258
258
record_MIT = wfdb .rdrecord ('sample-data/n16' ).__dict__
259
- record_EDF = wfdb .rdrecord ('sample-data/n16.edf' ).__dict__
259
+ record_EDF = wfdb .edf2mit ('sample-data/n16.edf' ).__dict__
260
260
261
261
fields = list (record_MIT .keys ())
262
262
# Original MIT format method of checksum is outdated, sometimes
@@ -270,8 +270,13 @@ def test_2f(self):
270
270
for field in fields :
271
271
# Signal value will be slightly off due to C to Python type conversion
272
272
if field == 'p_signal' :
273
- true_array = np .array (record_MIT [field ])
274
- pred_array = np .array (record_EDF [field ])
273
+ true_array = np .array (record_MIT [field ]).flatten ()
274
+ pred_array = np .array (record_EDF [field ]).flatten ()
275
+ # Prevent divide by zero warning
276
+ for i ,v in enumerate (true_array ):
277
+ if v == 0 :
278
+ true_array [i ] = 1
279
+ pred_array [i ] = 1
275
280
sig_diff = np .abs ((pred_array - true_array ) / true_array )
276
281
sig_diff [sig_diff == - np .inf ] = 0
277
282
sig_diff [sig_diff == np .inf ] = 0
@@ -299,8 +304,8 @@ def test_2g(self):
299
304
300
305
"""
301
306
# Non-uniform sample rates
302
- record_MIT = wfdb .rdrecord ('sample-data/SC4001E0_PSG ' ).__dict__
303
- record_EDF = wfdb .rdrecord ('sample-data/SC4001E0-PSG .edf' ).__dict__
307
+ record_MIT = wfdb .rdrecord ('sample-data/wave_4 ' ).__dict__
308
+ record_EDF = wfdb .edf2mit ('sample-data/wave_4 .edf' ).__dict__
304
309
305
310
fields = list (record_MIT .keys ())
306
311
# Original MIT format method of checksum is outdated, sometimes
@@ -309,19 +314,18 @@ def test_2g(self):
309
314
# Original MIT format units are less comprehensive since they
310
315
# default to mV if unknown.. therefore added more default labels
311
316
fields .remove ('units' )
312
- # Initial value of signal will be off due to resampling done by
313
- # MNE in the EDF reading phase
314
- fields .remove ('init_value' )
315
- # Samples per frame will be off due to resampling done by MNE in
316
- # the EDF reading phase... I should probably fix this later
317
- fields .remove ('samps_per_frame' )
318
317
319
318
test_results = []
320
319
for field in fields :
321
320
# Signal value will be slightly off due to C to Python type conversion
322
321
if field == 'p_signal' :
323
- true_array = np .array (record_MIT [field ])
324
- pred_array = np .array (record_EDF [field ])
322
+ true_array = np .array (record_MIT [field ]).flatten ()
323
+ pred_array = np .array (record_EDF [field ]).flatten ()
324
+ # Prevent divide by zero warning
325
+ for i ,v in enumerate (true_array ):
326
+ if v == 0 :
327
+ true_array [i ] = 1
328
+ pred_array [i ] = 1
325
329
sig_diff = np .abs ((pred_array - true_array ) / true_array )
326
330
sig_diff [sig_diff == - np .inf ] = 0
327
331
sig_diff [sig_diff == np .inf ] = 0
0 commit comments