Example #1
0
    def test_remove_mean_single_channel(self):
        tb = generate_timebase(t0=-0.5, n_samples=1.e2, sample_freq=1.e2)
        # nonzero signal mean
        tsd = TimeseriesData(timebase=tb,
                             signal=Signal(np.arange(len(tb))), channels=ChannelList(Channel('ch_01',Coords('dummy',(0,0,0)))))

        filtered_tsd = tsd.subtract_mean()

        assert_almost_equal(np.mean(filtered_tsd.signal), 0)
Example #2
0
    def testFilteredDataHistory_nocopy(self):

        tb = generate_timebase(t0=-0.5, n_samples=1.e2, sample_freq=1.e2)
        # nonzero signal mean
        ch = get_n_channels(1)
        tsd = TimeseriesData(timebase=tb,
                             signal=Signal(np.arange(len(tb))), channels=ch)

        filtered_tsd = tsd.subtract_mean()
        #self.assertEqual(len(filtered_tsd.history.split('\n')), 3)
        self.assertEqual(len(filtered_tsd.history.split('\n')), 5)  # bdb thinks extra 2 is OK
        output_data = filtered_tsd.normalise(method='rms', copy=False)
        #self.assertEqual(filtered_tsd.history.split('> ')[-1], "normalise(method='rms')")
        self.assertEqual(filtered_tsd.history.split('> ')[-1].split('\n')[0], "normalise(method='rms')")
        #self.assertEqual(output_data.history.split('> ')[-1], "normalise(method='rms')")
        self.assertEqual(output_data.history.split('> ')[-1].split('\n')[0], "normalise(method='rms')")
Example #3
0
    def testFilteredDataHistory_copy(self):
        """ make sure that _copy version does NOT alter original 
        """
        tb = generate_timebase(t0=-0.5, n_samples=1.e2, sample_freq=1.e2)
        # nonzero signal mean
        ch = get_n_channels(1)
        tsd = TimeseriesData(timebase=tb,
                             signal=Signal(np.arange(len(tb))), channels=ch)

        filtered_tsd = tsd.subtract_mean()
        # bdb in 4 places, assume that the xtra info (norm_value) is supposed to be there.
        #self.assertEqual(len(filtered_tsd.history.split('\n')), 3)
        self.assertEqual(len(filtered_tsd.history.split('\n')), 5)  # bdb thinks extra 2 is OK
        output_data = filtered_tsd.normalise(method='rms', copy=True)
        #self.assertEqual(output_data.history.split('> ')[-1], "normalise(method='rms')")
        self.assertEqual(output_data.history.split('> ')[-1].split('\n')[0], "normalise(method='rms')")

        #self.assertEqual(filtered_tsd.history.split('> ')[-1], "subtract_mean()")
        self.assertEqual(filtered_tsd.history.split('> ')[-1].split('\n')[0], "subtract_mean()")