From 19a34fd0fdd371fe81ddb40a6f19f57b3be81ec9 Mon Sep 17 00:00:00 2001 From: Alistair Johnson Date: Thu, 11 May 2023 14:25:06 -0400 Subject: [PATCH] Add a test to check if wrsamp can write more than 8 channels to fmt516 We should be able to read and write data with more than 8 channels to formats 508, 516, and 524. This test verifies that the digital signal generated when writing to format 516 is identical to the original signal loaded in from a sample record in format 16. --- tests/test_record.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_record.py b/tests/test_record.py index 9563ef11..8d09e39d 100644 --- a/tests/test_record.py +++ b/tests/test_record.py @@ -286,6 +286,33 @@ def test_read_write_flac_multifrequency(self): ) assert record == record_write + def test_read_write_flac_many_channels(self): + """ + Check we can read and write to format 516 with more than 8 channels. + """ + # Read in a signal with 12 channels in format 16 + record = wfdb.rdrecord("sample-data/s0010_re", physical=False) + + # Test that we can write out the signal in format 516 + wfdb.wrsamp( + record_name="s0010_re_fmt516", + fs=record.fs, + units=record.units, + sig_name=record.sig_name, + fmt=["516"] * record.n_sig, + d_signal=record.d_signal, + adc_gain=record.adc_gain, + baseline=record.baseline, + write_dir=self.temp_path, + ) + + # Check that signal matches the original + record_fmt516 = wfdb.rdrecord( + os.path.join(self.temp_path, "s0010_re_fmt516"), + physical=False, + ) + assert (record.d_signal == record_fmt516.d_signal).all() + def test_read_flac_longduration(self): """ Three signals multiplexed in a FLAC file, over 2**24 samples.