DARTsort 0.5.25__tar.gz → 0.5.26__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dartsort-0.5.25 → dartsort-0.5.26}/PKG-INFO +2 -2
- {dartsort-0.5.25 → dartsort-0.5.26}/README.md +1 -1
- {dartsort-0.5.25 → dartsort-0.5.26}/docs/index.md +1 -1
- {dartsort-0.5.25 → dartsort-0.5.26}/notebook/fit_and_batch_matching.py +20 -7
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/mixture.py +10 -3
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/main.py +1 -1
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/matching_util/drifty.py +68 -35
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/matching_util/matching_base.py +2 -6
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/main_util.py +11 -2
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/spiketorch.py +8 -16
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort.egg-info/PKG-INFO +2 -2
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_drifty_matching.py +58 -5
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_modeling.py +139 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/.github/workflows/ci.yml +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/.github/workflows/ci_windows.yml +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/.github/workflows/deploy.yml +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/.github/workflows/docs.yml +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/.gitignore +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/docs/main_api.md +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/docs/toolkit_api.md +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/environment.yml +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/notebook/.keep +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/notebook/ibl_dandi_example.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/pyproject.toml +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/setup.cfg +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/__main__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/cli.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/agglomerate.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/cluster_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/clustering.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/clustering_features.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/density.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/forward_backward.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/kmeans.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/merge.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/clustering/refine_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/config.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/detect/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/detect/detect.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/evaluate/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/evaluate/analysis.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/evaluate/comparison.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/evaluate/hybrid_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/evaluate/hybridkit.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/evaluate/noise_recording_tools.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/evaluate/sim_template_tools.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/evaluate/simkit.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/evaluate/simlib.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/localize/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/localize/localize_torch.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/localize/localize_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/grab.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/matching.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/matching_util/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/matching_util/compressed_upsampled.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/matching_util/pairwise.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/matching_util/pairwise_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/peel_base.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/peel_lib.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/reduction_template.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/shaver.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/subtract.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/subtract_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/peel/threshold.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/pretrained/default_temporal_kernel.npy +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/pretrained/detect_np1.pt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/pretrained/detect_np2.pt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/pretrained/glasbey1024.npz +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/pretrained/offset_trained_denoiser.pt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/pretrained/offset_trained_denoiser_added_temp.pt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/pretrained/offset_trained_denoiser_added_temp_boost.pt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/pretrained/original_single_chan_denoiser.pt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/pretrained/single_chan_denoiser.pt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/templates/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/templates/get_templates.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/templates/postprocess_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/templates/realignment.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/templates/template_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/templates/templates.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/templates/templib.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/_multichan_denoiser_kit.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/all_transformers.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/amortized_localization.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/amplitudes.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/decollider.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/denoising_scorer.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/enforce_decrease.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/fixed_prop.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/interp.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/localize.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/matched_filter_net.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/matching_denoiser.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/mixture_classifier.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/pipeline.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/reduction.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/single_channel_denoiser.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/supervised_denoiser.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/temporal_pca.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/transform_base.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/vq_matched_filter.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/transform/whiten.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/cli_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/data_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/drift_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/internal_config.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/interpolation_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/job_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/logging_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/more_operators.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/motion.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/multiprocessing_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/nn_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/noise_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/peel_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/preprocess_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/py_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/registration_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/residual_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/sparse_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/spikeio.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/testing_util/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/testing_util/matching_debug_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/testing_util/mixture_testing_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/torch_optimization_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/torch_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/util/waveform_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/__init__.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/analysis_plots.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/colors.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/gt.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/layout.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/metrics_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/mixture.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/recanim.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/scatterplots.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/sorting.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/unit.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/unit_comparison.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/versus.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/vismain.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort/vis/waveforms.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort.egg-info/SOURCES.txt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort.egg-info/dependency_links.txt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort.egg-info/entry_points.txt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort.egg-info/requires.txt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/src/dartsort.egg-info/top_level.txt +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/conftest.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_agglomerate.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_alignment.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_cluster_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_clustering.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_clustering_features.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_config.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_dartsort.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_data_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_density.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_detect.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_drift_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_enforce_decrease.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_grab_and_featurize.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_hybridkit.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_kmeans.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_linalg.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_localize_torch.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_matching.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_mixture_classifier.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_simkit.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_spiketorch.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_subtract.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_templates.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_threshold.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_torch_optimization_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_transform.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/tests/test_waveform_util.py +0 -0
- {dartsort-0.5.25 → dartsort-0.5.26}/zensical.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dartsort
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.26
|
|
4
4
|
Summary: DARTsort
|
|
5
5
|
Author-email: Charlie Windolf <ciw2048@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/cwindolf/dartsort
|
|
@@ -48,7 +48,7 @@ Requires-Dist: matplotlib-venn; extra == "vis"
|
|
|
48
48
|
[](https://coveralls.io/github/cwindolf/dartsort)
|
|
49
49
|
[](https://doi.org/10.5281/zenodo.16943074)
|
|
50
50
|
[](https://pypi.org/p/dartsort)
|
|
51
|
-
[](https://dartsort.zulipchat.
|
|
51
|
+
[](https://dartsort.zulipchat.com)
|
|
52
52
|
|
|
53
53
|
# dartsort
|
|
54
54
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://coveralls.io/github/cwindolf/dartsort)
|
|
6
6
|
[](https://doi.org/10.5281/zenodo.16943074)
|
|
7
7
|
[](https://pypi.org/p/dartsort)
|
|
8
|
-
[](https://dartsort.zulipchat.
|
|
8
|
+
[](https://dartsort.zulipchat.com)
|
|
9
9
|
|
|
10
10
|
# dartsort
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://coveralls.io/github/cwindolf/dartsort)
|
|
6
6
|
[](https://doi.org/10.5281/zenodo.16943074)
|
|
7
7
|
[](https://pypi.org/p/dartsort)
|
|
8
|
-
[](https://dartsort.zulipchat.
|
|
8
|
+
[](https://dartsort.zulipchat.com)
|
|
9
9
|
|
|
10
10
|
# dartsort
|
|
11
11
|
|
|
@@ -117,11 +117,22 @@ plt.colorbar(shrink=0.5, label='standardized voltage')
|
|
|
117
117
|
plt.xlabel('time (samples')
|
|
118
118
|
plt.ylabel('channels');
|
|
119
119
|
|
|
120
|
+
# %% [markdown]
|
|
121
|
+
# # Configuration
|
|
122
|
+
|
|
123
|
+
# %%
|
|
124
|
+
# use defaults, except for the pipeline change
|
|
125
|
+
cfg = dartsort.DARTsortUserConfig(fit_matching_models_only=True)
|
|
126
|
+
|
|
127
|
+
# %%
|
|
128
|
+
# process into an internal config object for later use
|
|
129
|
+
internal_cfg = dartsort.to_internal_config(cfg)
|
|
130
|
+
|
|
120
131
|
# %% [markdown]
|
|
121
132
|
# # Fit models
|
|
122
133
|
|
|
123
134
|
# %%
|
|
124
|
-
dartsort.dartsort(rec, ds_dir, cfg=
|
|
135
|
+
dartsort.dartsort(rec, ds_dir, cfg=cfg)
|
|
125
136
|
|
|
126
137
|
# %%
|
|
127
138
|
# !ls {ds_dir}
|
|
@@ -153,7 +164,7 @@ for batch_ix, batch_start_samples in enumerate(range(0, duration_samples, 60 * 3
|
|
|
153
164
|
hdf5_filename=f"matching1_batch{batch_ix:05}.h5",
|
|
154
165
|
chunk_starts_samples=np.arange(batch_start_samples, batch_end_samples, 30_000),
|
|
155
166
|
load_simple_features=False, # ignoring the output, so don't load up extra stuff
|
|
156
|
-
featurization_cfg=
|
|
167
|
+
featurization_cfg=internal_cfg.matching_classifier_featurization_cfg,
|
|
157
168
|
motion=dartsort.try_load_motion_info(ds_dir),
|
|
158
169
|
)
|
|
159
170
|
del res
|
|
@@ -163,11 +174,13 @@ for batch_ix, batch_start_samples in enumerate(range(0, duration_samples, 60 * 3
|
|
|
163
174
|
#
|
|
164
175
|
# In this section, I'm grabbing all of the matching outputs and concatenating them.
|
|
165
176
|
# Then, I'm running *dartsort*'s standard postprocessing: a final merge step and a spike-train
|
|
166
|
-
# cleaning step (duplicate detection removal).
|
|
177
|
+
# cleaning step (duplicate detection removal). This is controlled by the `DARTsortUserConfig` flag `postprocessing`,
|
|
178
|
+
# which is `"agglomerate_and_clean"` by default.
|
|
167
179
|
#
|
|
168
|
-
# Users can change this. If you don't want to merge,
|
|
169
|
-
# run the cleaning step on each chunk before concatenating: the
|
|
170
|
-
# output, but the output of cleaning is the same when
|
|
180
|
+
# Users can change this. If you don't want to merge, set `postprocessing="clean"` in the configuration
|
|
181
|
+
# section above. In that case, you could run the cleaning step on each chunk before concatenating: the
|
|
182
|
+
# merge needs to agree across the batched matching output, but the output of cleaning is the same when
|
|
183
|
+
# run batchwise or on the full result.
|
|
171
184
|
#
|
|
172
185
|
# Here, extra features (amplitudes, localizations) are loaded by the default behavior of `dartsort.load`,
|
|
173
186
|
# which can be turned off for users who don't need them.
|
|
@@ -181,7 +194,7 @@ sorting = dartsort.cluster(
|
|
|
181
194
|
sorting,
|
|
182
195
|
motion=dartsort.try_load_motion_info(ds_dir),
|
|
183
196
|
clustering_cfg=None,
|
|
184
|
-
refinement_cfgs=
|
|
197
|
+
refinement_cfgs=internal_cfg.final_refinement_cfgs,
|
|
185
198
|
)
|
|
186
199
|
|
|
187
200
|
# %%
|
|
@@ -5518,11 +5518,10 @@ def tree_groups(
|
|
|
5518
5518
|
distances: Tensor, max_group_size: int, max_distance: float, link="complete"
|
|
5519
5519
|
) -> list[Tensor]:
|
|
5520
5520
|
"""Extract groups up to size max_group_size and (@link-linked) distances out to size max_distance."""
|
|
5521
|
-
device = distances.device
|
|
5522
5521
|
k = distances.shape[0]
|
|
5523
5522
|
if k <= max_group_size and distances.max() <= max_distance:
|
|
5524
5523
|
# this would be common when splitting.
|
|
5525
|
-
return [torch.arange(k
|
|
5524
|
+
return [torch.arange(k)]
|
|
5526
5525
|
|
|
5527
5526
|
if pnoid:
|
|
5528
5527
|
assert not distances.isnan().any()
|
|
@@ -7054,6 +7053,9 @@ def _bootstrap_top(
|
|
|
7054
7053
|
gen: torch.Generator,
|
|
7055
7054
|
batch_size: int = 1024,
|
|
7056
7055
|
):
|
|
7056
|
+
if n_candidates == 1:
|
|
7057
|
+
return
|
|
7058
|
+
|
|
7057
7059
|
# use a un_adj_lut index-dependent probability here to avoid re-using
|
|
7058
7060
|
# the current label
|
|
7059
7061
|
p = un_adj.T[un_adj_lut.b.neighb_ids]
|
|
@@ -7751,8 +7753,13 @@ def _score_batch(
|
|
|
7751
7753
|
)
|
|
7752
7754
|
|
|
7753
7755
|
if do_resp:
|
|
7754
|
-
|
|
7756
|
+
n_top = min(n_candidates, Ctot)
|
|
7757
|
+
toplls, topinds = torch.topk(lls[:, :-1], n_top, dim=1)
|
|
7755
7758
|
candidates = candidates.take_along_dim(indices=topinds, dim=1)
|
|
7759
|
+
if n_top < n_candidates:
|
|
7760
|
+
n_pad = n_candidates - n_top
|
|
7761
|
+
toplls = F.pad(toplls, (0, n_pad), value=-torch.inf)
|
|
7762
|
+
candidates = F.pad(candidates, (0, n_pad), value=-1)
|
|
7756
7763
|
toplls = torch.concatenate((toplls, lls[:, -1:]), dim=1)
|
|
7757
7764
|
else:
|
|
7758
7765
|
toplls = lls
|
|
@@ -140,7 +140,7 @@ def dartsort(
|
|
|
140
140
|
ds_handle_link_from(cfg, output_dir)
|
|
141
141
|
|
|
142
142
|
# preprocess
|
|
143
|
-
copy_rec_flag = ds_will_copy_recording(cfg)
|
|
143
|
+
copy_rec_flag = ds_will_copy_recording(cfg, recording)
|
|
144
144
|
recording = preprocess(
|
|
145
145
|
recording, cfg.preprocessing, cfg.already_preprocessed, cfg.preprocessing_dtype
|
|
146
146
|
)
|
|
@@ -10,11 +10,12 @@ Features
|
|
|
10
10
|
|
|
11
11
|
Strategy
|
|
12
12
|
- Pre-compute the convolutions of all pairs of temporal basis elements
|
|
13
|
-
across
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
(shared across units, since the template basis is shared)
|
|
14
|
+
- Pre-compute all pairs of units' inner products spatial components,
|
|
15
|
+
for each rank pair
|
|
16
|
+
- This is recomputed per chunk if there's drift
|
|
17
|
+
- Form the pairwise convolutions needed by each subtraction from these
|
|
18
|
+
two factors
|
|
18
19
|
|
|
19
20
|
Coarse-to-fine approach
|
|
20
21
|
- Objective is amplitude-scaled but not temporally upsampled
|
|
@@ -56,15 +57,10 @@ from ...util.logging_util import get_logger
|
|
|
56
57
|
from ...util.motion import MotionInfo
|
|
57
58
|
from ...util.noise_util import Whitener
|
|
58
59
|
from ...util.py_util import databag, panic
|
|
59
|
-
from ...util.spiketorch import
|
|
60
|
+
from ...util.spiketorch import shared_temporal_pconv, spatial_gram
|
|
60
61
|
from ...util.torch_util import torch_compiler
|
|
61
62
|
from ...util.waveform_util import upsample_singlechan_torch
|
|
62
|
-
from .matching_base import
|
|
63
|
-
ChunkTemplateData,
|
|
64
|
-
MatchingPeaks,
|
|
65
|
-
MatchingTemplates,
|
|
66
|
-
subtract_precomputed_pconv,
|
|
67
|
-
)
|
|
63
|
+
from .matching_base import ChunkTemplateData, MatchingPeaks, MatchingTemplates
|
|
68
64
|
|
|
69
65
|
logger = get_logger(__name__)
|
|
70
66
|
|
|
@@ -149,6 +145,8 @@ class DriftyMatchingTemplates(MatchingTemplates):
|
|
|
149
145
|
conv_up_temporal_comps = up_temporal_comps
|
|
150
146
|
norm_discount = None
|
|
151
147
|
tconv = shared_temporal_pconv(conv_temporal_comps, conv_up_temporal_comps)
|
|
148
|
+
# up, rank * rank, lags
|
|
149
|
+
up_major_tconv = tconv.permute(2, 0, 1, 3).reshape(up_factor, rank * rank, -1)
|
|
152
150
|
|
|
153
151
|
assert temporal_comps.shape == (rank, self.spike_length_samples)
|
|
154
152
|
self.register_buffer("conv_temporal_comps", conv_temporal_comps.contiguous())
|
|
@@ -161,7 +159,7 @@ class DriftyMatchingTemplates(MatchingTemplates):
|
|
|
161
159
|
up_major_temporal_comps = up_temporal_comps.permute(1, 0, 2).contiguous()
|
|
162
160
|
self.register_buffer_or_none("up_major_temporal_comps", up_major_temporal_comps)
|
|
163
161
|
self.register_buffer("spatial_sing", spatial_sing.contiguous())
|
|
164
|
-
self.register_buffer("
|
|
162
|
+
self.register_buffer("up_major_tconv", up_major_tconv.contiguous())
|
|
165
163
|
if unit_ids is None:
|
|
166
164
|
unit_ids = torch.arange(self.n_units, device=device)
|
|
167
165
|
self.register_buffer("unit_ids", unit_ids)
|
|
@@ -188,17 +186,14 @@ class DriftyMatchingTemplates(MatchingTemplates):
|
|
|
188
186
|
conv_spatial_sing = conv_spatial_sing.contiguous()
|
|
189
187
|
self.register_buffer_or_none("conv_spatial_sing", conv_spatial_sing)
|
|
190
188
|
|
|
191
|
-
#
|
|
192
|
-
if
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
pconv = full_shared_pconv(self.b.tconv, self.b.conv_spatial_sing)
|
|
197
|
-
else:
|
|
198
|
-
pconv = full_shared_pconv(self.b.tconv, self.b.spatial_sing)
|
|
189
|
+
# spatial gram can be precomputed when not interpolating
|
|
190
|
+
if self.interpolating:
|
|
191
|
+
sgram = None
|
|
192
|
+
elif self.whiten_strategy == "prewhiten_postapply":
|
|
193
|
+
sgram = spatial_gram(self.b.conv_spatial_sing)
|
|
199
194
|
else:
|
|
200
|
-
|
|
201
|
-
self.register_buffer_or_none("
|
|
195
|
+
sgram = spatial_gram(self.b.spatial_sing)
|
|
196
|
+
self.register_buffer_or_none("sgram", sgram)
|
|
202
197
|
|
|
203
198
|
# indexing helpers
|
|
204
199
|
t = self.spike_length_samples
|
|
@@ -325,15 +320,15 @@ class DriftyMatchingTemplates(MatchingTemplates):
|
|
|
325
320
|
normsq = normsq_by_chan.sum(dim=1)
|
|
326
321
|
|
|
327
322
|
# normsq is always the pconv one
|
|
328
|
-
if self.b.
|
|
329
|
-
|
|
323
|
+
if self.b.sgram is None:
|
|
324
|
+
sgram = spatial_gram(normsq_spatial_sing)
|
|
330
325
|
else:
|
|
331
|
-
|
|
326
|
+
sgram = self.b.sgram
|
|
332
327
|
|
|
333
328
|
# padded spatial sing is used for clean wfs only
|
|
334
329
|
padded_spatial_sing = F.pad(spatial_sing, (0, 1))
|
|
335
330
|
|
|
336
|
-
return conv_spatial_sing, normsq, main_channels, padded_spatial_sing,
|
|
331
|
+
return conv_spatial_sing, normsq, main_channels, padded_spatial_sing, sgram
|
|
337
332
|
|
|
338
333
|
def data_at_time(
|
|
339
334
|
self,
|
|
@@ -346,7 +341,7 @@ class DriftyMatchingTemplates(MatchingTemplates):
|
|
|
346
341
|
scale_max: float,
|
|
347
342
|
resid_offset: int,
|
|
348
343
|
) -> ChunkTemplateData:
|
|
349
|
-
spatial_sing, normsq, main_channels, padded_spatial_sing,
|
|
344
|
+
spatial_sing, normsq, main_channels, padded_spatial_sing, sgram = (
|
|
350
345
|
self.spatial_at_time(t_s=t_s)
|
|
351
346
|
)
|
|
352
347
|
obj_normsq_plus_inv_lambda = normsq[:, None] + inv_lambda
|
|
@@ -374,7 +369,8 @@ class DriftyMatchingTemplates(MatchingTemplates):
|
|
|
374
369
|
conv_temporal_comps=self.b.conv_temporal_comps,
|
|
375
370
|
up_major_temporal_comps=self.b.up_major_temporal_comps,
|
|
376
371
|
spatial_sing=spatial_sing,
|
|
377
|
-
|
|
372
|
+
sgram=sgram,
|
|
373
|
+
up_major_tconv=self.b.up_major_tconv,
|
|
378
374
|
time_ix=self.b.time_ix,
|
|
379
375
|
sub_time_ix=self.b.sub_time_ix + resid_offset,
|
|
380
376
|
chan_ix=self.b.chan_ix,
|
|
@@ -412,7 +408,8 @@ class DriftyChunkTemplateData(ChunkTemplateData):
|
|
|
412
408
|
up_major_temporal_comps: Tensor
|
|
413
409
|
spatial_sing: Tensor
|
|
414
410
|
padded_spatial_sing: Tensor
|
|
415
|
-
|
|
411
|
+
sgram: Tensor
|
|
412
|
+
up_major_tconv: Tensor
|
|
416
413
|
spatial_whitener: Whitener | None
|
|
417
414
|
|
|
418
415
|
time_ix: Tensor
|
|
@@ -479,14 +476,14 @@ class DriftyChunkTemplateData(ChunkTemplateData):
|
|
|
479
476
|
)
|
|
480
477
|
|
|
481
478
|
def subtract_conv(
|
|
482
|
-
self, conv: Tensor, peaks: "MatchingPeaks", padding=0, batch_size=
|
|
479
|
+
self, conv: Tensor, peaks: "MatchingPeaks", padding=0, batch_size=128, sign=-1
|
|
483
480
|
):
|
|
484
|
-
|
|
481
|
+
_subtract_kron_pconv(
|
|
485
482
|
conv=conv,
|
|
486
|
-
|
|
483
|
+
sgram=self.sgram,
|
|
484
|
+
up_major_tconv=self.up_major_tconv,
|
|
487
485
|
peaks=peaks,
|
|
488
|
-
|
|
489
|
-
conv_lags=self.conv_lags,
|
|
486
|
+
padded_conv_lags=padding + self.conv_lags,
|
|
490
487
|
sign=sign,
|
|
491
488
|
batch_size=batch_size,
|
|
492
489
|
)
|
|
@@ -705,6 +702,42 @@ def convolve_lowrank_shared(
|
|
|
705
702
|
return out
|
|
706
703
|
|
|
707
704
|
|
|
705
|
+
def _subtract_kron_pconv(
|
|
706
|
+
*,
|
|
707
|
+
conv: Tensor,
|
|
708
|
+
sgram: Tensor,
|
|
709
|
+
up_major_tconv: Tensor,
|
|
710
|
+
peaks: MatchingPeaks,
|
|
711
|
+
padded_conv_lags: Tensor,
|
|
712
|
+
sign: int,
|
|
713
|
+
batch_size: int,
|
|
714
|
+
):
|
|
715
|
+
assert sign in (-1, 1)
|
|
716
|
+
if not peaks.n_spikes:
|
|
717
|
+
return
|
|
718
|
+
assert peaks.times is not None
|
|
719
|
+
assert peaks.template_inds is not None
|
|
720
|
+
n_units = conv.shape[0]
|
|
721
|
+
n_spikes = peaks.n_spikes
|
|
722
|
+
_, rank_sq, n_lags = up_major_tconv.shape
|
|
723
|
+
assert sgram.shape == (n_units, n_units, rank_sq)
|
|
724
|
+
assert padded_conv_lags.shape == (n_lags,)
|
|
725
|
+
|
|
726
|
+
if peaks.up_inds is None:
|
|
727
|
+
spike_tconv = up_major_tconv[0].broadcast_to(n_spikes, rank_sq, n_lags)
|
|
728
|
+
else:
|
|
729
|
+
spike_tconv = up_major_tconv[peaks.up_inds]
|
|
730
|
+
if peaks.scalings is not None:
|
|
731
|
+
spike_tconv = spike_tconv * peaks.scalings[:, None, None]
|
|
732
|
+
|
|
733
|
+
ix_time = (peaks.times[:, None] + padded_conv_lags).view(-1)
|
|
734
|
+
for i0 in range(0, n_units, batch_size):
|
|
735
|
+
i1 = min(n_units, i0 + batch_size)
|
|
736
|
+
batch = torch.bmm(sgram[peaks.template_inds, i0:i1], spike_tconv)
|
|
737
|
+
batch = batch.permute(1, 0, 2).reshape(i1 - i0, n_spikes * n_lags)
|
|
738
|
+
conv[i0:i1].index_add_(dim=1, index=ix_time, source=batch, alpha=sign)
|
|
739
|
+
|
|
740
|
+
|
|
708
741
|
# -- fine matching
|
|
709
742
|
|
|
710
743
|
|
|
@@ -209,12 +209,8 @@ class ChunkTemplateData:
|
|
|
209
209
|
def unsubtract(self, traces: Tensor, peaks: "MatchingPeaks"):
|
|
210
210
|
return self.subtract(traces, peaks, sign=1)
|
|
211
211
|
|
|
212
|
-
def unsubtract_conv(
|
|
213
|
-
self
|
|
214
|
-
):
|
|
215
|
-
return self.subtract_conv(
|
|
216
|
-
conv=conv, peaks=peaks, padding=padding, batch_size=batch_size, sign=1
|
|
217
|
-
)
|
|
212
|
+
def unsubtract_conv(self, conv: Tensor, peaks: "MatchingPeaks", padding=0):
|
|
213
|
+
return self.subtract_conv(conv=conv, peaks=peaks, padding=padding, sign=1)
|
|
218
214
|
|
|
219
215
|
def obj_from_conv(
|
|
220
216
|
self,
|
|
@@ -118,8 +118,17 @@ def ds_dump_config(internal_cfg: DARTsortInternalConfig, output_dir: Path):
|
|
|
118
118
|
logger.info(f"Recorded config to {json_path}.")
|
|
119
119
|
|
|
120
120
|
|
|
121
|
-
def ds_will_copy_recording(internal_cfg: DARTsortInternalConfig):
|
|
121
|
+
def ds_will_copy_recording(internal_cfg: DARTsortInternalConfig, recording: BaseRecording):
|
|
122
122
|
if internal_cfg.copy_recording_to_tmpdir == "if_preprocessing":
|
|
123
|
+
if internal_cfg.already_preprocessed == "yes":
|
|
124
|
+
return False
|
|
125
|
+
elif internal_cfg.already_preprocessed == "assume_yes_if_float":
|
|
126
|
+
if recording.dtype.kind == "f":
|
|
127
|
+
return False
|
|
128
|
+
elif internal_cfg.already_preprocessed == "no":
|
|
129
|
+
return True
|
|
130
|
+
else:
|
|
131
|
+
panic(internal_cfg.already_preprocessed)
|
|
123
132
|
return internal_cfg.preprocessing != "none"
|
|
124
133
|
elif internal_cfg.copy_recording_to_tmpdir == "yes":
|
|
125
134
|
return True
|
|
@@ -140,7 +149,7 @@ def ds_all_to_workdir(
|
|
|
140
149
|
sort_subdir="dartsort",
|
|
141
150
|
) -> tuple[BaseRecording, Path | None]:
|
|
142
151
|
"""Copy stuff to temporary working directory, if there is one."""
|
|
143
|
-
copy_rec = ds_will_copy_recording(internal_cfg)
|
|
152
|
+
copy_rec = ds_will_copy_recording(internal_cfg, recording)
|
|
144
153
|
|
|
145
154
|
if work_dir is None:
|
|
146
155
|
assert not internal_cfg.work_in_tmpdir
|
|
@@ -263,26 +263,18 @@ def shared_temporal_pconv(temporal_comps: Tensor, up_temporal_comps: Tensor) ->
|
|
|
263
263
|
|
|
264
264
|
|
|
265
265
|
@torch_compile
|
|
266
|
-
def
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
n_units, rank__, chans = spatial_sing.shape
|
|
271
|
-
assert rank == rank_ == rank__
|
|
272
|
-
out = spatial_sing.new_empty((n_units, n_units, up, conv_len))
|
|
273
|
-
spatial_sing_flat = spatial_sing.view(n_units * rank, chans)
|
|
274
|
-
tconv_flat = tconv.view(rank * rank, up * conv_len)
|
|
266
|
+
def spatial_gram(spatial_sing: Tensor, batch_size: int = 128) -> Tensor:
|
|
267
|
+
n_units, rank, chans = spatial_sing.shape
|
|
268
|
+
spatial_sing_flat = spatial_sing.reshape(n_units * rank, chans)
|
|
269
|
+
gram = spatial_sing.new_empty((n_units, n_units, rank * rank))
|
|
275
270
|
|
|
276
271
|
for i0 in range(0, n_units, batch_size):
|
|
277
272
|
i1 = min(n_units, i0 + batch_size)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
spatial_outer = spatial_outer.view(i1 - i0, rank, n_units, rank)
|
|
282
|
-
spatial_outer = spatial_outer.permute(0, 2, 1, 3).reshape(chunksz, rank * rank)
|
|
283
|
-
torch.mm(spatial_outer, tconv_flat, out=out[i0:i1].view(chunksz, up * conv_len))
|
|
273
|
+
outer = spatial_sing_flat[i0 * rank : i1 * rank] @ spatial_sing_flat.T
|
|
274
|
+
outer = outer.view(i1 - i0, rank, n_units, rank).permute(0, 2, 3, 1)
|
|
275
|
+
gram[i0:i1].view(i1 - i0, n_units, rank, rank).copy_(outer)
|
|
284
276
|
|
|
285
|
-
return
|
|
277
|
+
return gram
|
|
286
278
|
|
|
287
279
|
|
|
288
280
|
@torch_compile
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dartsort
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.26
|
|
4
4
|
Summary: DARTsort
|
|
5
5
|
Author-email: Charlie Windolf <ciw2048@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/cwindolf/dartsort
|
|
@@ -48,7 +48,7 @@ Requires-Dist: matplotlib-venn; extra == "vis"
|
|
|
48
48
|
[](https://coveralls.io/github/cwindolf/dartsort)
|
|
49
49
|
[](https://doi.org/10.5281/zenodo.16943074)
|
|
50
50
|
[](https://pypi.org/p/dartsort)
|
|
51
|
-
[](https://dartsort.zulipchat.
|
|
51
|
+
[](https://dartsort.zulipchat.com)
|
|
52
52
|
|
|
53
53
|
# dartsort
|
|
54
54
|
|
|
@@ -4,9 +4,13 @@ import torch
|
|
|
4
4
|
import torch.nn.functional as F
|
|
5
5
|
|
|
6
6
|
from dartsort.peel.matching_util import drifty
|
|
7
|
+
from dartsort.peel.matching_util.matching_base import (
|
|
8
|
+
MatchingPeaks,
|
|
9
|
+
subtract_precomputed_pconv,
|
|
10
|
+
)
|
|
7
11
|
from dartsort.util.testing_util import matching_debug_util
|
|
8
12
|
|
|
9
|
-
test_K = 11
|
|
13
|
+
test_K = 11 # noqa: N816
|
|
10
14
|
test_template_nc = [1, 4]
|
|
11
15
|
|
|
12
16
|
|
|
@@ -28,7 +32,7 @@ def test_shared_temporal_pconv(K, up):
|
|
|
28
32
|
@pytest.mark.parametrize("nc", [1, 5, -1])
|
|
29
33
|
@pytest.mark.parametrize("up", [1, 2, 4, 16])
|
|
30
34
|
@pytest.mark.parametrize("K", [1, 2, 5])
|
|
31
|
-
def
|
|
35
|
+
def test_kron_pconv(K, up, nc, rank, t):
|
|
32
36
|
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
33
37
|
rg = np.random.default_rng(0)
|
|
34
38
|
|
|
@@ -93,9 +97,10 @@ def test_full_shared_pconv(K, up, nc, rank, t):
|
|
|
93
97
|
"ipc,pqul,jqc->ijul", spatial_sing_, tconv1_, spatial_sing_
|
|
94
98
|
)
|
|
95
99
|
full_pconv1 = full_pconv1_.numpy(force=True)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
)
|
|
100
|
+
sgram_ = drifty.spatial_gram(spatial_sing_, batch_size=max(2, K // 2))
|
|
101
|
+
assert sgram_.shape == (K, K, rank * rank)
|
|
102
|
+
up_major_tconv_ = tconv1_.permute(2, 0, 1, 3).reshape(up, rank * rank, -1)
|
|
103
|
+
full_pconv2_ = torch.einsum("bak,jkl->abjl", sgram_, up_major_tconv_)
|
|
99
104
|
full_pconv2 = full_pconv2_.numpy(force=True)
|
|
100
105
|
|
|
101
106
|
if ortho:
|
|
@@ -113,6 +118,54 @@ def test_full_shared_pconv(K, up, nc, rank, t):
|
|
|
113
118
|
full_pconv0, full_pconv2, atol=4 * max(pconv_atol, gpu_pconv_atol, 5e-7)
|
|
114
119
|
)
|
|
115
120
|
|
|
121
|
+
# conv updates agree with dense pconv
|
|
122
|
+
n_spikes = 6
|
|
123
|
+
conv_len = 8 * t
|
|
124
|
+
conv_lags = torch.arange(-t + 1, t, device=device)
|
|
125
|
+
for with_up_scale in (False, True):
|
|
126
|
+
times = rg.integers(0, conv_len - 2 * t, size=n_spikes)
|
|
127
|
+
peaks = MatchingPeaks(
|
|
128
|
+
times=torch.asarray(times, device=device),
|
|
129
|
+
template_inds=torch.asarray(rg.integers(K, size=n_spikes), device=device),
|
|
130
|
+
up_inds=(
|
|
131
|
+
torch.asarray(rg.integers(up, size=n_spikes), device=device)
|
|
132
|
+
if with_up_scale
|
|
133
|
+
else None
|
|
134
|
+
),
|
|
135
|
+
scalings=(
|
|
136
|
+
torch.asarray(rg.uniform(0.5, 1.5, size=n_spikes), device=device).float()
|
|
137
|
+
if with_up_scale
|
|
138
|
+
else None
|
|
139
|
+
),
|
|
140
|
+
scores=torch.zeros(n_spikes, device=device),
|
|
141
|
+
)
|
|
142
|
+
conv_dense = torch.zeros((K, conv_len), device=device)
|
|
143
|
+
subtract_precomputed_pconv(
|
|
144
|
+
conv=conv_dense,
|
|
145
|
+
pconv=full_pconv1_,
|
|
146
|
+
peaks=peaks,
|
|
147
|
+
conv_lags=conv_lags,
|
|
148
|
+
sign=-1,
|
|
149
|
+
padding=t,
|
|
150
|
+
batch_size=max(2, K // 2),
|
|
151
|
+
)
|
|
152
|
+
conv_kron = torch.zeros((K, conv_len), device=device)
|
|
153
|
+
drifty._subtract_kron_pconv(
|
|
154
|
+
conv=conv_kron,
|
|
155
|
+
sgram=sgram_,
|
|
156
|
+
up_major_tconv=up_major_tconv_,
|
|
157
|
+
peaks=peaks,
|
|
158
|
+
padded_conv_lags=t + conv_lags,
|
|
159
|
+
sign=-1,
|
|
160
|
+
batch_size=max(2, K // 2),
|
|
161
|
+
)
|
|
162
|
+
conv_dense = conv_dense.numpy(force=True)
|
|
163
|
+
conv_kron = conv_kron.numpy(force=True)
|
|
164
|
+
assert np.abs(conv_dense).max() > 0
|
|
165
|
+
np.testing.assert_allclose(
|
|
166
|
+
conv_kron, conv_dense, atol=1e-5 * np.abs(conv_dense).max()
|
|
167
|
+
)
|
|
168
|
+
|
|
116
169
|
|
|
117
170
|
@pytest.mark.parametrize("deg", [1, 2, 3])
|
|
118
171
|
@pytest.mark.parametrize("radius", [8])
|