Ejemplo n.º 1
0
def test_ar_raw():
    """Test fitting AR model on raw data."""
    raw = io.read_raw_fif(raw_fname)
    # pick MEG gradiometers
    picks = pick_types(raw.info, meg='grad', exclude='bads')
    picks = picks[:2]
    tmin, tmax, order = 0, 10, 2
    coefs = fit_iir_model_raw(raw, order, picks, tmin, tmax)[1][1:]
    assert_equal(coefs.shape, (order,))
    assert_true(0.9 < -coefs[0] < 1.1)
Ejemplo n.º 2
0
def test_ar_raw():
    """Test fitting AR model on raw data."""
    raw = io.read_raw_fif(raw_fname, add_eeg_ref=False)
    # pick MEG gradiometers
    picks = pick_types(raw.info, meg='grad', exclude='bads')
    picks = picks[:2]
    tmin, tmax, order = 0, 10, 2
    coefs = fit_iir_model_raw(raw, order, picks, tmin, tmax)[1][1:]
    assert_equal(coefs.shape, (order,))
    assert_true(0.9 < -coefs[0] < 1.1)
Ejemplo n.º 3
0
def test_ar_raw():
    """Test fitting AR model on raw data."""
    raw = io.read_raw_fif(raw_fname).crop(0, 2).load_data()
    raw.pick_types(meg='grad')
    # pick MEG gradiometers
    for order in (2, 5, 10):
        coeffs = fit_iir_model_raw(raw, order)[1][1:]
        assert coeffs.shape == (order, )
        assert_allclose(-coeffs[0], 1., atol=0.5)
    # let's make sure we're doing something reasonable: first, white noise
    rng = np.random.RandomState(0)
    raw._data = rng.randn(*raw._data.shape)
    raw._data *= 1e-15
    for order in (2, 5, 10):
        coeffs = fit_iir_model_raw(raw, order)[1]
        assert_allclose(coeffs, [1.] + [0.] * order, atol=2e-2)
    # Now let's try pink noise
    iir = [1, -1, 0.2]
    raw._data = lfilter([1.], iir, raw._data)
    for order in (2, 5, 10):
        coeffs = fit_iir_model_raw(raw, order)[1]
        assert_allclose(coeffs, iir + [0.] * (order - 2), atol=5e-2)
Ejemplo n.º 4
0
def test_ar_raw():
    """Test fitting AR model on raw data."""
    raw = io.read_raw_fif(raw_fname).crop(0, 2).load_data()
    raw.pick_types(meg='grad')
    # pick MEG gradiometers
    for order in (2, 5, 10):
        coeffs = fit_iir_model_raw(raw, order)[1][1:]
        assert_equal(coeffs.shape, (order,))
        assert_allclose(-coeffs[0], 1., atol=0.5)
    # let's make sure we're doing something reasonable: first, white noise
    rng = np.random.RandomState(0)
    raw._data = rng.randn(*raw._data.shape)
    raw._data *= 1e-15
    for order in (2, 5, 10):
        coeffs = fit_iir_model_raw(raw, order)[1]
        assert_allclose(coeffs, [1.] + [0.] * order, atol=2e-2)
    # Now let's try pink noise
    iir = [1, -1, 0.2]
    raw._data = lfilter([1.], iir, raw._data)
    for order in (2, 5, 10):
        coeffs = fit_iir_model_raw(raw, order)[1]
        assert_allclose(coeffs, iir + [0.] * (order - 2), atol=5e-2)