Ejemplo n.º 1
0
    def test_eeg_read_keep_buffer_butterworth_filtered(self):
        # filtering
        # # orig ptsa returns extra time point that's why eegs[:,:,:-1]
        eegs = self.eegs[:, :, :-1]
        eegs_filtered = eegs.filtered([58, 62], filt_type='stop', order=4)

        # -------------------TimeSeriesX
        base_eegs = self.base_eegs
        base_eegs_filtered_direct = self.base_eegs.filtered([58, 62], filt_type='stop', order=4)

        b_filter = ButterworthFilter(time_series=base_eegs, freq_range=[58, 62], filt_type='stop', order=4)

        base_eegs_filtered = b_filter.filter()

        # ---------------- testing
        # assert_array_almost_equal(eegs_filtered[:,:,:], base_eegs_filtered.data, decimal=2)
        assert_array_equal(eegs_filtered[:, :, :], base_eegs_filtered.data)
        assert_array_equal(eegs_filtered[:, :, :], base_eegs_filtered_direct.data)

        # checking filtering of just single time series
        eegs_0_0 = eegs[0,0]
        eegs_filtered_0_0 = eegs_0_0.filtered([58, 62], filt_type='stop', order=4)

        assert_array_equal(eegs_filtered_0_0, eegs_filtered[0,0])

        base_eegs[0:1,0:1].filtered([58, 62], filt_type='stop', order=4)
Ejemplo n.º 2
0
    def test_eeg_read_keep_buffer_butterworth_filtered(self):

        # old readers
        events = self.read_ptsa_events()

        # in case fancy indexing looses Eventness of events we need to create Events object explicitely
        if not isinstance(events, Events):
            events = Events(events)

        base_events = self.read_base_events()

        eegs = events.get_data(channels=['002', '003'], start_time=0.0, end_time=1.6,
                               buffer_time=1.0, eoffset='eegoffset', keep_buffer=True,
                               eoffset_in_time=False, verbose=True)
        # filtering
        eegs_filtered = eegs.filtered([58, 62], filt_type='stop', order=4)


        # New style reading
        from ptsa.data.experimental.TimeSeriesEEGReader import TimeSeriesEEGReader

        time_series_reader = TimeSeriesEEGReader(events=base_events, start_time=0.0,
                                                 end_time=1.6, buffer_time=1.0, keep_buffer=True)

        time_series_reader.read(channels=['002', '003'])

        base_eegs = time_series_reader.get_output()

        from ptsa.data.filters.ButterworthFilter import ButterworthFilter
        b_filter = ButterworthFilter(time_series=base_eegs, samplerate=base_eegs.attrs['samplerate'],
                                     freq_range=[58, 62], filt_type='stop',
                                     order=4)


        base_eegs_filtered = b_filter.filter()



        # testing
        assert_array_equal(eegs_filtered, base_eegs_filtered.data)

        assert_array_equal(eegs, base_eegs.data)