コード例 #1
0
def test_union(epoch_a, epoch_b):
    expected = np.array([
        [0, 50],
        [55, 70],
        [75, 76],
        [77, 77],
        [85, 100],
        [110, 120],
    ])
    result = epoch_union(epoch_a, epoch_b)
    assert np.all(result == expected)
コード例 #2
0
def test_union_float(epoch_a, epoch_b):
    expected = np.array([
        [0, 50],
        [55, 70],
        [75, 76],
        [77, 77],
        [85, 100],
        [110, 120],
        [140, 150],
    ]) / 10
    result = epoch_union(epoch_a / 10, epoch_b / 10)
    assert np.all(result == expected)
コード例 #3
0
def get_est_val_times(recording, balance_phase=False):
    rng = np.random.RandomState(0)

    epochs = recording.epochs
    est_times, val_times = get_est_val_times_by_sequence(recording, rng)

    if balance_phase:
        target_times = select_balanced_targets(epochs, rng)

        m = epochs['name'].str.contains('^repeating$')
        repeating_times = epochs.loc[m, ['start', 'end']].values

        # Remove the repeating phase from the dataset
        est_times = epoch_difference(est_times, repeating_times)
        # Now, add back in selected targets from repeating phase
        est_times = epoch_union(est_times, target_times)

        # Remove the repeating phase from the dataset
        val_times = epoch_difference(val_times, repeating_times)
        # Now, add back in selected targets from repeating phase
        val_times = epoch_union(val_times, target_times)

    return est_times, val_times