Exemple #1
0
    def test_read_waveforms(self):
        self.channel_pair._amend_segments(self.segments)

        waveforms = self.channel_pair.read_waveforms()

        segments = [TaborSegment.from_binary_segment(waveform)
                    for waveform in waveforms]

        expected = [self.zero_segment, *self.segments]

        for ex, r in zip(expected, segments):
            ex1, ex2 = ex.data_a, ex.data_b
            r1, r2 = r.data_a, r.data_b
            np.testing.assert_equal(ex1, r1)
            np.testing.assert_equal(ex2, r2)

        self.assertEqual(expected, segments)
Exemple #2
0
    def test_from_binary_segment(self):
        ch_a = np.asarray(100 + np.arange(32), dtype=np.uint16)
        ch_b = np.asarray(1000 + np.arange(32), dtype=np.uint16)

        marker_a = np.ones(16, dtype=bool)
        marker_b = np.asarray(list(range(5)) + list(range(6)) + list(range(5)),
                              dtype=np.uint16)

        segment = TaborSegment.from_sampled(ch_a=ch_a,
                                            ch_b=ch_b,
                                            marker_a=marker_a,
                                            marker_b=marker_b)

        binary = segment.get_as_binary()

        reconstructed = TaborSegment.from_binary_segment(binary)

        self.assertEqual(segment, reconstructed)