Esempio n. 1
0
def test_localfieldpotential_slice():
    times = np.array([1.0, 2.0, 3.0])
    data = np.array([1.1, 0.9, 2.3])

    lfp = nept.LocalFieldPotential(data, times)
    sliced = lfp[:2]

    assert np.allclose(sliced.time, np.array([1.0, 2.0]))
    assert np.allclose(sliced.data, np.array([[1.1], [0.9]]))
Esempio n. 2
0
def test_localfieldpotential_too_many():
    times = np.array([1.0, 2.0, 3.0])
    data = np.array([1.1, 0.9, 2.3])
    other = np.array([3.1, 2.0, 1.4])

    with pytest.raises(ValueError) as excinfo:
        lfp = nept.LocalFieldPotential([data, other], times)

    assert str(excinfo.value) == 'can only contain one LFP'
Esempio n. 3
0
def test_swr():
    fs = 2000
    time = np.arange(0, 0.5, 1./fs)
    freq = np.ones(len(time))*100
    freq[int(len(time)*0.4):int(len(time)*0.6)] = 180
    freq[int(len(time)*0.7):int(len(time)*0.9)] = 260
    data = np.sin(2.*np.pi*freq*time)

    lfp = nept.LocalFieldPotential(data, time)

    swrs = nept.detect_swr_hilbert(lfp, fs=2000, thresh=(140.0, 250.0), z_thresh=0.4,
                                   merge_thresh=0.02, min_length=0.01)

    assert np.allclose(swrs.start, 0.1995)
    assert np.allclose(swrs.stop, 0.301)
Esempio n. 4
0
def load_lfp(filename):
    """Loads LFP as nept.LocalFieldPotential

    Parameters
    ----------
    filename: str

    Returns
    -------
    lfp: nept.LocalFieldPotential

    """
    data, time = load_ncs(filename)

    return nept.LocalFieldPotential(data, time)
Esempio n. 5
0
def test_localfieldpotential_nsamples():
    times = np.array([1.0, 2.0, 3.0])
    data = np.array([1.1, 0.9, 2.3])
    lfp = nept.LocalFieldPotential(data, times)

    assert np.allclose(lfp.n_samples, 3)