@@ -256,7 +256,7 @@ def test_2f(self):
256256 """
257257 # Uniform sample rates
258258 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__
260260
261261 fields = list (record_MIT .keys ())
262262 # Original MIT format method of checksum is outdated, sometimes
@@ -270,8 +270,13 @@ def test_2f(self):
270270 for field in fields :
271271 # Signal value will be slightly off due to C to Python type conversion
272272 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
275280 sig_diff = np .abs ((pred_array - true_array ) / true_array )
276281 sig_diff [sig_diff == - np .inf ] = 0
277282 sig_diff [sig_diff == np .inf ] = 0
@@ -299,8 +304,8 @@ def test_2g(self):
299304
300305 """
301306 # 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__
304309
305310 fields = list (record_MIT .keys ())
306311 # Original MIT format method of checksum is outdated, sometimes
@@ -309,19 +314,18 @@ def test_2g(self):
309314 # Original MIT format units are less comprehensive since they
310315 # default to mV if unknown.. therefore added more default labels
311316 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' )
318317
319318 test_results = []
320319 for field in fields :
321320 # Signal value will be slightly off due to C to Python type conversion
322321 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
325329 sig_diff = np .abs ((pred_array - true_array ) / true_array )
326330 sig_diff [sig_diff == - np .inf ] = 0
327331 sig_diff [sig_diff == np .inf ] = 0
0 commit comments