DARTsort 0.5.11__tar.gz → 0.5.13__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.11 → dartsort-0.5.13}/PKG-INFO +1 -1
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/agglomerate.py +6 -9
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/clustering.py +22 -3
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/clustering_features.py +70 -22
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/kmeans.py +1 -7
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/mixture.py +69 -42
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/refine_util.py +38 -141
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/config.py +2 -2
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/evaluate/analysis.py +9 -1
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/evaluate/comparison.py +2 -2
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/evaluate/simkit.py +24 -15
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/grab.py +2 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/matching.py +13 -1
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/peel_base.py +2 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/amortized_localization.py +3 -3
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/decollider.py +2 -2
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/mixture_classifier.py +102 -72
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/reduction.py +0 -1
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/temporal_pca.py +15 -3
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/data_util.py +38 -11
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/internal_config.py +3 -2
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/motion.py +10 -1
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/multiprocessing_util.py +1 -1
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/noise_util.py +18 -2
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/registration_util.py +13 -2
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/analysis_plots.py +100 -7
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/mixture.py +28 -7
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/scatterplots.py +1 -1
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/vismain.py +2 -2
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort.egg-info/PKG-INFO +1 -1
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort.egg-info/SOURCES.txt +1 -52
- dartsort-0.5.13/tests/test_agglomerate.py +35 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_dartsort.py +3 -2
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_data_util.py +1 -0
- dartsort-0.5.13/tests/test_mixture_classifier.py +138 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_simkit.py +1 -1
- dartsort-0.5.11/notebook/basic_integration_test.py +0 -137
- dartsort-0.5.11/notebook/ci diag.py +0 -573
- dartsort-0.5.11/notebook/dartsort_dredge_demo.ipynb +0 -437
- dartsort-0.5.11/notebook/dartsort_dredge_demo.py +0 -144
- dartsort-0.5.11/notebook/data test.py +0 -259
- dartsort-0.5.11/notebook/dead reckoning.py +0 -361
- dartsort-0.5.11/notebook/denoise np1.py +0 -356
- dartsort-0.5.11/notebook/denoise np2.py +0 -480
- dartsort-0.5.11/notebook/exploratory.py +0 -431
- dartsort-0.5.11/notebook/geom debug.py +0 -167
- dartsort-0.5.11/notebook/hdbscan_clustering_5min.py +0 -1294
- dartsort-0.5.11/notebook/hybrid 10.py +0 -1662
- dartsort-0.5.11/notebook/hybrid cluster.py +0 -475
- dartsort-0.5.11/notebook/hybrid_11.py +0 -1214
- dartsort-0.5.11/notebook/initial training.py +0 -162
- dartsort-0.5.11/notebook/make hybrid.py +0 -1376
- dartsort-0.5.11/notebook/mgh.py +0 -514
- dartsort-0.5.11/notebook/np1 feats.py +0 -1211
- dartsort-0.5.11/notebook/np2 processing version c.py +0 -321
- dartsort-0.5.11/notebook/paperfigs.py +0 -907
- dartsort-0.5.11/notebook/pdists.py +0 -641
- dartsort-0.5.11/notebook/postcheck.py +0 -803
- dartsort-0.5.11/notebook/ptp vae.py +0 -206
- dartsort-0.5.11/notebook/re clust.py +0 -893
- dartsort-0.5.11/notebook/reg fig loop.py +0 -723
- dartsort-0.5.11/notebook/reg_sim_exp.py +0 -493
- dartsort-0.5.11/notebook/relocating.py +0 -284
- dartsort-0.5.11/notebook/relocating_all.py +0 -182
- dartsort-0.5.11/notebook/restats +0 -0
- dartsort-0.5.11/notebook/sortStinger1.py +0 -1590
- dartsort-0.5.11/notebook/sortStinger3.py +0 -1541
- dartsort-0.5.11/notebook/sortStinger4.py +0 -1835
- dartsort-0.5.11/notebook/sortStinger5.py +0 -1586
- dartsort-0.5.11/notebook/sortStinger6.py +0 -1915
- dartsort-0.5.11/notebook/spike farm.py +0 -100
- dartsort-0.5.11/notebook/ss_ensemble_sim.py +0 -1965
- dartsort-0.5.11/notebook/ss_ensemble_sim_drift.py +0 -1928
- dartsort-0.5.11/notebook/ss_sim.py +0 -1965
- dartsort-0.5.11/notebook/stan diagnostics.py +0 -207
- dartsort-0.5.11/notebook/storytelling c.py +0 -686
- dartsort-0.5.11/notebook/storytelling.py +0 -684
- dartsort-0.5.11/notebook/subtract_with_phaseshift_denoiser.py +0 -260
- dartsort-0.5.11/notebook/tests/debug_matching.py +0 -454
- dartsort-0.5.11/notebook/tests/test_agreement.py +0 -367
- dartsort-0.5.11/notebook/tests/test_amplitude_scaling.py +0 -737
- dartsort-0.5.11/notebook/tests/test_batch_optim.py +0 -679
- dartsort-0.5.11/notebook/tests/test_ibme.py +0 -86
- dartsort-0.5.11/notebook/tests/test_mm_initialization.py +0 -142
- dartsort-0.5.11/notebook/tests/test_normxcorr1d.py +0 -63
- dartsort-0.5.11/notebook/tests/test_reassignment.py +0 -422
- dartsort-0.5.11/notebook/tests/test_relocation.py +0 -230
- dartsort-0.5.11/notebook/thomas.py +0 -1004
- dartsort-0.5.11/tests/test_mixture_classifier.py +0 -65
- {dartsort-0.5.11 → dartsort-0.5.13}/.github/workflows/ci.yml +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/.github/workflows/ci_windows.yml +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/.github/workflows/deploy.yml +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/.github/workflows/docs.yml +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/.gitignore +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/README.md +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/docs/index.md +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/docs/main_api.md +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/docs/toolkit_api.md +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/environment.yml +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/notebook/.keep +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/pyproject.toml +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/setup.cfg +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/__init__.py +2 -2
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/cli.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/cluster_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/density.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/forward_backward.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/merge.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/clustering/modes.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/detect/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/detect/detect.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/detect/detect_filters.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/evaluate/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/evaluate/hybrid_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/evaluate/noise_recording_tools.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/evaluate/sim_template_tools.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/evaluate/simlib.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/localize/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/localize/localize_torch.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/localize/localize_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/main.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/matching_util/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/matching_util/compressed_upsampled.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/matching_util/drifty.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/matching_util/matching_base.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/matching_util/pairwise.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/matching_util/pairwise_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/peel_lib.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/reduction_template.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/shaver.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/subtract.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/peel/threshold.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/pretrained/default_temporal_kernel.npy +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/pretrained/detect_np1.pt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/pretrained/detect_np2.pt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/pretrained/glasbey1024.npz +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/pretrained/offset_trained_denoiser.pt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/pretrained/offset_trained_denoiser_added_temp.pt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/pretrained/offset_trained_denoiser_added_temp_boost.pt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/pretrained/original_single_chan_denoiser.pt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/pretrained/single_chan_denoiser.pt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/templates/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/templates/get_templates.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/templates/postprocess_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/templates/realignment.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/templates/template_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/templates/templates.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/templates/templib.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/_multichan_denoiser_kit.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/all_transformers.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/amplitudes.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/denoising_scorer.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/enforce_decrease.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/fixed_prop.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/interp.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/localize.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/matching_denoiser.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/pipeline.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/single_channel_denoiser.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/supervised_denoiser.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/transform_base.py +2 -2
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/transform/whiten.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/cli_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/drift_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/interpolation_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/job_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/logging_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/main_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/more_operators.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/nn_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/peel_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/preprocess_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/py_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/residual_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/sparse_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/spikeio.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/spiketorch.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/testing_util/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/testing_util/matching_debug_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/testing_util/mixture_testing_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/torch_optimization_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/torch_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/util/waveform_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/__init__.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/colors.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/gt.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/layout.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/metrics_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/recanim.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/sorting.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/unit.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/unit_comparison.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/versus.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort/vis/waveforms.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort.egg-info/dependency_links.txt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort.egg-info/entry_points.txt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort.egg-info/requires.txt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/src/dartsort.egg-info/top_level.txt +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/conftest.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_alignment.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_cluster_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_clustering.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_config.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_density.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_detect.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_drift_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_drifty_matching.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_enforce_decrease.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_grab_and_featurize.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_kmeans.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_linalg.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_localize_torch.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_matching.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_modeling.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_spiketorch.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_subtract.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_templates.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_threshold.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_torch_optimization_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_transform.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/tests/test_waveform_util.py +0 -0
- {dartsort-0.5.11 → dartsort-0.5.13}/zensical.toml +0 -0
|
@@ -211,7 +211,7 @@ def agglomerate(
|
|
|
211
211
|
agg_sorting = deduplicate_spikes(agg_sorting, refinement_cfg.dedup_ms)
|
|
212
212
|
|
|
213
213
|
agg_sorting, reorder = reorder_by_depth(agg_sorting, motion=motion)
|
|
214
|
-
new_ids = reorder[new_ids]
|
|
214
|
+
new_ids = reorder[np.unique(new_ids, return_inverse=True)[1]]
|
|
215
215
|
|
|
216
216
|
return Agglomeration(
|
|
217
217
|
agglomerated_sorting=agg_sorting,
|
|
@@ -770,7 +770,7 @@ def combine_gmm_scores(
|
|
|
770
770
|
**{
|
|
771
771
|
f"{new_prefix}_candidates": candidates,
|
|
772
772
|
f"{new_prefix}_responsibilities": responsibilities,
|
|
773
|
-
f"{new_prefix}
|
|
773
|
+
f"{new_prefix}_log_liks": logliks,
|
|
774
774
|
}
|
|
775
775
|
)
|
|
776
776
|
|
|
@@ -826,7 +826,7 @@ def combine_gmm_scores(
|
|
|
826
826
|
**{
|
|
827
827
|
f"{new_prefix}_candidates": cand,
|
|
828
828
|
f"{new_prefix}_responsibilities": mergedr,
|
|
829
|
-
f"{new_prefix}
|
|
829
|
+
f"{new_prefix}_log_liks": mergedl,
|
|
830
830
|
},
|
|
831
831
|
)
|
|
832
832
|
|
|
@@ -873,11 +873,6 @@ def deduplicate_spikes(
|
|
|
873
873
|
radius_ms: float = -1.0,
|
|
874
874
|
score_by=("merged_log_liks", "gmm_log_liks", "scores"),
|
|
875
875
|
) -> DARTsortSorting:
|
|
876
|
-
"""The lower-scoring of any spikes within radius_samples of each other is relabeled to -1.
|
|
877
|
-
|
|
878
|
-
scores are grabbed from the first entry of score_by which is a valid property of the sorting.
|
|
879
|
-
If it's mu
|
|
880
|
-
"""
|
|
881
876
|
if radius_ms < 0 or sorting.labels is None:
|
|
882
877
|
return sorting
|
|
883
878
|
|
|
@@ -957,7 +952,9 @@ def _dedup_unit_loop(
|
|
|
957
952
|
score_slice = scores[i0 : i1 + 1]
|
|
958
953
|
dt_slice = dt[i0:i1]
|
|
959
954
|
order = np.argsort(score_slice)
|
|
960
|
-
|
|
955
|
+
# putting the -1 there ensures at least one spike is kept
|
|
956
|
+
# that case is only relevant when 0 in dt_slice
|
|
957
|
+
for oo in order[:-1]:
|
|
961
958
|
# discard spike i0 + oo
|
|
962
959
|
ii = i0 + oo
|
|
963
960
|
discard[ii] = True
|
|
@@ -155,10 +155,23 @@ class Clusterer:
|
|
|
155
155
|
def handle_sampling(
|
|
156
156
|
self, features: SimpleMatrixFeatures
|
|
157
157
|
) -> tuple[Literal[False], slice] | tuple[Literal[True], np.ndarray]:
|
|
158
|
+
if features.keep_mask is not None:
|
|
159
|
+
mask_ix = np.flatnonzero(features.keep_mask)
|
|
160
|
+
else:
|
|
161
|
+
mask_ix = None
|
|
158
162
|
if self.sampling_cfg is None:
|
|
159
|
-
|
|
163
|
+
if mask_ix is not None:
|
|
164
|
+
return True, mask_ix
|
|
165
|
+
else:
|
|
166
|
+
return False, slice(None)
|
|
160
167
|
elif features.n <= self.sampling_cfg.n_waveforms_fit:
|
|
161
|
-
|
|
168
|
+
if mask_ix is not None:
|
|
169
|
+
return True, mask_ix
|
|
170
|
+
else:
|
|
171
|
+
return False, slice(None)
|
|
172
|
+
|
|
173
|
+
if mask_ix is not None:
|
|
174
|
+
features = features.mask(mask_ix)
|
|
162
175
|
|
|
163
176
|
weights = fit_reweighting(
|
|
164
177
|
voltages=features.signed_amplitudes,
|
|
@@ -173,6 +186,8 @@ class Clusterer:
|
|
|
173
186
|
replace=False,
|
|
174
187
|
)
|
|
175
188
|
ixs.sort()
|
|
189
|
+
if mask_ix is not None:
|
|
190
|
+
ixs = mask_ix[ixs]
|
|
176
191
|
return True, ixs
|
|
177
192
|
|
|
178
193
|
def cluster(
|
|
@@ -432,16 +447,20 @@ class DensityPeaksClusterer(Clusterer):
|
|
|
432
447
|
kdtree = res["kdtree"]
|
|
433
448
|
assert isinstance(ixs, np.ndarray)
|
|
434
449
|
rest = np.setdiff1d(np.arange(len(X)), ixs)
|
|
450
|
+
Xr = X[rest]
|
|
451
|
+
isna = np.isnan(Xr).any(axis=1)
|
|
452
|
+
np.nan_to_num(Xr, copy=False)
|
|
435
453
|
other_labels = density.nearest_neighbor_assign(
|
|
436
454
|
kdtree,
|
|
437
455
|
res["labels"],
|
|
438
|
-
|
|
456
|
+
Xr,
|
|
439
457
|
radius_search=self.radius_search,
|
|
440
458
|
workers=self.workers,
|
|
441
459
|
)
|
|
442
460
|
labels = cluster_util.combine_disjoint(
|
|
443
461
|
ixs, res["labels"], rest, other_labels
|
|
444
462
|
)
|
|
463
|
+
labels[rest[isna]] = -1
|
|
445
464
|
else:
|
|
446
465
|
kdtree = None
|
|
447
466
|
labels = res["labels"]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from typing import Self, cast
|
|
2
|
+
from logging import WARN
|
|
2
3
|
|
|
3
4
|
import h5py
|
|
4
5
|
import numpy as np
|
|
@@ -38,9 +39,14 @@ class SimpleMatrixFeatures:
|
|
|
38
39
|
xyza: np.ndarray | None
|
|
39
40
|
signed_amplitudes: np.ndarray
|
|
40
41
|
amplitudes: np.ndarray
|
|
42
|
+
keep_mask: np.ndarray | None
|
|
41
43
|
|
|
42
44
|
def mask(self, mask) -> Self:
|
|
43
45
|
a = self.amplitudes[mask]
|
|
46
|
+
if self.keep_mask is not None:
|
|
47
|
+
k = self.keep_mask[mask]
|
|
48
|
+
else:
|
|
49
|
+
k = None
|
|
44
50
|
return self.__class__(
|
|
45
51
|
n=a.shape[0],
|
|
46
52
|
features=self.features[mask],
|
|
@@ -50,6 +56,7 @@ class SimpleMatrixFeatures:
|
|
|
50
56
|
xyza=None if self.xyza is None else self.xyza[mask],
|
|
51
57
|
signed_amplitudes=self.signed_amplitudes[mask],
|
|
52
58
|
amplitudes=a,
|
|
59
|
+
keep_mask=k,
|
|
53
60
|
)
|
|
54
61
|
|
|
55
62
|
@classmethod
|
|
@@ -68,14 +75,19 @@ class SimpleMatrixFeatures:
|
|
|
68
75
|
)
|
|
69
76
|
if xyza is not None:
|
|
70
77
|
x = xyza[:, 0]
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
_check_numbers(
|
|
79
|
+
"x", x, raise_for_numerics=clustering_features_cfg.raise_for_numerics
|
|
80
|
+
)
|
|
73
81
|
z = xyza[:, 2]
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
_check_numbers(
|
|
83
|
+
"z", z, raise_for_numerics=clustering_features_cfg.raise_for_numerics
|
|
84
|
+
)
|
|
76
85
|
z_reg = motion.correct_s(t_s, z)
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
_check_numbers(
|
|
87
|
+
"z_reg",
|
|
88
|
+
z_reg,
|
|
89
|
+
raise_for_numerics=clustering_features_cfg.raise_for_numerics,
|
|
90
|
+
)
|
|
79
91
|
else:
|
|
80
92
|
x = z = z_reg = None
|
|
81
93
|
|
|
@@ -96,14 +108,20 @@ class SimpleMatrixFeatures:
|
|
|
96
108
|
amp = getattr(sorting, clustering_features_cfg.amplitudes_dataset_name)
|
|
97
109
|
if clustering_features_cfg.use_amplitude:
|
|
98
110
|
assert amp is not None
|
|
99
|
-
|
|
100
|
-
|
|
111
|
+
_check_numbers(
|
|
112
|
+
"amp",
|
|
113
|
+
amp,
|
|
114
|
+
raise_for_numerics=clustering_features_cfg.raise_for_numerics,
|
|
115
|
+
)
|
|
101
116
|
ampft = amp.copy()
|
|
102
117
|
if clustering_features_cfg.log_transform_amplitude:
|
|
103
118
|
ampft = np.log(clustering_features_cfg.amp_log_c + ampft)
|
|
104
119
|
ampft *= clustering_features_cfg.amp_scale
|
|
105
|
-
|
|
106
|
-
|
|
120
|
+
_check_numbers(
|
|
121
|
+
"ampft",
|
|
122
|
+
ampft,
|
|
123
|
+
raise_for_numerics=clustering_features_cfg.raise_for_numerics,
|
|
124
|
+
)
|
|
107
125
|
features.append(ampft[:, None])
|
|
108
126
|
|
|
109
127
|
v = getattr(sorting, clustering_features_cfg.voltages_dataset_name, None)
|
|
@@ -124,8 +142,11 @@ class SimpleMatrixFeatures:
|
|
|
124
142
|
rank=clustering_features_cfg.n_main_channel_pcs,
|
|
125
143
|
dataset_name=clustering_features_cfg.pca_dataset_name,
|
|
126
144
|
)
|
|
127
|
-
|
|
128
|
-
|
|
145
|
+
_check_numbers(
|
|
146
|
+
"No motion pcs",
|
|
147
|
+
pcs,
|
|
148
|
+
raise_for_numerics=clustering_features_cfg.raise_for_numerics,
|
|
149
|
+
)
|
|
129
150
|
elif do_pcs and clustering_features_cfg.motion_aware:
|
|
130
151
|
shifts, n_pitches_shift = motion.pitch_shifts(
|
|
131
152
|
sorting=sorting,
|
|
@@ -144,8 +165,11 @@ class SimpleMatrixFeatures:
|
|
|
144
165
|
mask = np.broadcast_to(mask, len(schan))
|
|
145
166
|
if hasattr(sorting, clustering_features_cfg.pca_dataset_name):
|
|
146
167
|
pcs = getattr(sorting, clustering_features_cfg.pca_dataset_name)
|
|
147
|
-
|
|
148
|
-
|
|
168
|
+
_check_numbers(
|
|
169
|
+
"sorting pcs",
|
|
170
|
+
pcs,
|
|
171
|
+
raise_for_numerics=clustering_features_cfg.raise_for_numerics,
|
|
172
|
+
)
|
|
149
173
|
erp, pcs = interpolate_by_chunk(
|
|
150
174
|
mask=mask,
|
|
151
175
|
dataset=pcs,
|
|
@@ -158,8 +182,11 @@ class SimpleMatrixFeatures:
|
|
|
158
182
|
params=clustering_features_cfg.interp_params,
|
|
159
183
|
)
|
|
160
184
|
pcs = pcs[:, : clustering_features_cfg.n_main_channel_pcs, 0]
|
|
161
|
-
|
|
162
|
-
|
|
185
|
+
_check_numbers(
|
|
186
|
+
"sorting interp pcs",
|
|
187
|
+
pcs,
|
|
188
|
+
raise_for_numerics=clustering_features_cfg.raise_for_numerics,
|
|
189
|
+
)
|
|
163
190
|
else:
|
|
164
191
|
assert sorting.parent_h5_path is not None
|
|
165
192
|
with h5py.File(sorting.parent_h5_path, "r", locking=False) as h5:
|
|
@@ -175,8 +202,11 @@ class SimpleMatrixFeatures:
|
|
|
175
202
|
params=clustering_features_cfg.interp_params,
|
|
176
203
|
)
|
|
177
204
|
pcs = pcs[:, : clustering_features_cfg.n_main_channel_pcs, 0]
|
|
178
|
-
|
|
179
|
-
|
|
205
|
+
_check_numbers(
|
|
206
|
+
"h5 interp pcs",
|
|
207
|
+
pcs,
|
|
208
|
+
raise_for_numerics=clustering_features_cfg.raise_for_numerics,
|
|
209
|
+
)
|
|
180
210
|
|
|
181
211
|
if do_pcs:
|
|
182
212
|
assert pcs is not None
|
|
@@ -192,8 +222,11 @@ class SimpleMatrixFeatures:
|
|
|
192
222
|
else:
|
|
193
223
|
assert pctf in ("none", None)
|
|
194
224
|
pcs *= clustering_features_cfg.pc_scale
|
|
195
|
-
|
|
196
|
-
|
|
225
|
+
_check_numbers(
|
|
226
|
+
f"{pctf} pcs",
|
|
227
|
+
pcs,
|
|
228
|
+
raise_for_numerics=clustering_features_cfg.raise_for_numerics,
|
|
229
|
+
)
|
|
197
230
|
if torch.is_tensor(pcs):
|
|
198
231
|
pcs = pcs.numpy(force=True)
|
|
199
232
|
features.append(pcs)
|
|
@@ -203,6 +236,9 @@ class SimpleMatrixFeatures:
|
|
|
203
236
|
features = np.concatenate(features, axis=1)
|
|
204
237
|
else:
|
|
205
238
|
features = np.empty((n, 0))
|
|
239
|
+
keep = np.atleast_1d(np.isfinite(features).all(axis=1))
|
|
240
|
+
if keep.all():
|
|
241
|
+
keep = None
|
|
206
242
|
return cls(
|
|
207
243
|
n=n,
|
|
208
244
|
features=features,
|
|
@@ -212,6 +248,7 @@ class SimpleMatrixFeatures:
|
|
|
212
248
|
xyza=xyza,
|
|
213
249
|
amplitudes=amp,
|
|
214
250
|
signed_amplitudes=samp,
|
|
251
|
+
keep_mask=keep,
|
|
215
252
|
)
|
|
216
253
|
|
|
217
254
|
|
|
@@ -331,7 +368,18 @@ def _allfinite(x):
|
|
|
331
368
|
return np.isfinite(x).all()
|
|
332
369
|
|
|
333
370
|
|
|
334
|
-
def
|
|
371
|
+
def _check_numbers(name: str, x: np.ndarray, raise_for_numerics=False):
|
|
335
372
|
if isinstance(x, torch.Tensor):
|
|
336
373
|
x = x.numpy(force=True)
|
|
337
|
-
|
|
374
|
+
|
|
375
|
+
npinf = np.isposinf(x).sum()
|
|
376
|
+
nninf = np.isneginf(x).sum()
|
|
377
|
+
nna = np.isnan(x).sum()
|
|
378
|
+
if not (npinf + nninf + nna):
|
|
379
|
+
return
|
|
380
|
+
|
|
381
|
+
err = f"{name}: {npinf} +inf, {nninf} -inf, {nna} nan."
|
|
382
|
+
if raise_for_numerics:
|
|
383
|
+
raise ValueError(err)
|
|
384
|
+
else:
|
|
385
|
+
logger.warn(err)
|
|
@@ -24,7 +24,6 @@ from ..util.sparse_util import (
|
|
|
24
24
|
sparse_centroid_distsq,
|
|
25
25
|
)
|
|
26
26
|
from ..util.spiketorch import spawn_torch_rg, sqeuc_cdist_known_norm
|
|
27
|
-
from ..util.torch_util import torch_compile, torch_compiler
|
|
28
27
|
|
|
29
28
|
logger = get_logger(__name__)
|
|
30
29
|
|
|
@@ -78,6 +77,7 @@ def kmeanspp(
|
|
|
78
77
|
|
|
79
78
|
simple_case = (not min_distance) and (not skip_assignment)
|
|
80
79
|
if simple_case:
|
|
80
|
+
assert assignments is not None
|
|
81
81
|
_kmeanspp_simple_loop(
|
|
82
82
|
X=X,
|
|
83
83
|
Xnormsq=Xnormsq,
|
|
@@ -475,19 +475,16 @@ def kmeans(
|
|
|
475
475
|
)
|
|
476
476
|
|
|
477
477
|
|
|
478
|
-
@torch.compiler.disable
|
|
479
478
|
def _uniform(gen: torch.Generator, buf: Tensor):
|
|
480
479
|
return buf.uniform_(generator=gen)
|
|
481
480
|
|
|
482
481
|
|
|
483
|
-
@torch_compiler(fullgraph=False)
|
|
484
482
|
def _one_gumbel_nolog(p: Tensor, gen: torch.Generator, buf: Tensor):
|
|
485
483
|
z = _uniform(gen, buf)
|
|
486
484
|
z = z.log_()
|
|
487
485
|
return torch.divide(p, z, out=z).argmin(dim=0)
|
|
488
486
|
|
|
489
487
|
|
|
490
|
-
@torch_compile
|
|
491
488
|
def _sqeuc(X: Tensor, Xnormsq: Tensor, Y: Tensor, out: Tensor):
|
|
492
489
|
torch.addmm(Xnormsq, X, Y.transpose(0, 1), alpha=-2.0, out=out)
|
|
493
490
|
Ynormsq = (Y**2).sum(dim=1)
|
|
@@ -495,7 +492,6 @@ def _sqeuc(X: Tensor, Xnormsq: Tensor, Y: Tensor, out: Tensor):
|
|
|
495
492
|
return out
|
|
496
493
|
|
|
497
494
|
|
|
498
|
-
@torch_compiler(fullgraph=False)
|
|
499
495
|
def _kmeanspp_simple_loop(
|
|
500
496
|
*,
|
|
501
497
|
X: Tensor,
|
|
@@ -531,7 +527,6 @@ def _kmeanspp_simple_loop(
|
|
|
531
527
|
torch.minimum(dists, newdists, out=dists)
|
|
532
528
|
|
|
533
529
|
|
|
534
|
-
@torch_compiler(fullgraph=False)
|
|
535
530
|
def _kmeanspp_noassign_loop(
|
|
536
531
|
*,
|
|
537
532
|
X: Tensor,
|
|
@@ -563,7 +558,6 @@ def _kmeanspp_noassign_loop(
|
|
|
563
558
|
torch.minimum(dists, newdists, out=dists)
|
|
564
559
|
|
|
565
560
|
|
|
566
|
-
@torch_compiler(fullgraph=False)
|
|
567
561
|
def _kmeans_main_loop(
|
|
568
562
|
n_iter: int,
|
|
569
563
|
e: Tensor,
|