Пример #1
0
def test_thresh_nn_metrics():
    rec, sort = se.example_datasets.toy_example(dump_folder='test', dumpable=True, duration=10, num_channels=4, K=10,
                                                seed=0)
    s_threshold_hit = 0.9
    s_threshold_miss = 0.002

    nn_hit, nn_miss = compute_nn_metrics(sort, rec, apply_filter=False, seed=0)
    sort_hit = threshold_nn_metrics(sort, rec, s_threshold_hit, 'less', metric_name="nn_hit_rate",
                                    apply_filter=False, seed=0)
    sort_miss = threshold_nn_metrics(sort, rec, s_threshold_miss, 'greater', metric_name="nn_miss_rate",
                                     apply_filter=False, seed=0)

    original_ids = sort.get_unit_ids()
    new_nn_hit = []
    for unit in sort_hit.get_unit_ids():
        new_nn_hit.append(nn_hit[original_ids.index(unit)])
    new_nn_miss = []
    for unit in sort_miss.get_unit_ids():
        new_nn_miss.append(nn_miss[original_ids.index(unit)])
    new_nn_hit = np.array(new_nn_hit)
    new_nn_miss = np.array(new_nn_miss)
    assert np.all(new_nn_hit >= s_threshold_hit)
    assert np.all(new_nn_miss <= s_threshold_miss)
    check_dumping(sort_hit)
    check_dumping(sort_miss)
    shutil.rmtree('test')
Пример #2
0
def test_functions():
    rec, sort = se.example_datasets.toy_example(duration=10, num_channels=4, seed=0)

    firing_rates = compute_firing_rates(sort, seed=0)[0]
    num_spikes = compute_num_spikes(sort, seed=0)[0]
    isi = compute_isi_violations(sort, seed=0)[0]
    presence = compute_presence_ratios(sort, seed=0)[0]
    amp_cutoff = compute_amplitude_cutoffs(sort, rec, seed=0)[0]
    max_drift, cum_drift = compute_drift_metrics(sort, rec, seed=0, memmap=False)[0]
    silh = compute_silhouette_scores(sort, rec, seed=0)[0]
    iso = compute_isolation_distances(sort, rec, seed=0)[0]
    l_ratio = compute_l_ratios(sort, rec, seed=0)[0]
    dprime = compute_d_primes(sort, rec, seed=0)[0]
    nn_hit, nn_miss = compute_nn_metrics(sort, rec, seed=0)[0]
    snr = compute_snrs(sort, rec, seed=0)[0]
    metrics = compute_metrics(sort, rec, return_dict=True, seed=0)

    assert np.allclose(metrics['firing_rate'][0], firing_rates)
    assert np.allclose(metrics['num_spikes'][0], num_spikes)
    assert np.allclose(metrics['isi_viol'][0], isi)
    assert np.allclose(metrics['amplitude_cutoff'][0], amp_cutoff)
    assert np.allclose(metrics['presence_ratio'][0], presence)
    assert np.allclose(metrics['silhouette_score'][0], silh)
    assert np.allclose(metrics['isolation_distance'][0], iso)
    assert np.allclose(metrics['l_ratio'][0], l_ratio)
    assert np.allclose(metrics['d_prime'][0], dprime)
    assert np.allclose(metrics['snr'][0], snr)
    assert np.allclose(metrics['max_drift'][0], max_drift)
    assert np.allclose(metrics['cumulative_drift'][0], cum_drift)
    assert np.allclose(metrics['nn_hit_rate'][0], nn_hit)
    assert np.allclose(metrics['nn_miss_rate'][0], nn_miss)
Пример #3
0
def test_functions():
    rec, sort = se.example_datasets.toy_example(duration=10, num_channels=4)

    firing_rates = compute_firing_rates(sort)
    num_spikes = compute_num_spikes(sort)
    isi = compute_isi_violations(sort)
    presence = compute_presence_ratios(sort)

    amp_cutoff = compute_amplitude_cutoffs(sort, rec)

    max_drift, cum_drift = compute_drift_metrics(sort, rec)
    silh = compute_silhouette_scores(sort, rec)
    iso = compute_isolation_distances(sort, rec)
    l_ratio = compute_l_ratios(sort, rec)
    dprime = compute_d_primes(sort, rec)
    nn_hit, nn_miss = compute_nn_metrics(sort, rec)

    snr = compute_snrs(sort, rec)