DARTsort 0.3.6.5__tar.gz → 0.4.0__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 (224) hide show
  1. {dartsort-0.3.6.5 → dartsort-0.4.0}/.github/workflows/ci.yml +0 -7
  2. {dartsort-0.3.6.5 → dartsort-0.4.0}/.github/workflows/ci_windows.yml +8 -8
  3. {dartsort-0.3.6.5 → dartsort-0.4.0}/.gitignore +1 -0
  4. {dartsort-0.3.6.5 → dartsort-0.4.0}/PKG-INFO +5 -2
  5. {dartsort-0.3.6.5 → dartsort-0.4.0}/README.md +1 -0
  6. {dartsort-0.3.6.5 → dartsort-0.4.0}/pyproject.toml +4 -2
  7. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/__init__.py +14 -7
  8. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/cluster_util.py +13 -18
  9. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/clustering.py +37 -62
  10. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/clustering_features.py +27 -27
  11. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/density.py +9 -11
  12. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/forward_backward.py +3 -3
  13. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/gmm/mixture.py +1352 -440
  14. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/gmm/stable_features.py +23 -321
  15. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/kmeans.py +307 -123
  16. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/merge.py +8 -11
  17. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/refine_util.py +48 -59
  18. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/config.py +46 -31
  19. dartsort-0.4.0/src/dartsort/detect/__init__.py +2 -0
  20. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/detect/detect.py +22 -69
  21. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/evaluate/analysis.py +44 -62
  22. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/evaluate/comparison.py +6 -0
  23. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/evaluate/hybrid_util.py +25 -34
  24. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/evaluate/noise_recording_tools.py +1 -0
  25. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/evaluate/simkit.py +94 -52
  26. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/evaluate/simlib.py +105 -14
  27. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/localize/localize_torch.py +1 -1
  28. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/localize/localize_util.py +17 -15
  29. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/main.py +58 -90
  30. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/__init__.py +1 -2
  31. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/grab.py +25 -32
  32. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/matching.py +105 -138
  33. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/matching_util/compressed_upsampled.py +27 -46
  34. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/matching_util/drifty.py +104 -72
  35. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/matching_util/matching_base.py +61 -59
  36. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/matching_util/pairwise.py +15 -7
  37. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/matching_util/pairwise_util.py +15 -16
  38. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/peel_base.py +90 -82
  39. dartsort-0.4.0/src/dartsort/peel/reduction_template.py +385 -0
  40. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/subtract.py +149 -305
  41. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/threshold.py +75 -130
  42. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/templates/__init__.py +3 -1
  43. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/templates/get_templates.py +79 -197
  44. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/templates/postprocess_util.py +102 -38
  45. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/templates/realignment.py +4 -3
  46. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/templates/superres_util.py +23 -25
  47. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/templates/template_util.py +71 -53
  48. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/templates/templates.py +30 -8
  49. dartsort-0.4.0/src/dartsort/templates/templib.py +195 -0
  50. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/all_transformers.py +8 -2
  51. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/amplitudes.py +6 -3
  52. dartsort-0.4.0/src/dartsort/transform/fixed_prop.py +28 -0
  53. dartsort-0.4.0/src/dartsort/transform/interp.py +48 -0
  54. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/pipeline.py +4 -1
  55. dartsort-0.4.0/src/dartsort/transform/reduction.py +265 -0
  56. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/temporal_pca.py +77 -19
  57. dartsort-0.4.0/src/dartsort/transform/whiten.py +32 -0
  58. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/data_util.py +302 -42
  59. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/drift_util.py +45 -162
  60. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/internal_config.py +193 -129
  61. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/interpolation_util.py +597 -106
  62. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/job_util.py +12 -1
  63. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/main_util.py +20 -12
  64. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/more_operators.py +6 -2
  65. dartsort-0.4.0/src/dartsort/util/motion.py +337 -0
  66. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/multiprocessing_util.py +21 -14
  67. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/noise_util.py +308 -230
  68. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/py_util.py +39 -14
  69. dartsort-0.4.0/src/dartsort/util/registration_util.py +82 -0
  70. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/spiketorch.py +64 -11
  71. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/testing_util/matching_debug_util.py +69 -25
  72. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/waveform_util.py +7 -4
  73. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/__init__.py +20 -13
  74. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/analysis_plots.py +3 -3
  75. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/mixture.py +162 -47
  76. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/recanim.py +8 -10
  77. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/scatterplots.py +20 -21
  78. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/unit.py +14 -1
  79. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/vismain.py +29 -58
  80. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort.egg-info/PKG-INFO +5 -2
  81. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort.egg-info/SOURCES.txt +7 -9
  82. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort.egg-info/requires.txt +2 -0
  83. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_alignment.py +34 -47
  84. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_clustering.py +10 -11
  85. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_config.py +2 -0
  86. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_dartsort.py +5 -5
  87. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_detect.py +3 -3
  88. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_drift_util.py +35 -27
  89. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_grab_and_featurize.py +4 -4
  90. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_linalg.py +2 -2
  91. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_localize_torch.py +8 -8
  92. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_matching.py +22 -13
  93. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_modeling.py +38 -7
  94. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_simkit.py +45 -40
  95. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_spiketorch.py +4 -2
  96. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_subtract.py +9 -4
  97. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_templates.py +188 -90
  98. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_transform.py +8 -1
  99. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_waveform_util.py +4 -1
  100. dartsort-0.3.6.5/src/dartsort/clustering/relocate.py +0 -109
  101. dartsort-0.3.6.5/src/dartsort/clustering/split.py +0 -1285
  102. dartsort-0.3.6.5/src/dartsort/detect/__init__.py +0 -2
  103. dartsort-0.3.6.5/src/dartsort/peel/running_template.py +0 -1701
  104. dartsort-0.3.6.5/src/dartsort/peel/universal.py +0 -191
  105. dartsort-0.3.6.5/src/dartsort/transform/single_channel_templates.py +0 -98
  106. dartsort-0.3.6.5/src/dartsort/util/registration_util.py +0 -128
  107. dartsort-0.3.6.5/src/dartsort/util/universal_util.py +0 -269
  108. dartsort-0.3.6.5/src/dartsort/vis/over_time.py +0 -514
  109. dartsort-0.3.6.5/tests/test_relocate.py +0 -147
  110. dartsort-0.3.6.5/tests/test_universal.py +0 -9
  111. {dartsort-0.3.6.5 → dartsort-0.4.0}/.github/workflows/deploy.yml +0 -0
  112. {dartsort-0.3.6.5 → dartsort-0.4.0}/environment.yml +0 -0
  113. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/.keep +0 -0
  114. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/basic_integration_test.py +0 -0
  115. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/ci diag.py +0 -0
  116. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/dartsort_dredge_demo.ipynb +0 -0
  117. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/dartsort_dredge_demo.py +0 -0
  118. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/data test.py +0 -0
  119. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/dead reckoning.py +0 -0
  120. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/denoise np1.py +0 -0
  121. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/denoise np2.py +0 -0
  122. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/exploratory.py +0 -0
  123. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/geom debug.py +0 -0
  124. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/hdbscan_clustering_5min.py +0 -0
  125. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/hybrid 10.py +0 -0
  126. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/hybrid cluster.py +0 -0
  127. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/hybrid_11.py +0 -0
  128. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/initial training.py +0 -0
  129. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/make hybrid.py +0 -0
  130. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/mgh.py +0 -0
  131. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/np1 feats.py +0 -0
  132. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/np2 processing version c.py +0 -0
  133. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/paperfigs.py +0 -0
  134. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/pdists.py +0 -0
  135. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/postcheck.py +0 -0
  136. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/ptp vae.py +0 -0
  137. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/re clust.py +0 -0
  138. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/reg fig loop.py +0 -0
  139. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/reg_sim_exp.py +0 -0
  140. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/relocating.py +0 -0
  141. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/relocating_all.py +0 -0
  142. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/restats +0 -0
  143. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/sortStinger1.py +0 -0
  144. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/sortStinger3.py +0 -0
  145. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/sortStinger4.py +0 -0
  146. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/sortStinger5.py +0 -0
  147. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/sortStinger6.py +0 -0
  148. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/spike farm.py +0 -0
  149. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/ss_ensemble_sim.py +0 -0
  150. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/ss_ensemble_sim_drift.py +0 -0
  151. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/ss_sim.py +0 -0
  152. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/stan diagnostics.py +0 -0
  153. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/storytelling c.py +0 -0
  154. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/storytelling.py +0 -0
  155. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/subtract_with_phaseshift_denoiser.py +0 -0
  156. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/tests/debug_matching.py +0 -0
  157. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/tests/test_agreement.py +0 -0
  158. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/tests/test_amplitude_scaling.py +0 -0
  159. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/tests/test_batch_optim.py +0 -0
  160. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/tests/test_ibme.py +0 -0
  161. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/tests/test_mm_initialization.py +0 -0
  162. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/tests/test_normxcorr1d.py +0 -0
  163. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/tests/test_reassignment.py +0 -0
  164. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/tests/test_relocation.py +0 -0
  165. {dartsort-0.3.6.5 → dartsort-0.4.0}/notebook/thomas.py +0 -0
  166. {dartsort-0.3.6.5 → dartsort-0.4.0}/setup.cfg +0 -0
  167. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/cli.py +0 -0
  168. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/__init__.py +0 -0
  169. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/clustering/modes.py +0 -0
  170. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/detect/detect_filters.py +0 -0
  171. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/evaluate/__init__.py +0 -0
  172. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/evaluate/sim_template_tools.py +3 -3
  173. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/localize/__init__.py +0 -0
  174. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/peel/matching_util/__init__.py +0 -0
  175. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/pretrained/default_temporal_kernel.npy +0 -0
  176. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/pretrained/detect_np1.pt +0 -0
  177. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/pretrained/detect_np2.pt +0 -0
  178. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/pretrained/glasbey1024.npz +0 -0
  179. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/pretrained/offset_trained_denoiser.pt +0 -0
  180. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/pretrained/offset_trained_denoiser_added_temp.pt +0 -0
  181. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/pretrained/offset_trained_denoiser_added_temp_boost.pt +0 -0
  182. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/pretrained/original_single_chan_denoiser.pt +0 -0
  183. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/pretrained/single_chan_denoiser.pt +0 -0
  184. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/__init__.py +0 -0
  185. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/_multichan_denoiser_kit.py +0 -0
  186. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/amortized_localization.py +0 -0
  187. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/decollider.py +0 -0
  188. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/enforce_decrease.py +0 -0
  189. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/localize.py +0 -0
  190. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/matching_denoiser.py +0 -0
  191. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/single_channel_denoiser.py +0 -0
  192. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/supervised_denoiser.py +0 -0
  193. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/transform/transform_base.py +0 -0
  194. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/__init__.py +0 -0
  195. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/cli_util.py +0 -0
  196. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/logging_util.py +0 -0
  197. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/nn_util.py +0 -0
  198. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/peel_util.py +0 -0
  199. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/residual_util.py +0 -0
  200. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/sparse_util.py +0 -0
  201. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/spikeio.py +0 -0
  202. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/testing_util/__init__.py +0 -0
  203. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/testing_util/mixture_testing_util.py +0 -0
  204. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/torch_optimization_util.py +0 -0
  205. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/util/torch_util.py +0 -0
  206. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/colors.py +0 -0
  207. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/gt.py +0 -0
  208. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/layout.py +0 -0
  209. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/metrics_util.py +0 -0
  210. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/sorting.py +0 -0
  211. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/unit_comparison.py +0 -0
  212. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/versus.py +0 -0
  213. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort/vis/waveforms.py +0 -0
  214. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort.egg-info/dependency_links.txt +0 -0
  215. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort.egg-info/entry_points.txt +0 -0
  216. {dartsort-0.3.6.5 → dartsort-0.4.0}/src/dartsort.egg-info/top_level.txt +0 -0
  217. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/conftest.py +0 -0
  218. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_data_util.py +0 -0
  219. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_drifty_matching.py +0 -0
  220. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_enforce_decrease.py +0 -0
  221. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_kmeans.py +0 -0
  222. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_threshold.py +0 -0
  223. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_torch_optimization_util.py +0 -0
  224. {dartsort-0.3.6.5 → dartsort-0.4.0}/tests/test_util.py +0 -0
@@ -27,12 +27,6 @@ jobs:
27
27
  - name: Fetch tags and describe
28
28
  run: pushd dartsort/ && git fetch --prune --unshallow --tags && git describe && popd
29
29
 
30
- - name: Get DREDge
31
- uses: actions/checkout@v4
32
- with:
33
- repository: evarol/dredge
34
- path: dredge
35
-
36
30
  - uses: actions/setup-python@v5
37
31
  with:
38
32
  python-version: '3.x'
@@ -42,7 +36,6 @@ jobs:
42
36
  run: |
43
37
  python -m pip install -U pip # seems necessary to make sure pip is my pip
44
38
  pip install --extra-index-url https://download.pytorch.org/whl/cpu torch
45
- pip install dredge/
46
39
  pip install -e dartsort/[full]
47
40
 
48
41
  - name: pytest
@@ -4,12 +4,19 @@ on:
4
4
  push:
5
5
  branches:
6
6
  - main
7
+ workflow_run:
8
+ workflows: [CI]
9
+ types: [completed]
10
+ branches:
11
+ - develop
7
12
  workflow_dispatch:
8
13
 
9
14
  jobs:
10
-
11
15
  tests_windows:
12
16
  runs-on: "windows-latest"
17
+ if: >-
18
+ github.event_name != 'workflow_run' ||
19
+ github.event.workflow_run.conclusion == 'success'
13
20
  defaults:
14
21
  run:
15
22
  shell: bash -el {0}
@@ -23,12 +30,6 @@ jobs:
23
30
  - name: Fetch tags and describe
24
31
  run: pushd dartsort/ && git fetch --prune --unshallow --tags && git describe && popd
25
32
 
26
- - name: Get DREDge
27
- uses: actions/checkout@v4
28
- with:
29
- repository: evarol/dredge
30
- path: dredge
31
-
32
33
  - uses: actions/setup-python@v5
33
34
  with:
34
35
  python-version: '3.x'
@@ -38,7 +39,6 @@ jobs:
38
39
  run: |
39
40
  python -m pip install -U pip # seems necessary to make sure pip is my pip
40
41
  pip install --extra-index-url https://download.pytorch.org/whl/cpu torch
41
- pip install dredge/
42
42
  pip install -e dartsort/[full]
43
43
 
44
44
  - name: pytest
@@ -14,6 +14,7 @@ figs/*
14
14
  *.swp
15
15
  *.sublime-workspace
16
16
  *.sublime-project
17
+ .vscode/
17
18
 
18
19
  ## Core latex/pdflatex auxiliary files:
19
20
  *.aux
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dartsort
3
- Version: 0.3.6.5
3
+ Version: 0.4.0
4
4
  Summary: DARTsort
5
- Author-email: Charlie Windolf <ciw2107@columbia.edu>
5
+ Author-email: Charlie Windolf <ciw2048@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/cwindolf/dartsort
7
7
  Project-URL: Bug Tracker, https://github.com/cwindolf/dartsort/issues
8
8
  Classifier: Programming Language :: Python :: 3
@@ -10,7 +10,9 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.11
12
12
  Description-Content-Type: text/markdown
13
+ Requires-Dist: dredge-ephys
13
14
  Requires-Dist: h5py
15
+ Requires-Dist: jaxtyping
14
16
  Requires-Dist: linear_operator
15
17
  Requires-Dist: numba
16
18
  Requires-Dist: numpy>=1.20; python_version < "3.13"
@@ -44,6 +46,7 @@ Requires-Dist: black; extra == "full"
44
46
 
45
47
  [![badge](https://github.com/cwindolf/dartsort/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/cwindolf/dartsort/actions/)
46
48
  [![coveralls](https://coveralls.io/repos/github/cwindolf/dartsort/badge.svg?branch=main)](https://coveralls.io/github/cwindolf/dartsort)
49
+ [![Zenodo DOI](https://zenodo.org/badge/421108722.svg)](https://doi.org/10.5281/zenodo.16943074)
47
50
 
48
51
  # dartsort
49
52
 
@@ -1,5 +1,6 @@
1
1
  [![badge](https://github.com/cwindolf/dartsort/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/cwindolf/dartsort/actions/)
2
2
  [![coveralls](https://coveralls.io/repos/github/cwindolf/dartsort/badge.svg?branch=main)](https://coveralls.io/github/cwindolf/dartsort)
3
+ [![Zenodo DOI](https://zenodo.org/badge/421108722.svg)](https://doi.org/10.5281/zenodo.16943074)
3
4
 
4
5
  # dartsort
5
6
 
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "dartsort"
7
7
  dynamic = ["version"]
8
- authors = [{ name = "Charlie Windolf", email = "ciw2107@columbia.edu" }]
8
+ authors = [{ name = "Charlie Windolf", email = "ciw2048@gmail.com" }]
9
9
  description = "DARTsort"
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.11"
@@ -15,7 +15,9 @@ classifiers = [
15
15
  "Operating System :: OS Independent",
16
16
  ]
17
17
  dependencies = [
18
+ "dredge-ephys",
18
19
  "h5py",
20
+ "jaxtyping",
19
21
  "linear_operator",
20
22
  "numba",
21
23
  "numpy>=1.20;python_version<'3.13'",
@@ -73,4 +75,4 @@ line-length = 88
73
75
  "formats" = "ipynb,py:percent"
74
76
 
75
77
  [tool.pyright]
76
- "include" = ["src"]
78
+ "include" = ["src", "tests"]
@@ -26,16 +26,15 @@ from .main import (
26
26
  check_recording,
27
27
  cluster,
28
28
  dartsort,
29
- estimate_motion,
30
29
  grab,
31
30
  logger,
32
31
  match,
33
32
  run_peeler,
34
33
  subtract,
35
34
  threshold,
36
- universal_match,
37
35
  )
38
36
  from .peel.grab import GrabAndFeaturize
37
+ from .peel.matching import MatchingTemplates
39
38
  from .templates import (
40
39
  TemplateData,
41
40
  estimate_template_library,
@@ -43,17 +42,25 @@ from .templates import (
43
42
  realign,
44
43
  )
45
44
  from .transform import WaveformPipeline
46
- from .util import data_util, logging_util, noise_util, spiketorch, waveform_util
45
+ from .util import (
46
+ data_util,
47
+ logging_util,
48
+ noise_util,
49
+ spikeio,
50
+ spiketorch,
51
+ waveform_util,
52
+ )
47
53
  from .util.data_util import (
48
54
  DARTsortSorting,
55
+ check_recording,
49
56
  get_featurization_pipeline,
50
- load_h5,
51
57
  get_tpca,
58
+ load_h5,
52
59
  load_stored_tsvd,
53
- check_recording,
54
60
  )
55
61
  from .util.drift_util import registered_geometry
56
62
  from .util.internal_config import *
63
+ from .util.job_util import ensure_computation_config, set_global_computation_config
57
64
  from .util.logging_util import (
58
65
  DARTSORTDEBUG,
59
66
  DARTSORTVERBOSE,
@@ -61,8 +68,8 @@ from .util.logging_util import (
61
68
  get_logger,
62
69
  )
63
70
  from .util.noise_util import EmbeddedNoise
64
- from .util.py_util import resolve_path
65
- from .util.registration_util import try_load_motion_est
71
+ from .util.py_util import databag, resolve_path
72
+ from .util.motion import MotionInfo, get_motion_info, try_load_motion_info
66
73
  from .util.waveform_util import make_channel_index
67
74
 
68
75
  __version__ = importlib.metadata.version("dartsort")
@@ -14,6 +14,7 @@ from sklearn.neighbors import KNeighborsClassifier
14
14
 
15
15
  from ..util import data_util, drift_util, waveform_util
16
16
  from ..util.logging_util import get_logger
17
+ from ..util.motion import MotionInfo
17
18
  from dredge.motion_util import IdentityMotionEstimate
18
19
 
19
20
 
@@ -201,15 +202,15 @@ def combine_disjoint(inds_a, labels_a, inds_b, labels_b):
201
202
  return labels
202
203
 
203
204
 
204
- def reorder_by_depth(sorting, motion_est=None):
205
+ def reorder_by_depth(sorting, motion=None):
205
206
  kept = np.flatnonzero(sorting.labels >= 0)
206
207
  kept_labels = sorting.labels[kept]
207
208
 
208
209
  units, kept_labels = np.unique(kept_labels, return_inverse=True)
209
210
 
210
211
  depths = sorting.point_source_localizations[kept, 2]
211
- if motion_est is not None:
212
- depths = motion_est.correct_s(sorting.times_seconds[kept], depths)
212
+ if motion is not None:
213
+ depths = motion.correct_s(sorting.times_seconds[kept], depths)
213
214
 
214
215
  centroids = np.zeros(units.size)
215
216
  for u in range(units.size):
@@ -224,43 +225,37 @@ def reorder_by_depth(sorting, motion_est=None):
224
225
 
225
226
 
226
227
  def closest_registered_channels(
227
- times_seconds, x, z_abs, geom, z_reg=None, motion_est=None
228
+ *, times_seconds, x, z_abs, z_reg=None, motion: MotionInfo
228
229
  ) -> np.ndarray:
229
230
  """Assign spikes to the drift-extended channel closest to their registered position"""
230
- if motion_est is None:
231
- motion_est = IdentityMotionEstimate()
232
- registered_geom = drift_util.registered_geometry(geom, motion_est)
233
231
  if z_reg is None:
234
- z_reg = motion_est.correct_s(times_seconds, z_abs)
232
+ assert motion is not None
233
+ z_reg = motion.correct_s(times_seconds, z_abs)
235
234
  reg_pos = np.c_[x, z_reg]
236
235
 
237
- registered_kdt = KDTree(registered_geom)
238
- _, reg_channels = registered_kdt.query(reg_pos)
236
+ _, reg_channels = motion.rgeom_kdt.query(reg_pos)
239
237
  reg_channels = np.atleast_1d(reg_channels)
240
238
 
241
239
  return reg_channels
242
240
 
243
241
 
244
242
  def grid_snap(
243
+ *,
245
244
  times_seconds,
246
245
  x,
247
246
  z_abs,
248
- geom,
249
247
  grid_dx=15.0,
250
248
  grid_dz=15.0,
251
249
  z_reg=None,
252
- motion_est=None,
250
+ motion: MotionInfo,
253
251
  ) -> np.ndarray:
254
- if motion_est is None:
255
- motion_est = IdentityMotionEstimate()
256
252
  if z_reg is None:
257
- z_reg = motion_est.correct_s(times_seconds, z_abs)
253
+ z_reg = motion.correct_s(times_seconds, z_abs)
258
254
  reg_pos = np.c_[x, z_reg]
259
255
 
260
256
  # make a grid inside the registered geom bounding box
261
- registered_geom = drift_util.registered_geometry(geom, motion_est)
262
- min_x, max_x = registered_geom[:, 0].min(), registered_geom[:, 0].max()
263
- min_z, max_z = registered_geom[:, 1].min(), registered_geom[:, 1].max()
257
+ min_x, max_x = motion.rgeom[:, 0].min(), motion.rgeom[:, 0].max()
258
+ min_z, max_z = motion.rgeom[:, 1].min(), motion.rgeom[:, 1].max()
264
259
  grid_x = np.arange(min_x, max_x, grid_dx)
265
260
  grid_x += (min_x + max_x) / 2 - grid_x.mean()
266
261
  grid_z = np.arange(min_z, max_z, grid_dz)
@@ -1,25 +1,25 @@
1
1
  import gc
2
- from typing import cast, Literal, Self
2
+ from typing import Literal, Self, cast
3
3
 
4
4
  import numpy as np
5
5
  import sklearn.cluster
6
6
  import torch
7
7
  from spikeinterface.core import BaseRecording
8
8
 
9
- from ..util.data_util import chunk_time_ranges, fit_reweighting, DARTsortSorting
10
- from ..util.main_util import ds_save_intermediate_labels
9
+ from ..util import job_util
10
+ from ..util.data_util import DARTsortSorting, chunk_time_ranges, fit_reweighting
11
11
  from ..util.internal_config import (
12
12
  ClusteringConfig,
13
- RefinementConfig,
14
- FitSamplingConfig,
15
13
  ComputationConfig,
14
+ FitSamplingConfig,
15
+ RefinementConfig,
16
16
  )
17
- from .clustering_features import SimpleMatrixFeatures
18
- from ..util import job_util
17
+ from ..util.main_util import ds_save_intermediate_labels
18
+ from ..util.motion import MotionInfo
19
19
  from . import cluster_util, density, forward_backward, refine_util
20
+ from .clustering_features import SimpleMatrixFeatures
20
21
  from .gmm import mixture
21
22
 
22
-
23
23
  clustering_strategies: dict[str, "type[Clusterer]"] = {}
24
24
  refinement_strategies: dict[str, "type[Refinement]"] = {}
25
25
 
@@ -161,12 +161,12 @@ class Clusterer:
161
161
  features: SimpleMatrixFeatures,
162
162
  sorting: DARTsortSorting,
163
163
  recording: BaseRecording,
164
- motion_est=None,
164
+ motion: MotionInfo,
165
165
  ) -> DARTsortSorting:
166
166
  if features is None:
167
167
  pass
168
168
  else:
169
- labels = self._cluster(features, sorting, recording, motion_est)
169
+ labels = self._cluster(features, sorting, recording, motion)
170
170
  sorting = sorting.ephemeral_replace(labels=labels)
171
171
  if self.labels_fmt and self.save_labels_dir is not None:
172
172
  assert "{" not in self.labels_fmt
@@ -181,10 +181,10 @@ class Clusterer:
181
181
  features: SimpleMatrixFeatures,
182
182
  sorting: DARTsortSorting,
183
183
  recording: BaseRecording,
184
- motion_est=None,
184
+ motion: MotionInfo,
185
185
  ) -> np.ndarray:
186
186
  """Unused method but shows API."""
187
- del features, recording, motion_est
187
+ del features, recording, motion
188
188
  assert sorting.labels is not None
189
189
  return sorting.labels
190
190
 
@@ -198,15 +198,14 @@ class ChannelSnapClusterer(Clusterer):
198
198
  features: SimpleMatrixFeatures,
199
199
  sorting: DARTsortSorting,
200
200
  recording: BaseRecording,
201
- motion_est=None,
201
+ motion: MotionInfo,
202
202
  ) -> np.ndarray:
203
203
  return cluster_util.closest_registered_channels(
204
204
  times_seconds=sorting.times_seconds, # type: ignore
205
205
  x=features.x,
206
206
  z_abs=features.z,
207
207
  z_reg=features.z_reg,
208
- geom=recording.get_channel_locations(),
209
- motion_est=motion_est,
208
+ motion=motion,
210
209
  )
211
210
 
212
211
 
@@ -244,7 +243,7 @@ class GridSnapClusterer(Clusterer):
244
243
  features: SimpleMatrixFeatures,
245
244
  sorting: DARTsortSorting,
246
245
  recording: BaseRecording,
247
- motion_est=None,
246
+ motion: MotionInfo,
248
247
  ) -> np.ndarray:
249
248
  return cluster_util.grid_snap(
250
249
  times_seconds=sorting.times_seconds, # type: ignore
@@ -253,8 +252,7 @@ class GridSnapClusterer(Clusterer):
253
252
  z_reg=features.z_reg,
254
253
  grid_dx=self.grid_dx,
255
254
  grid_dz=self.grid_dz,
256
- geom=recording.get_channel_locations(),
257
- motion_est=motion_est,
255
+ motion=motion,
258
256
  )
259
257
 
260
258
 
@@ -329,7 +327,7 @@ class DensityPeaksClusterer(Clusterer):
329
327
  features: SimpleMatrixFeatures,
330
328
  sorting: DARTsortSorting,
331
329
  recording: BaseRecording,
332
- motion_est=None,
330
+ motion: MotionInfo,
333
331
  ) -> np.ndarray:
334
332
  subsampling, ixs = self.handle_sampling(features)
335
333
  X = features.features
@@ -354,7 +352,7 @@ class DensityPeaksClusterer(Clusterer):
354
352
  features.xyza,
355
353
  features.amplitudes,
356
354
  sorting,
357
- motion_est,
355
+ motion,
358
356
  recording.get_channel_locations(),
359
357
  sigma_local=self.sigma_local,
360
358
  sigma_regional=self.sigma_regional,
@@ -479,7 +477,7 @@ class GMMDensityPeaksClusterer(Clusterer):
479
477
  features: SimpleMatrixFeatures,
480
478
  sorting: DARTsortSorting,
481
479
  recording: BaseRecording,
482
- motion_est=None,
480
+ motion: MotionInfo,
483
481
  ) -> np.ndarray:
484
482
  res = density.gmm_density_peaks(
485
483
  X=features.features,
@@ -551,7 +549,7 @@ class RecursiveHDBSCANClusterer(Clusterer):
551
549
  features: SimpleMatrixFeatures,
552
550
  sorting: DARTsortSorting,
553
551
  recording: BaseRecording,
554
- motion_est=None,
552
+ motion: MotionInfo,
555
553
  ) -> np.ndarray:
556
554
  return cluster_util.recursive_hdbscan_clustering(
557
555
  features.features,
@@ -593,7 +591,7 @@ class ScikitLearnClusterer(Clusterer):
593
591
  features: SimpleMatrixFeatures,
594
592
  sorting: DARTsortSorting,
595
593
  recording: BaseRecording,
596
- motion_est=None,
594
+ motion: MotionInfo,
597
595
  ) -> np.ndarray:
598
596
  skcls = getattr(sklearn.cluster, self.sklearn_class_name)
599
597
  clus = skcls(**self.sklearn_kwargs)
@@ -617,10 +615,10 @@ class Refinement(Clusterer):
617
615
  features: SimpleMatrixFeatures,
618
616
  sorting: DARTsortSorting,
619
617
  recording: BaseRecording,
620
- motion_est=None,
618
+ motion: MotionInfo,
621
619
  ):
622
- sorting = self.clusterer.cluster(features, sorting, recording, motion_est)
623
- sorting = self.refine(features, sorting, recording, motion_est)
620
+ sorting = self.clusterer.cluster(features, sorting, recording, motion)
621
+ sorting = self.refine(features, sorting, recording, motion)
624
622
  return sorting
625
623
 
626
624
  def _refine(
@@ -628,9 +626,9 @@ class Refinement(Clusterer):
628
626
  features: SimpleMatrixFeatures,
629
627
  sorting: DARTsortSorting,
630
628
  recording: BaseRecording,
631
- motion_est=None,
629
+ motion: MotionInfo,
632
630
  ):
633
- del features, recording, motion_est
631
+ del features, recording, motion
634
632
  return sorting
635
633
 
636
634
  def refine(
@@ -638,9 +636,9 @@ class Refinement(Clusterer):
638
636
  features: SimpleMatrixFeatures,
639
637
  sorting: DARTsortSorting,
640
638
  recording: BaseRecording,
641
- motion_est=None,
639
+ motion: MotionInfo,
642
640
  ):
643
- sorting = self._refine(features, sorting, recording, motion_est)
641
+ sorting = self._refine(features, sorting, recording, motion)
644
642
  if self.labels_fmt and self.save_labels_dir is not None:
645
643
  labels_fmt = self.labels_fmt.format(stepname="")
646
644
  ds_save_intermediate_labels(
@@ -658,14 +656,14 @@ class TMMRefinement(Refinement):
658
656
  features: SimpleMatrixFeatures,
659
657
  sorting: DARTsortSorting,
660
658
  recording: BaseRecording,
661
- motion_est=None,
659
+ motion: MotionInfo,
662
660
  ):
663
661
  assert features is not None
664
662
  subsampling, ixs = self.handle_sampling(features)
665
663
  ixs = cast(np.ndarray, ixs) if subsampling else None
666
664
  sorting = mixture.tmm_demix(
667
665
  sorting=sorting,
668
- motion_est=motion_est,
666
+ motion=motion,
669
667
  refinement_cfg=self.refinement_cfg,
670
668
  computation_cfg=self.computation_cfg,
671
669
  fit_indices=ixs,
@@ -681,43 +679,20 @@ class TMMRefinement(Refinement):
681
679
  refinement_strategies["tmm"] = TMMRefinement
682
680
 
683
681
 
684
- class SplitMergeRefinement(Refinement):
685
- def _refine(
686
- self,
687
- features: SimpleMatrixFeatures,
688
- sorting: DARTsortSorting,
689
- recording: BaseRecording,
690
- motion_est=None,
691
- ):
692
- return refine_util.split_merge(
693
- recording=recording,
694
- sorting=sorting,
695
- motion_est=motion_est,
696
- split_cfg=self.refinement_cfg.split_cfg,
697
- merge_cfg=self.refinement_cfg.merge_cfg,
698
- merge_template_cfg=self.refinement_cfg.merge_template_cfg,
699
- computation_cfg=self.computation_cfg,
700
- )
701
-
702
-
703
- # code too old. todo.
704
- # refinement_strategies["splitmerge"] = SplitMergeRefinement
705
-
706
-
707
682
  class PCMergeRefinement(Refinement):
708
683
  def _refine(
709
684
  self,
710
685
  features: SimpleMatrixFeatures,
711
686
  sorting: DARTsortSorting,
712
687
  recording: BaseRecording,
713
- motion_est=None,
688
+ motion: MotionInfo,
714
689
  ):
715
690
  return refine_util.pc_merge(
716
- sorting,
691
+ sorting=sorting,
717
692
  refinement_cfg=self.refinement_cfg,
718
- motion_est=motion_est,
693
+ motion=motion,
719
694
  computation_cfg=self.computation_cfg,
720
- )
695
+ ).sorting
721
696
 
722
697
 
723
698
  refinement_strategies["pcmerge"] = PCMergeRefinement
@@ -731,7 +706,7 @@ class ForwardBackwardEnsembler(Refinement):
731
706
  features: SimpleMatrixFeatures,
732
707
  sorting: DARTsortSorting,
733
708
  recording: BaseRecording,
734
- motion_est=None,
709
+ motion: MotionInfo,
735
710
  ):
736
711
  chunk_length_samples = (
737
712
  recording.sampling_frequency * self.refinement_cfg.chunk_size_s
@@ -745,7 +720,7 @@ class ForwardBackwardEnsembler(Refinement):
745
720
  mask = np.flatnonzero(times_seconds == times_seconds.clip(lo, hi))
746
721
  s = sorting.mask(mask)
747
722
  f = features.mask(mask)
748
- l = self.clusterer._cluster(f, s, recording, motion_est)
723
+ l = self.clusterer._cluster(f, s, recording, motion)
749
724
  labels = np.full_like(sorting.labels, -1)
750
725
  labels[mask] = l
751
726
  chunk_sortings.append(sorting.ephemeral_replace(labels=labels))
@@ -756,7 +731,7 @@ class ForwardBackwardEnsembler(Refinement):
756
731
  log_c=self.refinement_cfg.log_c,
757
732
  feature_scales=self.refinement_cfg.feature_scales,
758
733
  adaptive_feature_scales=self.refinement_cfg.adaptive_feature_scales,
759
- motion_est=motion_est,
734
+ motion=motion,
760
735
  )
761
736
  sorting = sorting.ephemeral_replace(labels=labels)
762
737
  return sorting
@@ -1,11 +1,14 @@
1
- from typing import cast, Self
1
+ from typing import Self, cast
2
2
 
3
3
  import h5py
4
4
  import numpy as np
5
5
  import torch
6
+ from spikeinterface.core import BaseRecording
6
7
 
7
- from ..util.internal_config import ClusteringFeaturesConfig
8
8
  from ..util import drift_util, interpolation_util
9
+ from ..util.data_util import DARTsortSorting
10
+ from ..util.internal_config import ClusteringFeaturesConfig
11
+ from ..util.motion import MotionInfo
9
12
  from ..util.py_util import databag
10
13
  from ..util.waveform_util import single_channel_index
11
14
  from . import cluster_util
@@ -21,9 +24,9 @@ minimal_features_cfg = ClusteringFeaturesConfig(
21
24
 
22
25
 
23
26
  def get_clustering_features(
24
- recording,
25
- sorting,
26
- motion_est=None,
27
+ recording: BaseRecording,
28
+ sorting: DARTsortSorting,
29
+ motion: MotionInfo,
27
30
  clustering_features_cfg: (
28
31
  ClusteringFeaturesConfig | None
29
32
  ) = default_clustering_features_cfg,
@@ -32,7 +35,7 @@ def get_clustering_features(
32
35
  clustering_features_cfg = minimal_features_cfg
33
36
  if clustering_features_cfg.features_type == "simple_matrix":
34
37
  return SimpleMatrixFeatures.from_config(
35
- recording, sorting, motion_est, clustering_features_cfg
38
+ recording, sorting, motion, clustering_features_cfg
36
39
  )
37
40
  assert False
38
41
 
@@ -62,14 +65,20 @@ class SimpleMatrixFeatures:
62
65
  )
63
66
 
64
67
  @classmethod
65
- def from_config(cls, recording, sorting, motion_est, clustering_features_cfg):
68
+ def from_config(
69
+ cls,
70
+ recording: BaseRecording,
71
+ sorting: DARTsortSorting,
72
+ motion: MotionInfo,
73
+ clustering_features_cfg: ClusteringFeaturesConfig,
74
+ ):
66
75
  assert clustering_features_cfg.features_type == "simple_matrix"
67
76
 
68
77
  xyza = getattr(sorting, clustering_features_cfg.localizations_dataset_name)
69
78
  x = xyza[:, 0]
70
- z_reg = z = xyza[:, 2]
71
- if motion_est is not None:
72
- z_reg = motion_est.correct_s(sorting.times_seconds, z)
79
+ z = xyza[:, 2]
80
+ t_s = sorting.times_seconds # type: ignore
81
+ z_reg = motion.correct_s(t_s, z)
73
82
 
74
83
  features = []
75
84
 
@@ -110,22 +119,13 @@ class SimpleMatrixFeatures:
110
119
  dataset_name=clustering_features_cfg.pca_dataset_name,
111
120
  )
112
121
  elif do_pcs and clustering_features_cfg.motion_aware:
113
- geom = sorting.geom
114
- if motion_est is None:
115
- registered_geom = geom
116
- else:
117
- registered_geom = drift_util.registered_geometry(
118
- geom, motion_est=motion_est
119
- )
120
- res = drift_util.get_shift_info(sorting, motion_est, geom)
121
- channels, shifts, n_pitches_shift = res
122
- mainchan_ci = single_channel_index(len(geom))
122
+ shifts, n_pitches_shift = motion.pitch_shifts(sorting=sorting)
123
+ mainchan_ci = single_channel_index(len(motion.geom))
123
124
  schan, *_ = drift_util.get_stable_channels(
124
- geom,
125
- channels,
126
- mainchan_ci,
127
- registered_geom,
128
- n_pitches_shift,
125
+ motion=motion,
126
+ channels=sorting.channels,
127
+ channel_index=mainchan_ci,
128
+ n_pitches_shift=n_pitches_shift,
129
129
  workers=clustering_features_cfg.workers,
130
130
  )
131
131
  mask = np.ones((1,), dtype=bool)
@@ -134,11 +134,11 @@ class SimpleMatrixFeatures:
134
134
  pcs = interpolation_util.interpolate_by_chunk(
135
135
  mask=mask,
136
136
  dataset=h5[clustering_features_cfg.pca_dataset_name],
137
- geom=geom,
137
+ geom=motion.geom,
138
138
  channel_index=cast(h5py.Dataset, h5["channel_index"])[:],
139
139
  channels=sorting.channels,
140
140
  shifts=shifts,
141
- registered_geom=registered_geom,
141
+ registered_geom=motion.rgeom,
142
142
  target_channels=schan,
143
143
  params=clustering_features_cfg.interp_params,
144
144
  )