コード例 #1
0
ファイル: test_signal.py プロジェクト: christianbrodbeck/NEMS
def test_merge_selections(signal):
    signals = []
    for i in range(10):
        jk = signal.jackknife_by_time(10, i, invert=True)
        signals.append(jk)

    merged = merge_selections(signals)

    # merged and signal should be identical
    assert np.sum(np.isnan(merged.as_continuous())) == 0
    assert np.array_equal(signal.as_continuous(), merged.as_continuous())
    assert signal.epochs.equals(merged.epochs)

    # This should not throw an exception
    merge_selections([signal, signal, signal])

    normalized = signal.normalized_by_mean()

    # This SHOULD throw an exception because they totally overlap
    with pytest.raises(ValueError):
        merge_selections([signal, normalized])

    jk2 = normalized.jackknife_by_time(10, 2, invert=True)
    jk3 = signal.jackknife_by_time(10, 3, invert=True)
    jk4 = signal.jackknife_by_time(10, 4, invert=True)

    # This will NOT throw an exception because they don't overlap
    merged = merge_selections([jk2, jk3])
    merged = merge_selections([jk2, jk4])

    # This SHOULD throw an exception
    with pytest.raises(ValueError):
        merged = merge_selections([signal, jk2])
コード例 #2
0
ファイル: recording.py プロジェクト: christianbrodbeck/NEMS
def jackknife_inverse_merge(rec_list):
    '''
    merges list of jackknife validation data into a signal recording
    '''
    if type(rec_list) is not list:
        raise ValueError('Expecting list of recordings')
    new_sigs = {}
    rec1 = rec_list[0]
    for sn in rec1.signals.keys():
        sig_list = [r[sn] for r in rec_list]
        #new_sigs[sn]=sig_list[0].jackknife_inverse_merge(sig_list)
        new_sigs[sn] = merge_selections(sig_list)
    return Recording(signals=new_sigs)