def test_localize_peaks():

    repo = 'https://gin.g-node.org/NeuralEnsemble/ephy_testing_data'
    remote_path = 'mearec/mearec_test_10s.h5'
    local_path = download_dataset(repo=repo,
                                  remote_path=remote_path,
                                  local_folder=None)
    recording = MEArecRecordingExtractor(local_path)

    peaks = detect_peaks(recording,
                         method='locally_exclusive',
                         peak_sign='neg',
                         detect_threshold=5,
                         n_shifts=2,
                         chunk_size=10000,
                         verbose=False,
                         progress_bar=False)

    peak_locations = localize_peaks(recording,
                                    peaks,
                                    method='center_of_mass',
                                    chunk_size=10000,
                                    verbose=True,
                                    progress_bar=False)
    assert peaks.size == peak_locations.shape[0]

    peak_locations = localize_peaks(recording,
                                    peaks,
                                    method='monopolar_triangulation',
                                    n_jobs=1,
                                    chunk_size=10000,
                                    verbose=True,
                                    progress_bar=True)
    assert peaks.size == peak_locations.shape[0]
Exemplo n.º 2
0
def test_detect_peaks():
    repo = 'https://gin.g-node.org/NeuralEnsemble/ephy_testing_data'
    remote_path = 'mearec/mearec_test_10s.h5'
    local_path = download_dataset(repo=repo,
                                  remote_path=remote_path,
                                  local_folder=None)
    recording = MEArecRecordingExtractor(local_path)

    peaks = detect_peaks(recording,
                         method='by_channel',
                         peak_sign='neg',
                         detect_threshold=5,
                         n_shifts=2,
                         chunk_size=10000,
                         verbose=1,
                         progress_bar=False,
                         outputs='numpy_compact')

    sample_inds, chan_inds, amplitudes, seg_inds = detect_peaks(
        recording,
        method='locally_exclusive',
        peak_sign='neg',
        detect_threshold=5,
        n_shifts=2,
        chunk_size=10000,
        verbose=1,
        progress_bar=False,
        outputs='numpy_split')
Exemplo n.º 3
0
def test_estimate_motion_rigid():
    local_path = download_dataset(repo=repo,
                                  remote_path=remote_path,
                                  local_folder=None)
    recording = MEArecRecordingExtractor(local_path)
    print(recording)
    peaks = np.load('mearec_detected_peaks.npy')

    motion, temporal_bins, spatial_bins, extra_check = estimate_motion(
        recording,
        peaks,
        peak_locations=None,
        direction='y',
        bin_duration_s=1.,
        bin_um=10.,
        margin_um=5,
        method='decentralized_registration',
        method_kwargs={},
        non_rigid_kwargs=None,
        output_extra_check=True,
        progress_bar=True,
        verbose=True)
    # print(motion)
    # print(extra_check)
    print(spatial_bins)

    assert spatial_bins is None
Exemplo n.º 4
0
def test_detect_peaks():

    repo = 'https://gin.g-node.org/NeuralEnsemble/ephy_testing_data'
    remote_path = 'mearec/mearec_test_10s.h5'
    local_path = download_dataset(repo=repo,
                                  remote_path=remote_path,
                                  local_folder=None)
    recording = MEArecRecordingExtractor(local_path)

    # by_channel
    peaks = detect_peaks(recording,
                         method='by_channel',
                         peak_sign='neg',
                         detect_threshold=5,
                         n_shifts=2,
                         chunk_size=10000,
                         verbose=1,
                         progress_bar=False)

    # by_channel
    sorting = detect_peaks(recording,
                           method='by_channel',
                           peak_sign='neg',
                           detect_threshold=5,
                           n_shifts=2,
                           chunk_size=10000,
                           verbose=1,
                           progress_bar=False,
                           outputs="sorting")
    assert isinstance(sorting, BaseSorting)

    # locally_exclusive
    peaks = detect_peaks(recording,
                         method='locally_exclusive',
                         peak_sign='neg',
                         detect_threshold=5,
                         n_shifts=2,
                         chunk_size=10000,
                         verbose=1,
                         progress_bar=False)

    # locally_exclusive + localization
    peaks = detect_peaks(
        recording,
        method='locally_exclusive',
        peak_sign='neg',
        detect_threshold=5,
        n_shifts=2,
        chunk_size=10000,
        verbose=1,
        progress_bar=True,
        localization_dict=dict(method='center_of_mass',
                               local_radius_um=150,
                               ms_before=0.1,
                               ms_after=0.3),
        #localization_dict=dict(method='monopolar_triangulation', local_radius_um=150,
        #                       ms_before=0.1, ms_after=0.3, max_distance_um=1000)
    )
    assert 'x' in peaks.dtype.fields
def test_localize_peaks():
    repo = 'https://gin.g-node.org/NeuralEnsemble/ephy_testing_data'
    remote_path = 'mearec/mearec_test_10s.h5'
    local_path = download_dataset(repo=repo, remote_path=remote_path, local_folder=None)
    recording = MEArecRecordingExtractor(local_path)

    peaks = detect_peaks(recording,
                         method='by_channel',
                         peak_sign='neg', detect_threshold=5, n_shifts=2,
                         chunk_size=10000, verbose=False, progress_bar=False,
                         outputs='numpy_compact'
                         )

    peak_locations = localize_peaks(recording, peaks,
                                    chunk_size=10000, verbose=True, progress_bar=False, )

    assert peaks.size == peak_locations.shape[0]
Exemplo n.º 6
0
def test_motion_functions():
    local_path = download_dataset(repo=repo,
                                  remote_path=remote_path,
                                  local_folder=None)
    recording = MEArecRecordingExtractor(local_path)

    peaks = np.load('mearec_detected_peaks.npy')

    bin_um = 2
    motion_histogram, temporal_bins, spatial_bins = make_motion_histogram(
        recording, peaks, bin_um=bin_um)
    # print(motion_histogram.shape, temporal_bins.size, spatial_bins.size)

    pairwise_displacement = compute_pairwise_displacement(motion_histogram,
                                                          bin_um,
                                                          method='conv2d')

    motion = compute_global_displacement(pairwise_displacement)
def test_detect_peaks():

    repo = 'https://gin.g-node.org/NeuralEnsemble/ephy_testing_data'
    remote_path = 'mearec/mearec_test_10s.h5'
    local_path = download_dataset(repo=repo, remote_path=remote_path, local_folder=None)
    recording = MEArecRecordingExtractor(local_path)

    # by_channel

    noise_levels = get_noise_levels(recording, return_scaled=False)

    peaks = detect_peaks(recording, method='by_channel',
                         peak_sign='neg', detect_threshold=5, n_shifts=2,
                         chunk_size=10000, verbose=1, progress_bar=False, noise_levels=noise_levels)



    subset_peaks = select_peaks(peaks, max_peaks_per_channel=100)
    subset_peaks = select_peaks(peaks, 'smart_sampling', max_peaks_per_channel=100, noise_levels=noise_levels)

    assert len(subset_peaks) < len(peaks)
Exemplo n.º 8
0
def setup_module():
    local_path = download_dataset(repo=repo,
                                  remote_path=remote_path,
                                  local_folder=None)
    recording = MEArecRecordingExtractor(local_path)

    # detect and localize
    peaks = detect_peaks(
        recording,
        method='locally_exclusive',
        peak_sign='neg',
        detect_threshold=5,
        n_shifts=2,
        chunk_size=10000,
        verbose=1,
        progress_bar=True,
        localization_dict=dict(method='center_of_mass',
                               local_radius_um=150,
                               ms_before=0.1,
                               ms_after=0.3),
        #~ localization_dict=dict(method='monopolar_triangulation', local_radius_um=150, ms_before=0.1, ms_after=0.3, max_distance_um=1000),
    )
    np.save('mearec_detected_peaks.npy', peaks)