def test_detect_spindle_to_data():
    detsp = DetectSpindle()
    sp = detsp(data)

    sp_data = sp.to_data('count')
    assert sp_data(0)[0] == 2

    sp_freq = sp.to_data('peak_freq')
    assert approx(sp_freq(0)[0]) == 14.151831564532694
Example #2
0
def test_detect_spindle_to_data():
    detsp = DetectSpindle()
    sp = detsp(data)

    sp_data = sp.to_data('count')
    assert sp_data(0)[0] == 1

    sp_freq = sp.to_data('peak_freq')
    assert approx(sp_freq(0)[0]) == 13.793103448275861
Example #3
0
def test_detect_spindle_to_data():
    detsp = DetectSpindle()
    sp = detsp(data)

    sp_data = sp.to_data('count')
    assert sp_data(0)[0] == 1

    sp_freq = sp.to_data('peak_freq')
    assert approx(sp_freq(0)[0]) == 13.114754098360656

    sp_ptp = sp.to_data('ptp')
    assert approx(sp_ptp(0)[0]) == 63.53406593406595
def test_merge_close():
    detsp = DetectSpindle(method='Nir2011')

    sp = detsp(data)
    assert len(sp.events) == 4
def test_detect_spindle_unknownmethod():
    with raises(ValueError):
        detsp = DetectSpindle(method='xxx')
def test_detect_spindle_Concordia():
    detsp = DetectSpindle(method='Concordia')

    sp = detsp(data)
    assert (len(sp.events)) == 3
def test_detect_spindle_UCSD():
    detsp = DetectSpindle(method='UCSD')

    sp = detsp(data)
    assert len(sp.events) == 9
def test_detect_spindle_FASST2():
    detsp = DetectSpindle(method='FASST2')

    sp = detsp(data)
    assert len(sp.events) == 8
def test_detect_Lacourse2018():
    detsp = DetectSpindle(method='Lacourse2018')

    sp = detsp(data)
    assert len(sp.events) == 8
def test_detect_Ray2015():
    detsp = DetectSpindle(method='Ray2015')

    sp = detsp(data)
    assert len(sp.events) == 5
def test_detect_Martin2013():
    detsp = DetectSpindle(method='Martin2013')
    
    sp = detsp(data)
    assert len(sp.events) == 3
def test_detect_spindle_Ferrarelli2007():
    detsp = DetectSpindle(method='Ferrarelli2007')

    sp = detsp(data)
    assert len(sp.events) == 0
def test_detect_spindle_Wamsley2012():
    detsp = DetectSpindle(method='Wamsley2012')

    sp = detsp(data)
    assert len(sp.events) == 4
def test_detect_spindle_Nir2011():
    detsp = DetectSpindle(method='Nir2011')

    sp = detsp(data)
    assert len(sp.events) == 4
def test_detect_spindle_Moelle2011():
    detsp = DetectSpindle()
    assert repr(detsp) == 'detsp_Moelle2011_12-15Hz_00.5-03.0s'

    sp = detsp(data)
    assert len(sp.events) == 4
Example #16
0
hfile = os.path.join(target_path, 'Hypnogram_excerpt2.txt')  # hypnogram
cfile = os.path.join(target_path, 'excerpt2_config.txt')  # GUI config

# Define an instance of Sleep :
sp = Sleep(data=dfile, hypno=hfile, config_file=cfile)

###############################################################################
# Define new methods
###############################################################################

###############################################################################
# Spindle function
# ~~~~~~~~~~~~~~~~

# Define a DetectSpindle instance :
opts_spin = DetectSpindle('Moelle2011')


# Define the function to replace :
def fcn_spindle(data, sf, time, hypno):  # noqa
    """New spindle detection function.

    See : https://wonambi-python.github.io/api/wonambi.detect.spindle.html
    for an exhaustive list of implemented detections inside wonambi.
    """
    out, _, _ = detect_Moelle2011(data, sf, time, opts_spin)
    indices = np.zeros((len(out), 2))
    for i, k in enumerate(out):
        indices[i, 0] = k['start']
        indices[i, 1] = k['end']
    indices *= sf