예제 #1
0
    def test_eeg_read_keep_buffer(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)

        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)


        # NEW READERS
        base_events = self.read_base_events()

        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()

        # testing
        assert_array_equal(eegs, base_eegs.data)
예제 #2
0
    def test_eeg_read_keep_buffer(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)

        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)

        # NEW READERS
        base_events = self.read_base_events()

        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()

        # testing
        assert_array_equal(eegs, base_eegs.data)
예제 #3
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)
예제 #4
0
    def test_eeg_resample(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_resampled = eegs.resampled(50.0)

        # 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.ResampleFilter import ResampleFilter
        resample_filter = ResampleFilter(time_series=base_eegs,
                                         resamplerate=50.0)

        base_eegs_resampled = resample_filter.filter()

        # testing
        assert_array_equal(eegs_resampled, base_eegs_resampled.data)
예제 #5
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)
예제 #6
0
    def test_eeg_resample(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_resampled = eegs.resampled(50.0)


        # 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.ResampleFilter import ResampleFilter
        resample_filter = ResampleFilter(time_series=base_eegs, resamplerate=50.0)

        base_eegs_resampled = resample_filter.filter()


        # testing
        assert_array_equal(eegs_resampled, base_eegs_resampled.data)