DARTsort 0.5.5__tar.gz → 0.5.7__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.
Files changed (225) hide show
  1. {dartsort-0.5.5 → dartsort-0.5.7}/PKG-INFO +1 -1
  2. {dartsort-0.5.5 → dartsort-0.5.7}/docs/main_api.md +1 -1
  3. {dartsort-0.5.5 → dartsort-0.5.7}/docs/toolkit_api.md +17 -1
  4. {dartsort-0.5.5 → dartsort-0.5.7}/pyproject.toml +6 -0
  5. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/__init__.py +1 -0
  6. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/agglomerate.py +246 -1
  7. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/cluster_util.py +41 -4
  8. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/clustering.py +21 -1
  9. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/clustering_features.py +7 -3
  10. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/density.py +139 -151
  11. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/kmeans.py +17 -32
  12. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/merge.py +7 -12
  13. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/mixture.py +186 -55
  14. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/modes.py +3 -42
  15. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/refine_util.py +1 -1
  16. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/config.py +14 -4
  17. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/evaluate/analysis.py +39 -15
  18. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/evaluate/comparison.py +26 -8
  19. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/evaluate/hybrid_util.py +1 -1
  20. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/evaluate/simkit.py +3 -1
  21. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/main.py +22 -2
  22. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/matching.py +6 -5
  23. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/matching_util/pairwise_util.py +6 -0
  24. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/peel_base.py +1 -0
  25. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/reduction_template.py +1 -6
  26. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/subtract.py +30 -17
  27. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/templates/get_templates.py +2 -1
  28. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/templates/postprocess_util.py +8 -0
  29. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/templates/realignment.py +3 -1
  30. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/templates/templates.py +49 -2
  31. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/_multichan_denoiser_kit.py +15 -2
  32. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/decollider.py +17 -3
  33. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/enforce_decrease.py +2 -1
  34. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/mixture_classifier.py +1 -1
  35. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/pipeline.py +4 -0
  36. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/reduction.py +57 -45
  37. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/cli_util.py +2 -2
  38. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/data_util.py +31 -36
  39. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/drift_util.py +1 -1
  40. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/internal_config.py +39 -14
  41. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/interpolation_util.py +3 -3
  42. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/logging_util.py +30 -14
  43. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/main_util.py +2 -3
  44. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/motion.py +3 -0
  45. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/nn_util.py +4 -0
  46. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/peel_util.py +10 -8
  47. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/preprocess_util.py +2 -2
  48. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/spiketorch.py +20 -3
  49. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/waveform_util.py +0 -40
  50. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/analysis_plots.py +4 -2
  51. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/gt.py +39 -8
  52. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/mixture.py +4 -2
  53. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/recanim.py +2 -1
  54. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/scatterplots.py +86 -14
  55. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/unit.py +38 -6
  56. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/unit_comparison.py +34 -9
  57. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/versus.py +57 -9
  58. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/vismain.py +79 -8
  59. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/waveforms.py +5 -3
  60. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort.egg-info/PKG-INFO +1 -1
  61. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort.egg-info/SOURCES.txt +2 -0
  62. {dartsort-0.5.5 → dartsort-0.5.7}/tests/conftest.py +3 -3
  63. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_alignment.py +48 -0
  64. dartsort-0.5.7/tests/test_cluster_util.py +83 -0
  65. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_clustering.py +5 -5
  66. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_dartsort.py +1 -1
  67. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_data_util.py +2 -1
  68. dartsort-0.5.7/tests/test_density.py +88 -0
  69. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_detect.py +3 -3
  70. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_enforce_decrease.py +2 -1
  71. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_modeling.py +13 -5
  72. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_simkit.py +2 -2
  73. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_spiketorch.py +2 -1
  74. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_templates.py +4 -3
  75. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_torch_optimization_util.py +2 -1
  76. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_util.py +1 -0
  77. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_waveform_util.py +2 -2
  78. {dartsort-0.5.5 → dartsort-0.5.7}/.github/workflows/ci.yml +0 -0
  79. {dartsort-0.5.5 → dartsort-0.5.7}/.github/workflows/ci_windows.yml +0 -0
  80. {dartsort-0.5.5 → dartsort-0.5.7}/.github/workflows/deploy.yml +0 -0
  81. {dartsort-0.5.5 → dartsort-0.5.7}/.github/workflows/docs.yml +0 -0
  82. {dartsort-0.5.5 → dartsort-0.5.7}/.gitignore +0 -0
  83. {dartsort-0.5.5 → dartsort-0.5.7}/README.md +0 -0
  84. {dartsort-0.5.5 → dartsort-0.5.7}/docs/index.md +0 -0
  85. {dartsort-0.5.5 → dartsort-0.5.7}/environment.yml +0 -0
  86. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/.keep +0 -0
  87. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/basic_integration_test.py +0 -0
  88. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/ci diag.py +0 -0
  89. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/dartsort_dredge_demo.ipynb +0 -0
  90. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/dartsort_dredge_demo.py +0 -0
  91. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/data test.py +0 -0
  92. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/dead reckoning.py +0 -0
  93. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/denoise np1.py +0 -0
  94. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/denoise np2.py +0 -0
  95. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/exploratory.py +0 -0
  96. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/geom debug.py +0 -0
  97. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/hdbscan_clustering_5min.py +0 -0
  98. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/hybrid 10.py +0 -0
  99. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/hybrid cluster.py +0 -0
  100. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/hybrid_11.py +0 -0
  101. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/initial training.py +0 -0
  102. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/make hybrid.py +0 -0
  103. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/mgh.py +0 -0
  104. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/np1 feats.py +0 -0
  105. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/np2 processing version c.py +0 -0
  106. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/paperfigs.py +0 -0
  107. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/pdists.py +0 -0
  108. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/postcheck.py +0 -0
  109. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/ptp vae.py +0 -0
  110. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/re clust.py +0 -0
  111. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/reg fig loop.py +0 -0
  112. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/reg_sim_exp.py +0 -0
  113. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/relocating.py +0 -0
  114. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/relocating_all.py +0 -0
  115. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/restats +0 -0
  116. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/sortStinger1.py +0 -0
  117. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/sortStinger3.py +0 -0
  118. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/sortStinger4.py +0 -0
  119. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/sortStinger5.py +0 -0
  120. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/sortStinger6.py +0 -0
  121. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/spike farm.py +0 -0
  122. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/ss_ensemble_sim.py +0 -0
  123. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/ss_ensemble_sim_drift.py +0 -0
  124. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/ss_sim.py +0 -0
  125. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/stan diagnostics.py +0 -0
  126. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/storytelling c.py +0 -0
  127. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/storytelling.py +0 -0
  128. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/subtract_with_phaseshift_denoiser.py +0 -0
  129. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/tests/debug_matching.py +0 -0
  130. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/tests/test_agreement.py +0 -0
  131. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/tests/test_amplitude_scaling.py +0 -0
  132. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/tests/test_batch_optim.py +0 -0
  133. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/tests/test_ibme.py +0 -0
  134. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/tests/test_mm_initialization.py +0 -0
  135. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/tests/test_normxcorr1d.py +0 -0
  136. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/tests/test_reassignment.py +0 -0
  137. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/tests/test_relocation.py +0 -0
  138. {dartsort-0.5.5 → dartsort-0.5.7}/notebook/thomas.py +0 -0
  139. {dartsort-0.5.5 → dartsort-0.5.7}/setup.cfg +0 -0
  140. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/cli.py +0 -0
  141. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/__init__.py +0 -0
  142. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/clustering/forward_backward.py +0 -0
  143. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/detect/__init__.py +0 -0
  144. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/detect/detect.py +0 -0
  145. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/detect/detect_filters.py +0 -0
  146. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/evaluate/__init__.py +0 -0
  147. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/evaluate/noise_recording_tools.py +0 -0
  148. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/evaluate/sim_template_tools.py +0 -0
  149. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/evaluate/simlib.py +0 -0
  150. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/localize/__init__.py +0 -0
  151. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/localize/localize_torch.py +0 -0
  152. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/localize/localize_util.py +0 -0
  153. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/__init__.py +0 -0
  154. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/grab.py +0 -0
  155. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/matching_util/__init__.py +0 -0
  156. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/matching_util/compressed_upsampled.py +0 -0
  157. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/matching_util/drifty.py +0 -0
  158. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/matching_util/matching_base.py +0 -0
  159. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/matching_util/pairwise.py +0 -0
  160. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/peel_lib.py +0 -0
  161. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/shaver.py +0 -0
  162. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/peel/threshold.py +0 -0
  163. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/pretrained/default_temporal_kernel.npy +0 -0
  164. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/pretrained/detect_np1.pt +0 -0
  165. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/pretrained/detect_np2.pt +0 -0
  166. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/pretrained/glasbey1024.npz +0 -0
  167. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/pretrained/offset_trained_denoiser.pt +0 -0
  168. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/pretrained/offset_trained_denoiser_added_temp.pt +0 -0
  169. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/pretrained/offset_trained_denoiser_added_temp_boost.pt +0 -0
  170. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/pretrained/original_single_chan_denoiser.pt +0 -0
  171. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/pretrained/single_chan_denoiser.pt +0 -0
  172. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/templates/__init__.py +0 -0
  173. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/templates/template_util.py +0 -0
  174. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/templates/templib.py +0 -0
  175. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/__init__.py +0 -0
  176. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/all_transformers.py +0 -0
  177. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/amortized_localization.py +0 -0
  178. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/amplitudes.py +0 -0
  179. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/denoising_scorer.py +0 -0
  180. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/fixed_prop.py +0 -0
  181. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/interp.py +0 -0
  182. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/localize.py +0 -0
  183. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/matching_denoiser.py +0 -0
  184. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/single_channel_denoiser.py +0 -0
  185. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/supervised_denoiser.py +0 -0
  186. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/temporal_pca.py +0 -0
  187. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/transform_base.py +0 -0
  188. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/transform/whiten.py +0 -0
  189. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/__init__.py +0 -0
  190. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/job_util.py +0 -0
  191. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/more_operators.py +0 -0
  192. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/multiprocessing_util.py +0 -0
  193. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/noise_util.py +0 -0
  194. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/py_util.py +0 -0
  195. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/registration_util.py +0 -0
  196. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/residual_util.py +0 -0
  197. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/sparse_util.py +0 -0
  198. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/spikeio.py +0 -0
  199. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/testing_util/__init__.py +0 -0
  200. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/testing_util/matching_debug_util.py +0 -0
  201. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/testing_util/mixture_testing_util.py +0 -0
  202. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/torch_optimization_util.py +0 -0
  203. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/util/torch_util.py +0 -0
  204. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/__init__.py +0 -0
  205. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/colors.py +0 -0
  206. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/layout.py +0 -0
  207. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/metrics_util.py +0 -0
  208. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort/vis/sorting.py +0 -0
  209. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort.egg-info/dependency_links.txt +0 -0
  210. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort.egg-info/entry_points.txt +0 -0
  211. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort.egg-info/requires.txt +0 -0
  212. {dartsort-0.5.5 → dartsort-0.5.7}/src/dartsort.egg-info/top_level.txt +0 -0
  213. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_config.py +0 -0
  214. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_drift_util.py +0 -0
  215. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_drifty_matching.py +0 -0
  216. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_grab_and_featurize.py +0 -0
  217. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_kmeans.py +0 -0
  218. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_linalg.py +0 -0
  219. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_localize_torch.py +0 -0
  220. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_matching.py +0 -0
  221. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_mixture_classifier.py +0 -0
  222. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_subtract.py +0 -0
  223. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_threshold.py +0 -0
  224. {dartsort-0.5.5 → dartsort-0.5.7}/tests/test_transform.py +0 -0
  225. {dartsort-0.5.5 → dartsort-0.5.7}/zensical.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dartsort
3
- Version: 0.5.5
3
+ Version: 0.5.7
4
4
  Summary: DARTsort
5
5
  Author-email: Charlie Windolf <ciw2048@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/cwindolf/dartsort
@@ -19,7 +19,7 @@ For details on parameters you should think about before running the sorter, see
19
19
 
20
20
  The return value from the `dartsort()` function is a `DARTsortResult` object, which is a dictionary containing spike trains and motion information:
21
21
 
22
- ::: dartsort.DARTsortReturn
22
+ ::: dartsort.DARTsortResult
23
23
  options:
24
24
  show_bases: false
25
25
 
@@ -17,7 +17,13 @@ In *dartsort* those kind of workflows are called "peelers" (inspired by the iter
17
17
  All of the peelers accept a featurization pipeline or a [`FeaturizationConfig`](#dartsort.FeaturizationConfig) object which handles the spike featurization; these are discussed [in the next section](#featurization-pipelines).
18
18
 
19
19
  *dartsort* includes high-level functions for running various kinds of peelers and corresponding configuration objects.
20
- These are:
20
+ These are in sections below.
21
+
22
+ ### Template matching
23
+
24
+ [`match()`](#dartsort.match) runs template matching from known templates if its `template_data` parameter is set, or else estimating templates from `sorting` using [`estimate_template_library()`](#dartsort.estimate_template_library).
25
+
26
+ It is configured by the [matching_cfg](#dartsort.MatchingConfig) argument.
21
27
 
22
28
  ::: dartsort.match
23
29
 
@@ -25,18 +31,28 @@ These are:
25
31
  options:
26
32
  show_if_no_docstring: true
27
33
 
34
+ ### Neural-net based collision-cleaned spike detection
35
+
28
36
  ::: dartsort.subtract
29
37
 
30
38
  ::: dartsort.SubtractionConfig
31
39
  options:
32
40
  show_if_no_docstring: true
33
41
 
42
+ ### Thresholding spike detection
43
+
34
44
  ::: dartsort.threshold
35
45
 
36
46
  ::: dartsort.ThresholdingConfig
37
47
  options:
38
48
  show_if_no_docstring: true
39
49
 
50
+
51
+ ### Spike extraction and featurization at known event times
52
+
53
+ ::: dartsort.grab
54
+
55
+
40
56
  ## Featurization pipelines
41
57
 
42
58
  Featurization is configured by building a `FeaturizationConfig`.
@@ -81,9 +81,15 @@ ignore = ["F722"]
81
81
  [tool.ty.src]
82
82
  include = ["src", "tests"]
83
83
 
84
+ [tool.basedpyright]
85
+ include = ["src", "tests"]
86
+ enableTypeIgnoreComments = true
87
+ typeCheckingMode = "standard"
88
+
84
89
  [tool.ty.analysis]
85
90
  replace-imports-with-any = ["hdbscan"]
86
91
 
87
92
  [tool.ty.rules]
88
93
  "unsupported-base" = "ignore"
89
94
  "invalid-key" = "ignore"
95
+ "possibly-unresolved-reference" = "error"
@@ -74,6 +74,7 @@ from .util.logging_util import (
74
74
  DARTSORTVERBOSE,
75
75
  DARTsortLogger,
76
76
  get_logger,
77
+ set_log_level,
77
78
  )
78
79
  from .util.motion import MotionInfo, get_motion_info, try_load_motion_info
79
80
  from .util.noise_util import EmbeddedNoise
@@ -177,7 +177,13 @@ def agglomerate(
177
177
  threshold=0.5,
178
178
  link=template_merge_cfg.linkage,
179
179
  )
180
- agg_sorting = reorder_by_depth(agg_sorting, motion=motion)
180
+
181
+ agg_sorting = combine_gmm_scores(agg_sorting, new_ids=new_ids)
182
+
183
+ agg_sorting = deduplicate_spikes(agg_sorting, refinement_cfg.dedup_ms)
184
+
185
+ agg_sorting, reorder = reorder_by_depth(agg_sorting, motion=motion)
186
+ new_ids = reorder[new_ids]
181
187
 
182
188
  return Agglomeration(
183
189
  agglomerated_sorting=agg_sorting,
@@ -625,3 +631,242 @@ def firing_corr(sorting: DARTsortSorting, dt: float, method="binsqrt"):
625
631
  fr = np.sqrt(fr.values)
626
632
 
627
633
  return np.corrcoef(fr, rowvar=False)
634
+
635
+
636
+ def combine_gmm_scores(
637
+ sorting: DARTsortSorting, new_ids: np.ndarray, old_prefix="gmm", new_prefix="merged"
638
+ ) -> DARTsortSorting:
639
+ """If new_ids merges units, return a sorting with merged likelihoods."""
640
+ candidates = getattr(sorting, f"{old_prefix}_candidates", None)
641
+ responsibilities = getattr(sorting, f"{old_prefix}_responsibilities", None)
642
+ logliks = getattr(sorting, f"{old_prefix}_log_liks", None)
643
+
644
+ havec = candidates is not None
645
+ haver = responsibilities is not None
646
+ havel = logliks is not None
647
+ assert all([havec, haver, havel]) or not any([havec, havel, haver])
648
+ if not havec:
649
+ return sorting
650
+ assert candidates is not None
651
+ assert responsibilities is not None
652
+ assert logliks is not None
653
+
654
+ # check that new_ids is a merge
655
+ assert (new_ids >= 0).all()
656
+ unique_new_ids, new_id_counts = np.unique(new_ids, return_counts=True)
657
+ assert unique_new_ids.shape[0] == unique_new_ids.max() + 1 <= new_ids.shape[0]
658
+ if unique_new_ids.shape == new_ids.shape:
659
+ return sorting.ephemeral_replace(
660
+ **{
661
+ f"{new_prefix}_candidates": candidates,
662
+ f"{new_prefix}_responsibilities": responsibilities,
663
+ f"{new_prefix}_logliks": logliks,
664
+ }
665
+ )
666
+
667
+ # check invariants at the top
668
+ if responsibilities.shape[1] > 2:
669
+ assert np.all(np.diff(responsibilities[:, :-1], axis=1) <= 0)
670
+ assert np.greater_equal(np.isneginf(logliks[:, :-1]), candidates == -1).all()
671
+ if sorting.labels is not None:
672
+ assert np.all(
673
+ np.logical_or(
674
+ sorting.labels < 0, sorting.labels == new_ids[candidates[:, 0]]
675
+ )
676
+ )
677
+
678
+ # two steps: first merge, then sort
679
+ # merge candidates
680
+ new_ids_ = np.pad(new_ids, [(0, 1)], constant_values=-1)
681
+ orig_bye = candidates < 0
682
+ nbye = orig_bye.sum()
683
+ cand = np.where(orig_bye, new_ids.shape[0], candidates)
684
+ cand = new_ids_[cand]
685
+ assert (cand < 0).sum() >= nbye
686
+
687
+ # deduplicate
688
+ mergedr = responsibilities[:, : cand.shape[1]].copy()
689
+ mergedl = logliks[:, : cand.shape[1]].copy()
690
+ _combine_loop(cand, new_id_counts, mergedr, mergedl)
691
+
692
+ # now re-sort
693
+ order = np.argsort(-mergedl, axis=1, kind="stable")
694
+ cand = np.take_along_axis(cand, axis=1, indices=order)
695
+ mergedr = np.take_along_axis(mergedr, axis=1, indices=order)
696
+ mergedl = np.take_along_axis(mergedl, axis=1, indices=order)
697
+ mergedl = np.concatenate([mergedl, logliks[:, cand.shape[1] :]], axis=1)
698
+ mergedr = np.concatenate([mergedr, responsibilities[:, cand.shape[1] :]], axis=1)
699
+
700
+ # check invariants at the bottom
701
+ if mergedr.shape[1] > 2:
702
+ assert np.all(np.diff(mergedr[:, : cand.shape[1]], axis=1) <= 0)
703
+ assert np.greater_equal(np.isneginf(mergedl[:, : cand.shape[1]]), cand == -1).all()
704
+ assert (cand < 0).sum() >= nbye
705
+ if sorting.labels is not None:
706
+ changed = sorting.labels != cand[:, 0]
707
+ changed = changed[sorting.labels >= 0]
708
+ logger.dartsortdebug(
709
+ f"Mixture component aggregation changes {100 * changed.mean():0.2f}"
710
+ f"% of spike labels ({changed.sum().item()} spikes)."
711
+ )
712
+ return sorting.ephemeral_replace(
713
+ labels=np.where(mergedl[:, 0] >= mergedl[:, -1], cand[:, 0], -1),
714
+ **{
715
+ f"{new_prefix}_candidates": cand,
716
+ f"{new_prefix}_responsibilities": mergedr,
717
+ f"{new_prefix}_logliks": mergedl,
718
+ },
719
+ )
720
+
721
+
722
+ @numba.njit(parallel=True)
723
+ def _combine_loop(
724
+ cand: np.ndarray,
725
+ new_id_counts: np.ndarray,
726
+ mergedr: np.ndarray,
727
+ mergedl: np.ndarray,
728
+ ):
729
+ for s in numba.prange(cand.shape[0]): # ty: ignore
730
+ rcand = cand[s]
731
+ for j in range(cand.shape[1] - 1):
732
+ ncandj = rcand[j]
733
+ if ncandj < 0 or new_id_counts[ncandj] <= 1:
734
+ continue
735
+
736
+ eq_ncandj = rcand[j + 1 :] == ncandj
737
+ if eq_ncandj.sum() <= 1:
738
+ continue
739
+
740
+ rsum = mergedr[s, j]
741
+ lsum = mergedl[s, j]
742
+ for i, k in enumerate(range(j + 1, cand.shape[1])):
743
+ if not eq_ncandj[i]:
744
+ continue
745
+ cand[s, k] = -1
746
+
747
+ if mergedl[s, k] == -np.inf:
748
+ continue
749
+ rsum += mergedr[s, k]
750
+ lsum = np.logaddexp(lsum, mergedl[s, k])
751
+
752
+ mergedr[s, k] = 0.0
753
+ mergedl[s, k] = -np.inf
754
+
755
+ mergedr[s, j] = rsum
756
+ mergedl[s, j] = lsum
757
+
758
+
759
+ def deduplicate_spikes(
760
+ sorting: DARTsortSorting,
761
+ radius_ms: float = -1.0,
762
+ score_by=("merged_logliks", "gmm_logliks", "scores"),
763
+ ) -> DARTsortSorting:
764
+ """The lower-scoring of any spikes within radius_samples of each other is relabeled to -1.
765
+
766
+ scores are grabbed from the first entry of score_by which is a valid property of the sorting.
767
+ If it's mu
768
+ """
769
+ if radius_ms < 0 or sorting.labels is None:
770
+ return sorting
771
+
772
+ radius_samples = WaveformConfig.ms_to_samples(
773
+ ms=radius_ms,
774
+ sampling_frequency=sorting.sampling_frequency,
775
+ )
776
+ assert radius_samples >= 0
777
+
778
+ new_labels = sorting.labels.copy()
779
+ scores = None
780
+ for sck in score_by:
781
+ scores = getattr(sorting, sck, None)
782
+ if scores is not None:
783
+ logger.dartsortdebug(f"deduplicate by score {sck}")
784
+ break
785
+ if scores is None:
786
+ raise ValueError(f"sorting had none of {score_by}.")
787
+ if scores.ndim == 2:
788
+ scores = scores[:, 0]
789
+ assert scores.ndim == 1
790
+ assert scores.shape == new_labels.shape
791
+
792
+ # handle unsorted times
793
+ tsort = np.argsort(sorting.times_samples)
794
+ new_labels = new_labels[tsort]
795
+ times_samples = sorting.times_samples[tsort]
796
+ scores = scores[tsort]
797
+
798
+ unit_ids = np.unique(new_labels)
799
+ unit_ids = unit_ids[unit_ids >= 0]
800
+ ndrop = 0
801
+ for unit_id in unit_ids:
802
+ in_unit = np.flatnonzero(new_labels == unit_id)
803
+ t = times_samples[in_unit]
804
+ dt = np.diff(t)
805
+ if dt.min() > radius_samples:
806
+ continue
807
+ discard = _dedup_unit(t, dt, scores[in_unit], radius_samples)
808
+ ndrop += discard.sum()
809
+ new_labels[in_unit[discard]] = -1
810
+
811
+ logger.dartsortdebug(f"drop {ndrop}/{len(sorting)} isi violator spikes")
812
+ new_labels = new_labels[np.argsort(tsort)]
813
+
814
+ return sorting.ephemeral_replace(labels=new_labels)
815
+
816
+
817
+ def _dedup_unit(
818
+ t: np.ndarray, dt: np.ndarray, scores: np.ndarray, radius: int
819
+ ) -> np.ndarray:
820
+ """Deduplicate a single unit's spike train."""
821
+ discard = np.zeros(t.shape, dtype=bool)
822
+ _dedup_unit_loop(dt, scores, radius, discard)
823
+ return discard
824
+
825
+
826
+ @numba.njit
827
+ def _dedup_unit_loop(
828
+ dt: np.ndarray, scores: np.ndarray, radius: int, discard: np.ndarray
829
+ ):
830
+ n = scores.shape[0]
831
+ i0 = 0
832
+ while i0 < n - 1:
833
+ if dt[i0] > radius:
834
+ i0 += 1
835
+ continue
836
+
837
+ i1 = i0 + 1
838
+ while i1 < n - 1 and dt[i1] <= radius:
839
+ i1 += 1
840
+
841
+ # now, i0:i1 + 1 is a slice of violators
842
+ # discard until all valid
843
+ score_slice = scores[i0 : i1 + 1]
844
+ dt_slice = dt[i0:i1]
845
+ order = np.argsort(score_slice)
846
+ for oo in order:
847
+ # discard spike i0 + oo
848
+ ii = i0 + oo
849
+ discard[ii] = True
850
+
851
+ # figure out isi after bridging the gap, handle edges
852
+ bridge_isi = 0.0
853
+ if ii < n - 1:
854
+ bridge_isi += dt[ii]
855
+ else:
856
+ bridge_isi = np.inf
857
+ if ii > 0:
858
+ bridge_isi += dt[ii - 1]
859
+ else:
860
+ bridge_isi = np.inf
861
+
862
+ # update dt with bridge isi
863
+ if ii < n - 1:
864
+ dt[ii] = bridge_isi
865
+ if ii > 0:
866
+ dt[ii - 1] = bridge_isi
867
+
868
+ # check if done
869
+ if dt_slice.min() > radius:
870
+ break
871
+
872
+ i0 = i1
@@ -321,8 +321,29 @@ def combine_disjoint(inds_a, labels_a, inds_b, labels_b):
321
321
 
322
322
 
323
323
  def reorder_by_depth(
324
- sorting, motion=None, spatial_footprints=None, geom=None, centroids=None
325
- ):
324
+ sorting: DARTsortSorting,
325
+ motion: MotionInfo | None = None,
326
+ spatial_footprints: np.ndarray | None = None,
327
+ geom: np.ndarray | None = None,
328
+ centroids: np.ndarray | None = None,
329
+ ) -> tuple[DARTsortSorting, np.ndarray]:
330
+ """Reorder cluster labels so that centroid depth is increasing
331
+
332
+ Parameters
333
+ ----------
334
+ sorting : DARTsortSorting
335
+ motion : MotionInfo | None, optional
336
+ spatial_footprints : np.ndarray | None, optional
337
+ geom : np.ndarray | None, optional
338
+ centroids : np.ndarray | None, optional
339
+
340
+ Returns
341
+ -------
342
+ reordered_sorting: DARTsortSorting
343
+ reorder: np.ndarray
344
+ reorder[j] is the new label of original unit j.
345
+ """
346
+ assert sorting.labels is not None
326
347
  kept = np.flatnonzero(sorting.labels >= 0)
327
348
  kept_labels = sorting.labels[kept]
328
349
 
@@ -355,8 +376,9 @@ def reorder_by_depth(
355
376
  # this one is some food for thought, lol.
356
377
  reorder = np.argsort(np.argsort(centroids, kind="stable"), kind="stable")
357
378
  labels[kept] = reorder[kept_labels]
379
+ reordered_sorting = sorting.ephemeral_replace(labels=labels)
358
380
 
359
- return sorting.ephemeral_replace(labels=labels)
381
+ return reordered_sorting, reorder
360
382
 
361
383
 
362
384
  def closest_registered_channels(
@@ -502,7 +524,22 @@ def get_main_channel_pcs(
502
524
  return features
503
525
 
504
526
 
505
- def decrumb(labels, min_size=5, in_place=False, flatten=True):
527
+ def decrumb(labels: np.ndarray, min_size: int=5, in_place=False, flatten=True):
528
+ """Remove small units
529
+
530
+ Parameters
531
+ ----------
532
+ labels : np.ndarray
533
+ min_size : int
534
+ in_place : bool
535
+ flatten : bool
536
+ Flatten the output label space to be contiguous.
537
+
538
+ Returns
539
+ -------
540
+ labels
541
+ The (flattened) decrumbed labels.
542
+ """
506
543
  kept = np.flatnonzero(labels >= 0)
507
544
  labels_kept = labels[kept]
508
545
  labels = labels if in_place else labels.copy()
@@ -352,9 +352,27 @@ class DensityPeaksClusterer(Clusterer):
352
352
  recording: BaseRecording | None,
353
353
  motion: MotionInfo,
354
354
  ) -> np.ndarray:
355
+ labels, _ = self._cluster_extra(
356
+ features=features,
357
+ stable_features=stable_features,
358
+ sorting=sorting,
359
+ recording=recording,
360
+ motion=motion,
361
+ )
362
+ return labels
363
+
364
+ def _cluster_extra(
365
+ self,
366
+ features: SimpleMatrixFeatures,
367
+ stable_features: StableWaveformFeatures | None,
368
+ sorting: DARTsortSorting,
369
+ recording: BaseRecording | None,
370
+ motion: MotionInfo,
371
+ ) -> tuple[np.ndarray, dict]:
355
372
  subsampling, ixs = self.handle_sampling(features)
356
373
  X = features.features
357
374
  X_fit = X[ixs]
375
+ assert self.computation_cfg is not None
358
376
 
359
377
  if not self.uhdversion:
360
378
  res = density.density_peaks(
@@ -369,6 +387,7 @@ class DensityPeaksClusterer(Clusterer):
369
387
  outlier_radius=self.outlier_radius,
370
388
  outlier_neighbor_count=self.outlier_neighbor_count,
371
389
  workers=self.workers,
390
+ device=self.computation_cfg.actual_device(),
372
391
  )
373
392
  else:
374
393
  res = density.density_peaks_fancy(
@@ -403,13 +422,14 @@ class DensityPeaksClusterer(Clusterer):
403
422
  ixs, res["labels"], rest, other_labels
404
423
  )
405
424
  else:
425
+ kdtree = None
406
426
  labels = res["labels"]
407
427
 
408
428
  labels = cluster_util.decrumb(
409
429
  labels, min_size=self.remove_clusters_smaller_than, in_place=True
410
430
  )
411
431
 
412
- return labels
432
+ return labels, dict(dpc_res=res, kdtree=kdtree, ixs=ixs)
413
433
 
414
434
 
415
435
  clustering_strategies["dpc"] = DensityPeaksClusterer
@@ -7,7 +7,11 @@ from torch import Tensor
7
7
 
8
8
  from ..util.data_util import DARTsortSorting
9
9
  from ..util.drift_util import get_stable_channels
10
- from ..util.internal_config import ClusteringFeaturesConfig, ComputationConfig
10
+ from ..util.internal_config import (
11
+ ClusteringFeaturesConfig,
12
+ ComputationConfig,
13
+ default_clustering_features_cfg,
14
+ )
11
15
  from ..util.interpolation_util import (
12
16
  SpikeNeighborhoods,
13
17
  StableFeaturesInterpolator,
@@ -63,8 +67,8 @@ class SimpleMatrixFeatures:
63
67
  *,
64
68
  sorting: DARTsortSorting,
65
69
  motion: MotionInfo,
66
- clustering_features_cfg: ClusteringFeaturesConfig,
67
- computation_cfg: ComputationConfig | None,
70
+ clustering_features_cfg: ClusteringFeaturesConfig = default_clustering_features_cfg,
71
+ computation_cfg: ComputationConfig | None = None,
68
72
  ) -> Self:
69
73
  computation_cfg = ensure_computation_config(computation_cfg)
70
74
  t_s = sorting.times_seconds