Exemplo n.º 1
0
def test_filter_1d():
    # make sure a 1D array raises an error
    data = np.array([1, 2, 3, 4])
    block = pipeline.Filter(b, a)

    with pytest.raises(ValueError):
        block.process(data)
Exemplo n.º 2
0
def test_filter_overlap():
    # make sure output is continuous when filtering overlapped data
    data = rand_data_2d
    win_length = 10
    overlap = 5
    block = pipeline.Filter(b, a, overlap=overlap)

    data1 = data[:, 0:win_length]
    data2 = data[:, win_length-overlap:win_length-overlap+win_length]
    out1 = block.process(data1)
    out2 = block.process(data2)

    assert_array_almost_equal(out1[:, -overlap:], out2[:, :overlap])
Exemplo n.º 3
0
            self.finish()
        else:
            super().key_press(key)


if __name__ == '__main__':
    # from pytrigno import TrignoEMG
    # dev = TrignoEMG((0, 3), 200, host='192.168.1.114', units='normalized')
    from axopy.daq import NoiseGenerator
    dev = NoiseGenerator(rate=2000, num_channels=4, read_size=200)

    b, a = butter(4, (10 / 2000. / 2., 450 / 2000. / 2.), 'bandpass')
    preproc_pipeline = pipeline.Pipeline([
        pipeline.Windower(400),
        pipeline.Centerer(),
        pipeline.Filter(b, a=a, overlap=200),
    ])
    main_pipeline = pipeline.Pipeline([
        preproc_pipeline,
        pipeline.Callable(mean_absolute_value,
                          func_kwargs={
                              'weights': 'mav',
                              'axis': -1,
                              'keepdims': False
                          }),
        RLSMapping(4, 2, 0.99)
    ])

    Experiment(daq=dev, subject='test').run(Oscilloscope(preproc_pipeline),
                                            CursorFollowing(main_pipeline))
Exemplo n.º 4
0
def test_fir_filter():
    # use default parameter for a
    data = rand_data_2d
    block = pipeline.Filter(b)
    block.process(data)
    block.process(data)
Exemplo n.º 5
0
            self.finish()
        if key == util.key_q:
            sys.exit()
        else:
            super().key_press(key)


# dev = NoiseGenerator(rate=2000, num_channels=1, read_size=200)
dev = TrignoEMG(channel_range=(0, 0), samples_per_read=200, units='mV')

exp = Experiment(daq=dev, subject='test')
config = exp.configure(numbands=int)

# TODO: figure out how to do this recursively
b, a = butter(1, .1, fs=2000, btype='lowpass')
lowpassfilter = pipeline.Pipeline([pipeline.Filter(b, a=a, overlap=200)])

b, a = butter(4, (40, 60), fs=2000, btype='bandpass')
lowfilter = pipeline.Pipeline([pipeline.Filter(b, a=a, overlap=200)])

b, a = butter(4, (80, 100), fs=2000, btype='bandpass')
highfilter = pipeline.Pipeline([pipeline.Filter(b, a=a, overlap=200)])

b, a = butter(4, (120, 140), fs=2000, btype='bandpass')
midfilter = pipeline.Pipeline([pipeline.Filter(b, a=a, overlap=200)])

main_pipeline = pipeline.Pipeline([
    pipeline.Windower(1000),
    pipeline.Passthrough([(lowfilter, highfilter, midfilter),
                          FFT(),
                          pipeline.Callable(integrated_emg),