DARTsort 0.5.28__tar.gz → 0.5.30__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 (181) hide show
  1. {dartsort-0.5.28 → dartsort-0.5.30}/.github/workflows/ci.yml +2 -2
  2. {dartsort-0.5.28 → dartsort-0.5.30}/PKG-INFO +4 -4
  3. {dartsort-0.5.28 → dartsort-0.5.30}/environment.yml +1 -2
  4. {dartsort-0.5.28 → dartsort-0.5.30}/pyproject.toml +3 -4
  5. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/agglomerate.py +14 -4
  6. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/cluster_util.py +3 -3
  7. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/clustering.py +1 -0
  8. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/mixture.py +2 -2
  9. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/refine_util.py +14 -3
  10. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/config.py +8 -3
  11. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/evaluate/analysis.py +2 -1
  12. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/evaluate/hybridkit.py +1 -1
  13. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/evaluate/noise_recording_tools.py +2 -2
  14. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/localize/localize_util.py +1 -2
  15. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/peel_base.py +4 -39
  16. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/subtract.py +10 -12
  17. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/subtract_util.py +0 -28
  18. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/_multichan_denoiser_kit.py +1 -1
  19. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/mixture_classifier.py +38 -71
  20. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/reduction.py +0 -3
  21. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/data_util.py +8 -6
  22. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/drift_util.py +1 -1
  23. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/internal_config.py +9 -5
  24. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/multiprocessing_util.py +2 -2
  25. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/preprocess_util.py +3 -3
  26. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/registration_util.py +22 -14
  27. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/waveform_util.py +1 -1
  28. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/mixture.py +11 -2
  29. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/unit.py +18 -4
  30. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort.egg-info/PKG-INFO +4 -4
  31. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort.egg-info/requires.txt +2 -2
  32. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_clustering.py +7 -3
  33. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_drift_util.py +23 -2
  34. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_simkit.py +7 -2
  35. {dartsort-0.5.28 → dartsort-0.5.30}/.github/workflows/ci_windows.yml +0 -0
  36. {dartsort-0.5.28 → dartsort-0.5.30}/.github/workflows/deploy.yml +0 -0
  37. {dartsort-0.5.28 → dartsort-0.5.30}/.github/workflows/docs.yml +0 -0
  38. {dartsort-0.5.28 → dartsort-0.5.30}/.gitignore +0 -0
  39. {dartsort-0.5.28 → dartsort-0.5.30}/README.md +0 -0
  40. {dartsort-0.5.28 → dartsort-0.5.30}/docs/index.md +0 -0
  41. {dartsort-0.5.28 → dartsort-0.5.30}/docs/main_api.md +0 -0
  42. {dartsort-0.5.28 → dartsort-0.5.30}/docs/toolkit_api.md +0 -0
  43. {dartsort-0.5.28 → dartsort-0.5.30}/notebook/.keep +0 -0
  44. {dartsort-0.5.28 → dartsort-0.5.30}/notebook/fit_and_batch_matching.py +0 -0
  45. {dartsort-0.5.28 → dartsort-0.5.30}/notebook/ibl_dandi_example.py +0 -0
  46. {dartsort-0.5.28 → dartsort-0.5.30}/setup.cfg +0 -0
  47. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/__init__.py +0 -0
  48. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/__main__.py +0 -0
  49. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/cli.py +0 -0
  50. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/__init__.py +0 -0
  51. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/clustering_features.py +0 -0
  52. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/density.py +0 -0
  53. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/forward_backward.py +0 -0
  54. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/kmeans.py +0 -0
  55. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/clustering/merge.py +0 -0
  56. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/detect/__init__.py +0 -0
  57. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/detect/detect.py +0 -0
  58. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/evaluate/__init__.py +0 -0
  59. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/evaluate/comparison.py +0 -0
  60. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/evaluate/hybrid_util.py +0 -0
  61. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/evaluate/sim_template_tools.py +0 -0
  62. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/evaluate/simkit.py +0 -0
  63. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/evaluate/simlib.py +0 -0
  64. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/localize/__init__.py +0 -0
  65. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/localize/localize_torch.py +0 -0
  66. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/main.py +0 -0
  67. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/__init__.py +0 -0
  68. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/grab.py +0 -0
  69. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/matching.py +0 -0
  70. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/matching_util/__init__.py +0 -0
  71. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/matching_util/compressed_upsampled.py +0 -0
  72. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/matching_util/drifty.py +0 -0
  73. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/matching_util/matching_base.py +0 -0
  74. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/matching_util/pairwise.py +0 -0
  75. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/matching_util/pairwise_util.py +0 -0
  76. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/peel_lib.py +0 -0
  77. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/reduction_template.py +0 -0
  78. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/shaver.py +0 -0
  79. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/peel/threshold.py +0 -0
  80. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/pretrained/default_temporal_kernel.npy +0 -0
  81. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/pretrained/detect_np1.pt +0 -0
  82. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/pretrained/detect_np2.pt +0 -0
  83. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/pretrained/glasbey1024.npz +0 -0
  84. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/pretrained/offset_trained_denoiser.pt +0 -0
  85. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/pretrained/offset_trained_denoiser_added_temp.pt +0 -0
  86. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/pretrained/offset_trained_denoiser_added_temp_boost.pt +0 -0
  87. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/pretrained/original_single_chan_denoiser.pt +0 -0
  88. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/pretrained/single_chan_denoiser.pt +0 -0
  89. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/templates/__init__.py +0 -0
  90. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/templates/get_templates.py +0 -0
  91. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/templates/postprocess_util.py +0 -0
  92. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/templates/realignment.py +0 -0
  93. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/templates/template_util.py +0 -0
  94. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/templates/templates.py +0 -0
  95. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/templates/templib.py +0 -0
  96. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/__init__.py +0 -0
  97. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/all_transformers.py +0 -0
  98. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/amortized_localization.py +0 -0
  99. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/amplitudes.py +0 -0
  100. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/decollider.py +0 -0
  101. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/denoising_scorer.py +0 -0
  102. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/enforce_decrease.py +0 -0
  103. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/fixed_prop.py +0 -0
  104. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/interp.py +0 -0
  105. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/localize.py +0 -0
  106. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/matched_filter_net.py +0 -0
  107. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/matching_denoiser.py +0 -0
  108. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/pipeline.py +0 -0
  109. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/single_channel_denoiser.py +0 -0
  110. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/supervised_denoiser.py +0 -0
  111. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/temporal_pca.py +0 -0
  112. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/transform_base.py +0 -0
  113. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/vq_matched_filter.py +0 -0
  114. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/transform/whiten.py +0 -0
  115. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/__init__.py +0 -0
  116. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/cli_util.py +0 -0
  117. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/interpolation_util.py +0 -0
  118. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/job_util.py +0 -0
  119. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/logging_util.py +0 -0
  120. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/main_util.py +0 -0
  121. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/more_operators.py +0 -0
  122. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/motion.py +0 -0
  123. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/nn_util.py +0 -0
  124. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/noise_util.py +0 -0
  125. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/peel_util.py +0 -0
  126. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/py_util.py +0 -0
  127. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/residual_util.py +0 -0
  128. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/sparse_util.py +0 -0
  129. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/spikeio.py +0 -0
  130. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/spiketorch.py +0 -0
  131. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/testing_util/__init__.py +0 -0
  132. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/testing_util/matching_debug_util.py +0 -0
  133. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/testing_util/mixture_testing_util.py +0 -0
  134. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/torch_optimization_util.py +0 -0
  135. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/util/torch_util.py +0 -0
  136. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/__init__.py +0 -0
  137. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/analysis_plots.py +0 -0
  138. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/colors.py +0 -0
  139. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/gt.py +0 -0
  140. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/layout.py +0 -0
  141. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/metrics_util.py +0 -0
  142. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/recanim.py +0 -0
  143. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/scatterplots.py +0 -0
  144. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/sorting.py +0 -0
  145. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/unit_comparison.py +0 -0
  146. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/versus.py +0 -0
  147. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/vismain.py +0 -0
  148. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort/vis/waveforms.py +0 -0
  149. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort.egg-info/SOURCES.txt +0 -0
  150. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort.egg-info/dependency_links.txt +0 -0
  151. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort.egg-info/entry_points.txt +0 -0
  152. {dartsort-0.5.28 → dartsort-0.5.30}/src/dartsort.egg-info/top_level.txt +0 -0
  153. {dartsort-0.5.28 → dartsort-0.5.30}/tests/conftest.py +0 -0
  154. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_agglomerate.py +0 -0
  155. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_alignment.py +0 -0
  156. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_cluster_util.py +0 -0
  157. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_clustering_features.py +0 -0
  158. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_config.py +0 -0
  159. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_dartsort.py +0 -0
  160. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_data_util.py +0 -0
  161. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_density.py +0 -0
  162. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_detect.py +0 -0
  163. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_drifty_matching.py +0 -0
  164. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_enforce_decrease.py +0 -0
  165. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_grab_and_featurize.py +0 -0
  166. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_hybridkit.py +0 -0
  167. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_kmeans.py +0 -0
  168. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_linalg.py +0 -0
  169. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_localize_torch.py +0 -0
  170. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_matching.py +0 -0
  171. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_mixture_classifier.py +0 -0
  172. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_modeling.py +0 -0
  173. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_spiketorch.py +0 -0
  174. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_subtract.py +0 -0
  175. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_templates.py +0 -0
  176. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_threshold.py +0 -0
  177. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_torch_optimization_util.py +0 -0
  178. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_transform.py +0 -0
  179. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_util.py +0 -0
  180. {dartsort-0.5.28 → dartsort-0.5.30}/tests/test_waveform_util.py +0 -0
  181. {dartsort-0.5.28 → dartsort-0.5.30}/zensical.toml +0 -0
@@ -19,14 +19,14 @@ jobs:
19
19
 
20
20
  steps:
21
21
  - name: Checkout
22
- uses: actions/checkout@v4
22
+ uses: actions/checkout@v7
23
23
  with:
24
24
  path: dartsort
25
25
 
26
26
  - name: Fetch tags and describe
27
27
  run: pushd dartsort/ && git fetch --prune --unshallow --tags && git describe && popd
28
28
 
29
- - uses: actions/setup-python@v6
29
+ - uses: actions/setup-python@v7
30
30
  with:
31
31
  python-version: "3.x"
32
32
  cache: "pip" # caching pip dependencies
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dartsort
3
- Version: 0.5.28
3
+ Version: 0.5.30
4
4
  Summary: DARTsort
5
5
  Author-email: Charlie Windolf <ciw2048@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/cwindolf/dartsort
@@ -8,12 +8,11 @@ Project-URL: Bug Tracker, https://github.com/cwindolf/dartsort/issues
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.11
11
+ Requires-Python: >=3.12
12
12
  Description-Content-Type: text/markdown
13
- Requires-Dist: dredge-ephys
13
+ Requires-Dist: dredge-ephys>=0.4.0
14
14
  Requires-Dist: h5py
15
15
  Requires-Dist: jaxtyping
16
- Requires-Dist: kdepy
17
16
  Requires-Dist: linear_operator
18
17
  Requires-Dist: numba
19
18
  Requires-Dist: numpy>=1.20; python_version < "3.13"
@@ -37,6 +36,7 @@ Provides-Extra: test
37
36
  Requires-Dist: pytest; extra == "test"
38
37
  Requires-Dist: pytest-cov; extra == "test"
39
38
  Provides-Extra: vis
39
+ Requires-Dist: kdepy; extra == "vis"
40
40
  Requires-Dist: matplotlib; extra == "vis"
41
41
  Requires-Dist: seaborn; extra == "vis"
42
42
  Requires-Dist: matplotlib-venn; extra == "vis"
@@ -3,12 +3,11 @@ name: dartsort
3
3
  channels:
4
4
  - conda-forge
5
5
  dependencies:
6
- - python=3.14
6
+ - python>=3.11
7
7
  - h5py
8
8
  - ipykernel
9
9
  - ipython
10
10
  - ipywidgets
11
- - kdepy
12
11
  - linear_operator
13
12
  - matplotlib
14
13
  - numba
@@ -8,17 +8,16 @@ dynamic = ["version"]
8
8
  authors = [{ name = "Charlie Windolf", email = "ciw2048@gmail.com" }]
9
9
  description = "DARTsort"
10
10
  readme = "README.md"
11
- requires-python = ">=3.11"
11
+ requires-python = ">=3.12"
12
12
  classifiers = [
13
13
  "Programming Language :: Python :: 3",
14
14
  "License :: OSI Approved :: MIT License",
15
15
  "Operating System :: OS Independent",
16
16
  ]
17
17
  dependencies = [
18
- "dredge-ephys",
18
+ "dredge-ephys>=0.4.0",
19
19
  "h5py",
20
20
  "jaxtyping",
21
- "kdepy",
22
21
  "linear_operator",
23
22
  "numba",
24
23
  "numpy>=1.20;python_version<'3.13'",
@@ -40,7 +39,7 @@ dependencies = [
40
39
  [project.optional-dependencies]
41
40
  doc = ["zensical", "mkdocstrings-python"]
42
41
  test = ["pytest", "pytest-cov"]
43
- vis = ["matplotlib", "seaborn", "matplotlib-venn"]
42
+ vis = ["kdepy", "matplotlib", "seaborn", "matplotlib-venn"]
44
43
 
45
44
  [project.urls]
46
45
  "Homepage" = "https://github.com/cwindolf/dartsort"
@@ -6,9 +6,15 @@ from typing import cast
6
6
  import numba
7
7
  import numpy as np
8
8
  import torch
9
- from KDEpy import FFTKDE
10
9
  from spikeinterface.core import BaseRecording
11
10
 
11
+ try:
12
+ import KDEpy
13
+
14
+ HAVE_KDEPY = True
15
+ except ImportError:
16
+ HAVE_KDEPY = False
17
+
12
18
  from ..templates.template_util import shared_basis_compress_templates
13
19
  from ..templates.templates import TemplateData
14
20
  from ..util.data_util import (
@@ -479,6 +485,8 @@ def qda(
479
485
  ) -> QDAResult:
480
486
  from ..util.data_util import get_gmm_scores
481
487
 
488
+ assert HAVE_KDEPY or not bimodality
489
+
482
490
  # reconstruct scores from sorting attached data (exclude train_ix?)
483
491
  gscores = get_gmm_scores(sorting)
484
492
  glabels = sorting.labels
@@ -597,6 +605,8 @@ def _qda_job(ij):
597
605
  assert np.isclose(binc[bc], 0.0)
598
606
  assert binc.shape[0] == 2 * bc + 1
599
607
 
608
+ from KDEpy import FFTKDE
609
+
600
610
  try:
601
611
  kde = FFTKDE(bw="ISJ").fit(dll)
602
612
  except ValueError as e:
@@ -807,7 +817,7 @@ def _check_soft_assign_invariants(
807
817
  maxdiff = -np.inf
808
818
  n_neginf_viol = 0
809
819
 
810
- for s in numba.prange(cand.shape[0]): # ty: ignore[not-iterable]
820
+ for s in numba.prange(cand.shape[0]):
811
821
  for j in range(n_cand):
812
822
  if cand[s, j] < 0:
813
823
  nbye += 1
@@ -827,7 +837,7 @@ def _assign_labels(
827
837
  n_changed = 0
828
838
  n_labeled = 0
829
839
 
830
- for s in numba.prange(cand.shape[0]): # ty: ignore[not-iterable]
840
+ for s in numba.prange(cand.shape[0]):
831
841
  if labels[s] >= 0:
832
842
  n_labeled += 1
833
843
  if labels[s] != cand[s, 0]:
@@ -846,7 +856,7 @@ def _combine_loop(
846
856
  ):
847
857
  n_cand = cand.shape[1]
848
858
 
849
- for s in numba.prange(cand.shape[0]): # ty: ignore
859
+ for s in numba.prange(cand.shape[0]):
850
860
  spike_cand = cand[s]
851
861
  for j in range(n_cand - 1):
852
862
  spike_candj = spike_cand[j]
@@ -121,7 +121,7 @@ def merge_group_shifts(
121
121
 
122
122
  @numba.njit(nogil=True, parallel=True)
123
123
  def apply_time_shifts(times: np.ndarray, labels: np.ndarray, unit_shifts: np.ndarray):
124
- for i in numba.prange(times.shape[0]): # ty: ignore[not-iterable]
124
+ for i in numba.prange(times.shape[0]):
125
125
  label = labels[i]
126
126
  if label >= 0:
127
127
  times[i] -= unit_shifts[label]
@@ -867,7 +867,7 @@ def _violation_count_matrix(
867
867
  n = times.shape[0]
868
868
 
869
869
  # parallelize over chunks
870
- for c in numba.prange(starts.shape[0] - 1): # ty: ignore[not-iterable]
870
+ for c in numba.prange(starts.shape[0] - 1):
871
871
  out = counts[c] # my thread's output buffer
872
872
 
873
873
  for i in range(starts[c], starts[c + 1]):
@@ -904,7 +904,7 @@ def _violation_weight_matrix(
904
904
  window_length = weights.shape[0] - 1
905
905
 
906
906
  # parallelize over chunks
907
- for c in numba.prange(starts.shape[0] - 1): # ty: ignore[not-iterable]
907
+ for c in numba.prange(starts.shape[0] - 1):
908
908
  out = sums[c] # my thread's output buffer
909
909
 
910
910
  for i in range(starts[c], starts[c + 1]):
@@ -838,6 +838,7 @@ class TMMRefinement(Refinement):
838
838
  save_step_labels_format=self.labels_fmt,
839
839
  save_step_labels_dir=self.save_labels_dir,
840
840
  save_cfg=self.save_cfg,
841
+ seed=self.refinement_cfg.sampling_cfg.seed,
841
842
  skip_final_assign_and_return_mix_data=skip_final_assign_and_return_mix_data,
842
843
  )
843
844
  gc.collect()
@@ -7598,7 +7598,7 @@ def _update_lut_mean_batch(
7598
7598
 
7599
7599
  # constplogdet. add in the signal-rank-0-only terms.
7600
7600
  lut_params.constplogdet[i0:i1] = neighb_cov.nobs[nn].mul_(LOG_2PI) # type: ignore # ty: ignore[x]
7601
- lut_params.constplogdet[i0:i1] += neighb_cov.b.logdet[nn]
7601
+ lut_params.constplogdet[i0:i1] += neighb_cov.b.logdet[nn] # ty: ignore[not-subscriptable]
7602
7602
  if pnoid:
7603
7603
  assert lut_params.constplogdet[i0:i1].isfinite().all() # type: ignore # ty: ignore[x]
7604
7604
 
@@ -7658,7 +7658,7 @@ def _update_lut_ppca_batch(
7658
7658
  assert lut_params.Tpad is not None
7659
7659
  lut_params.Tpad[i0:i1, :, :-1] = T # type: ignore # ty: ignore[x]
7660
7660
  cap_logdet = L.diagonal(dim1=-2, dim2=-1).log().sum(dim=1).mul_(2.0)
7661
- lut_params.constplogdet[i0:i1] += cap_logdet
7661
+ lut_params.constplogdet[i0:i1] += cap_logdet # ty: ignore[not-subscriptable]
7662
7662
  if pnoid:
7663
7663
  assert lut_params.b.constplogdet[i0:i1].isfinite().all()
7664
7664
 
@@ -4,12 +4,17 @@ from typing import cast
4
4
  import numba
5
5
  import numpy as np
6
6
  import torch
7
- from KDEpy import FFTKDE
8
- from KDEpy.bw_selection import improved_sheather_jones
9
7
  from scipy.spatial import KDTree
10
8
  from scipy.stats import norm
11
9
  from spikeinterface.core.baserecording import BaseRecording
12
10
 
11
+ try:
12
+ import KDEpy
13
+
14
+ HAVE_KDEPY = True
15
+ except ImportError:
16
+ HAVE_KDEPY = False
17
+
13
18
  from dartsort.clustering.mixture import Scores
14
19
 
15
20
  from ..util import data_util, spiketorch
@@ -392,7 +397,9 @@ def collision_cleaning_error_filter(
392
397
  assert flag_scores.excess_rate is not None
393
398
  flag_bad |= flag_scores.excess_rate > refinement_cfg.cc_flag_excess_rate
394
399
 
395
- logger.dartsortdebug(f"CC flag criterion dropped {flag_bad.sum()} / {nu0} units.")
400
+ logger.dartsortdebug(
401
+ f"CC flag criterion dropped {flag_bad.sum()} / {nu0} units."
402
+ )
396
403
  keep_mask &= np.logical_not(flag_bad)
397
404
 
398
405
  bad_ids = np.flatnonzero(np.logical_not(keep_mask))
@@ -646,6 +653,7 @@ def gmm_isolation_scores(
646
653
  kde_rhs=50.0,
647
654
  kde_dx: float = 0.5,
648
655
  ) -> GMMIsolationScores:
656
+ assert HAVE_KDEPY
649
657
  if unit_ids is None:
650
658
  unit_ids = np.arange(scores.candidates[:, 0].max().item() + 1)
651
659
  assert unit_ids is not None
@@ -761,6 +769,9 @@ def _iso_job(unit_id) -> tuple[float, np.ndarray | None, np.ndarray | None]:
761
769
  # fit kde. will symmetrize around 0 to avoid boundary issues (since lr>=0)
762
770
  amax = in_lr.abs().amax().item()
763
771
  lr = in_lr.double().numpy(force=True)
772
+ from KDEpy import FFTKDE
773
+ from KDEpy.bw_selection import improved_sheather_jones
774
+
764
775
  try:
765
776
  # select bandwidth based on positive part
766
777
  bw = improved_sheather_jones(lr[:, None])
@@ -10,6 +10,7 @@ from .util.internal_config import (
10
10
  KmeansppSelection,
11
11
  KmeansppStopping,
12
12
  MixtureStep,
13
+ MotionBatchingMode,
13
14
  PreprocessingStrategy,
14
15
  RealignStrategy,
15
16
  TemplateSVDMethod,
@@ -250,6 +251,10 @@ class DARTsortUserConfig:
250
251
  max_dist_from_median_um: float = 250.0
251
252
  """Motion bins farther than this from the local median will be replaced by interpolation."""
252
253
  median_neighborhood_bins: int = 51
254
+ motion_batching_mode: MotionBatchingMode = "full"
255
+ """'full' or 'online'. Online helps with long recordings."""
256
+ motion_chunk_len_s: Annotated[float, Field(gt=0)] = 3000.0
257
+ """Chunk length in seconds for online motion tracking"""
253
258
 
254
259
  # -- pipeline control parameters for specific use cases
255
260
  fit_matching_models_only: bool = False
@@ -369,8 +374,8 @@ class DeveloperConfig(DARTsortUserConfig):
369
374
  kmeanspp_patience: int = 21
370
375
  kmeanspp_greedy_proposals: int = 1
371
376
  kmeanspp_neighb_overlap: float | None = None
372
- kmeanspp_selection: KmeansppSelection = "phi"
373
- kmeanspp_stopping: KmeansppStopping = "patience"
377
+ kmeanspp_selection: KmeansppSelection = "marginal"
378
+ kmeanspp_stopping: KmeansppStopping = "dpmeanspp"
374
379
 
375
380
  # filters
376
381
  gmm_isolation_threshold: float | None = None
@@ -401,7 +406,7 @@ class DeveloperConfig(DARTsortUserConfig):
401
406
  gmm_n_candidates: int = 5
402
407
  gmm_n_search: int | None = 3
403
408
  gmm_val_proportion: Annotated[float, Field(gt=0)] = 0.5
404
- gmm_batch_size: int = 2048
409
+ gmm_batch_size: int = 4096
405
410
  initial_basis_shrinkage: float = 1.0
406
411
  prior_pseudocount: float = 0.0
407
412
  cov_kind: str = "factorizednoise"
@@ -16,7 +16,7 @@ import spikeinterface.core as sc
16
16
  import torch
17
17
  from sklearn.decomposition import PCA
18
18
 
19
- from ..clustering.agglomerate import QDAResult, qda, template_distances
19
+ from ..clustering.agglomerate import HAVE_KDEPY, QDAResult, qda, template_distances
20
20
  from ..templates import TemplateData
21
21
  from ..util import job_util, logging_util
22
22
  from ..util.data_util import (
@@ -193,6 +193,7 @@ class DARTsortAnalysis:
193
193
 
194
194
  if (
195
195
  allow_qda
196
+ and HAVE_KDEPY
196
197
  and template_data is not None
197
198
  and hasattr(sorting, "gmm_candidates")
198
199
  ):
@@ -135,7 +135,7 @@ def make_hybrid_recording(
135
135
  assert target_recording.get_num_segments() == 1
136
136
  assert injected_sorting.get_num_segments() == 1
137
137
  if hasattr(injected_sorting, "get_last_spike_frame"):
138
- assert injected_sorting.get_last_spike_frame() < target_recording.get_num_frames() # ty:ignore[call-non-callable]
138
+ assert injected_sorting.get_last_spike_frame() < target_recording.get_num_frames()
139
139
  assert abs(templates.sampling_frequency - target_sampling_frequency) < 10
140
140
 
141
141
  if folder is not None and not overwrite:
@@ -71,7 +71,7 @@ def get_background_recording(
71
71
  spatial_std, spatial_vt = rbf_kernel_sqrt(
72
72
  geom, bandwidth=noise_spatial_kernel_bandwidth
73
73
  )
74
- noise_temporal_kernel = noise_temporal_kernel.astype(spatial_vt.dtype) + 0j # ty:ignore[no-matching-overload]
74
+ noise_temporal_kernel = noise_temporal_kernel.astype(spatial_vt.dtype) + 0j
75
75
  noise = StationaryFactorizedNoise(
76
76
  spatial_std=spatial_std,
77
77
  vt_spatial=spatial_vt,
@@ -119,7 +119,7 @@ class WhiteNoiseRecording(BaseRecording):
119
119
  channel_ids = np.asarray(channel_ids)
120
120
  assert channel_ids.shape == (n_channels,)
121
121
  assert n_segments == 1
122
- super().__init__(sampling_frequency, channel_ids=channel_ids, dtype=dtype) # type: ignore
122
+ super().__init__(sampling_frequency, channel_ids=channel_ids, dtype=dtype)
123
123
  self._serializability["json"] = False
124
124
  self._serializability["pickle"] = False
125
125
  segment = WhiteNoiseRecordingSegment(
@@ -21,7 +21,6 @@ def localize_waveforms(
21
21
  radius=None,
22
22
  n_channels_subset=None,
23
23
  ):
24
- C, dim = geom.shape
25
24
  amp_vecs = ptp(waveforms, 1)
26
25
  if main_channels is None:
27
26
  main_channels = amp_vecs.argmax(1)
@@ -287,7 +286,7 @@ def point_source_mse(locs, amp_vecs, channels, channel_index, geom):
287
286
  torch.asarray(amp_vecs).nan_to_num(),
288
287
  channel_mask,
289
288
  *torch.asarray(locs).T,
290
- torch.asarray(dxz).nan_to_num(),
289
+ torch.asarray(dxz).nan_to_num(), # ty: ignore[too-many-positional-arguments]
291
290
  )
292
291
  alpha = alpha.numpy()
293
292
  else:
@@ -907,17 +907,10 @@ class BasePeeler(BModule):
907
907
  def sample_chunks(
908
908
  self, chunk_starts_samples: np.ndarray, n_chunks: int, ordered: bool = False
909
909
  ) -> np.ndarray:
910
- if self.fit_sampling_cfg.chunk_sampling == "random":
911
- rg = np.random.default_rng(self.random_seed)
912
- chunk_starts_samples = rg.choice(
913
- chunk_starts_samples, size=n_chunks, replace=False
914
- )
915
- elif self.fit_sampling_cfg.chunk_sampling == "kmeanspp":
916
- _ix = _kmeansppix(len(chunk_starts_samples), n_chunks, self.random_seed)
917
- chunk_starts_samples = chunk_starts_samples[_ix]
918
- else:
919
- panic(self.fit_sampling_cfg.chunk_sampling)
920
-
910
+ rg = np.random.default_rng(self.random_seed)
911
+ chunk_starts_samples = rg.choice(
912
+ chunk_starts_samples, size=n_chunks, replace=False
913
+ )
921
914
  if ordered:
922
915
  chunk_starts_samples.sort()
923
916
 
@@ -1354,31 +1347,3 @@ def _peeler_process_job(chunk_start_samples__n_resid_snips):
1354
1347
  skip_features=_peeler_process_context.ctx.skip_features,
1355
1348
  to_cpu=_peeler_process_context.ctx.to_cpu,
1356
1349
  )
1357
-
1358
-
1359
- def _kmeansppix(n: int, k: int | None = None, seed=0):
1360
- rg = np.random.default_rng(seed)
1361
- k = k if k is not None else n
1362
- assert 0 < k <= n
1363
-
1364
- xx = np.arange(float(n))
1365
- xx -= np.mean(xx)
1366
- xx /= np.std(xx)
1367
-
1368
- inds = np.full((k,), n + 1, dtype=np.int64)
1369
- inds[0] = rg.integers(n)
1370
-
1371
- dist = xx - xx[inds[0]]
1372
- dist *= dist
1373
-
1374
- scratch = np.empty_like(dist)
1375
-
1376
- for j in range(1, k):
1377
- p = np.divide(dist, dist.sum(), out=scratch)
1378
- inds[j] = rg.choice(n, p=p)
1379
- dj = np.subtract(xx, xx[inds[j]], out=scratch)
1380
- dj *= dj
1381
- np.minimum(dist, dj, out=dist)
1382
-
1383
- assert np.unique(inds).shape == (k,)
1384
- return inds
@@ -43,7 +43,6 @@ from .subtract_util import (
43
43
  ChunkSubtracter,
44
44
  make_peak_proposer,
45
45
  proposal_filters_from_pipeline,
46
- proposal_fit_featurization_cfg,
47
46
  with_proposal_filters,
48
47
  )
49
48
 
@@ -64,7 +63,6 @@ class SubtractionPeeler(BasePeeler):
64
63
  p: SubtractionConfig = default_subtraction_cfg,
65
64
  waveform_cfg: WaveformConfig = default_waveform_cfg,
66
65
  fit_sampling_cfg: FitSamplingConfig = default_peeling_fit_sampling_cfg,
67
- featurization_cfg: FeaturizationConfig | None = None,
68
66
  save_iteration=False,
69
67
  save_residnorm_decrease=False,
70
68
  save_collidedness=False,
@@ -94,8 +92,6 @@ class SubtractionPeeler(BasePeeler):
94
92
  self.save_iteration = save_iteration
95
93
  self.save_residnorm_decrease = save_residnorm_decrease
96
94
  self.save_collidedness = save_collidedness
97
- # non-voltage proposal may need this config
98
- self.featurization_cfg = featurization_cfg
99
95
  self.dedup_batch_size = self.nearest_batch_length()
100
96
  if self.p.whiten:
101
97
  self.threshold = self.p.threshold_before_whitening
@@ -388,7 +384,6 @@ class SubtractionPeeler(BasePeeler):
388
384
  p=subtraction_cfg,
389
385
  waveform_cfg=waveform_cfg,
390
386
  fit_sampling_cfg=sampling_cfg,
391
- featurization_cfg=featurization_cfg,
392
387
  save_iteration=subtraction_cfg.save_iteration,
393
388
  save_residnorm_decrease=subtraction_cfg.save_residnorm_decrease,
394
389
  save_collidedness=save_collidedness,
@@ -628,10 +623,8 @@ class SubtractionPeeler(BasePeeler):
628
623
 
629
624
  def _threshold_to_fit(self, tmp_dir, fit_pipeline, computation_cfg):
630
625
  threshold_cfg = ThresholdingConfig(
631
- detection_proposal=self.p.detection_proposal,
632
- proposal_filters=self.p.proposal_filters,
626
+ detection_proposal="voltage",
633
627
  voltage_threshold=self.p.voltage_threshold,
634
- proposal_threshold=self.p.proposal_threshold,
635
628
  spatial_dedup_radius_um=(
636
629
  self.p.first_denoiser_spatial_dedup_radius or self.p.subtract_radius_um
637
630
  ),
@@ -659,10 +652,15 @@ class SubtractionPeeler(BasePeeler):
659
652
  waveform_cfg=self.waveform_cfg,
660
653
  channel_index=self.b.sub_channel_index,
661
654
  threshold_cfg=threshold_cfg,
662
- featurization_cfg=proposal_fit_featurization_cfg(
663
- self.featurization_cfg,
664
- self.p.detection_proposal,
665
- self.p.proposal_filters,
655
+ featurization_cfg=FeaturizationConfig(
656
+ do_tpca_denoise=False,
657
+ do_enforce_decrease="no",
658
+ save_input_voltages=False,
659
+ save_input_waveforms=True,
660
+ save_input_tpca_projs=False,
661
+ save_amplitudes=False,
662
+ do_localization=False,
663
+ input_waveforms_name="",
666
664
  ),
667
665
  sampling_cfg=sampling_cfg,
668
666
  max_waveforms_fit=self.p.first_denoiser_max_waveforms_fit,
@@ -708,34 +708,6 @@ def with_proposal_filters(
708
708
  panic(proposal)
709
709
 
710
710
 
711
- def proposal_fit_featurization_cfg(
712
- featurization_cfg: FeaturizationConfig | None,
713
- proposal: DetectionProposal,
714
- n_filters: int,
715
- ) -> FeaturizationConfig:
716
- if featurization_cfg is None and proposal != "voltage":
717
- raise ValueError(
718
- f"{proposal=} needs the featurization config its filters are fit with."
719
- )
720
- if featurization_cfg is None:
721
- featurization_cfg = FeaturizationConfig()
722
- waveforms_only = FeaturizationConfig(
723
- do_tpca_denoise=False,
724
- do_enforce_decrease="no",
725
- save_input_voltages=False,
726
- save_input_waveforms=True,
727
- save_input_tpca_projs=False,
728
- save_amplitudes=False,
729
- do_localization=False,
730
- input_waveforms_name="",
731
- tpca_rank=featurization_cfg.tpca_rank,
732
- tpca_fit_radius=featurization_cfg.tpca_fit_radius,
733
- tpca_max_waveforms=featurization_cfg.tpca_max_waveforms,
734
- input_tpca_waveform_cfg=featurization_cfg.input_tpca_waveform_cfg,
735
- )
736
- return with_proposal_filters(waveforms_only, proposal, n_filters)
737
-
738
-
739
711
  def proposal_filters_from_pipeline(
740
712
  pipeline: "WaveformPipeline", proposal: DetectionProposal, n_filters: int
741
713
  ) -> tuple[Tensor, int]:
@@ -353,7 +353,7 @@ def get_noise_h5(
353
353
 
354
354
  @numba.njit(parallel=True)
355
355
  def take_along_dim2_masked(arr, out, channels, mask_val):
356
- for i in numba.prange(arr.shape[0]): # type: ignore
356
+ for i in numba.prange(arr.shape[0]):
357
357
  wf = arr[i]
358
358
  cc = channels[i]
359
359
  for t in range(arr.shape[1]):
@@ -159,24 +159,9 @@ class TruncatedMixtureModelTransformer(BaseWaveformFeaturizer):
159
159
  cii, cjj = np.nonzero(self.channel_index_np < len(self.channel_index_np))
160
160
  self.channel_index_valid_inds = cii, cjj
161
161
 
162
- # precompute drifting neighborhood lookup tables
163
162
  if self.motion.drifting:
164
- # in this case, prebake a lookup table
165
- # TODO just consider relevant time bins here?
166
- # or chunk this somehow?
167
- tbs = self.motion.time_bins_s
168
- tcm_t, nid_t = neighborhood_mapping_at_time(
169
- motion=self.motion,
170
- t_s=torch.from_numpy(tbs),
171
- neighborhoods=self.b.neighborhoods,
172
- channel_index=self.channel_index_np,
173
- workers=self.workers,
174
- static_neighbs=self.static_neighbs,
175
- channel_index_valid_inds=self.channel_index_valid_inds,
176
- )
177
163
  nid_map = None
178
164
  else:
179
- tcm_t = nid_t = tbs = None
180
165
  # in this case, channel index is a superset of neighborhoods and
181
166
  # we prebake the mapping from chans to neighb ids
182
167
  ci_eq_neighb = _outer_all_equal(
@@ -193,13 +178,6 @@ class TruncatedMixtureModelTransformer(BaseWaveformFeaturizer):
193
178
  )
194
179
  nid_map[_chans] = _chan_nids
195
180
  self.register_buffer_or_none("neighborhood_ids_map", nid_map)
196
- self.drifting_time_bins_s = tbs
197
- self.register_buffer_or_none(
198
- "drifting_target_channels_map_t", tcm_t, persistent=False
199
- )
200
- self.register_buffer_or_none(
201
- "drifting_neighborhood_ids_map_t", nid_t, persistent=False
202
- )
203
181
 
204
182
  def fit(
205
183
  self,
@@ -360,10 +338,21 @@ class TruncatedMixtureModelTransformer(BaseWaveformFeaturizer):
360
338
  # drifting channel mapping
361
339
  assert self.motion is not None
362
340
  if self.motion.drifting:
363
- assert self.drifting_time_bins_s is not None
364
- t_idx = find_nearest(self.drifting_time_bins_s, chunk_center_s)
365
- target_channels_map = self.b.drifting_target_channels_map_t[t_idx]
366
- neighborhood_ids_map = self.b.drifting_neighborhood_ids_map_t[t_idx]
341
+ time_bins_s = self.motion.time_bins_s
342
+ t_bin_s = time_bins_s[find_nearest(time_bins_s, chunk_center_s)]
343
+ depths_um = self.motion.geom[:, 1]
344
+ _, n_pitches_shift = self.motion.pitch_shifts(
345
+ times_s=np.full_like(depths_um, t_bin_s), depths_um=depths_um
346
+ )
347
+ target_channels_map, neighborhood_ids_map = neighborhood_mapping_at_shift(
348
+ self.motion,
349
+ n_pitches_shift=n_pitches_shift,
350
+ channel_index=self.channel_index_np,
351
+ neighborhoods=self.b.neighborhoods,
352
+ static_neighbs=self.static_neighbs,
353
+ channel_index_valid_inds=self.channel_index_valid_inds,
354
+ workers=self.workers,
355
+ )
367
356
  else:
368
357
  target_channels_map = self.b.channel_index
369
358
  neighborhood_ids_map = self.b.neighborhood_ids_map
@@ -411,59 +400,37 @@ class TruncatedMixtureModelTransformer(BaseWaveformFeaturizer):
411
400
  return res
412
401
 
413
402
 
414
- def neighborhood_mapping_at_time(
403
+ def neighborhood_mapping_at_shift(
415
404
  motion: MotionInfo,
416
405
  *,
417
- t_s: torch.Tensor | np.ndarray,
406
+ n_pitches_shift: np.ndarray,
418
407
  channel_index: np.ndarray,
419
408
  neighborhoods: torch.Tensor,
420
- workers: int = 4,
421
- shift_mode="round",
422
409
  static_neighbs: np.ndarray,
423
410
  channel_index_valid_inds: tuple[np.ndarray, np.ndarray],
424
- ):
425
- t_s = t_s.numpy(force=True) if isinstance(t_s, torch.Tensor) else np.asarray(t_s)
426
- t_s = np.atleast_1d(t_s)
427
-
428
- index_at_time = torch.full((len(t_s), *channel_index.shape), -1)
429
- nids_at_time = torch.full(
430
- (len(t_s), channel_index.shape[0]),
431
- neighborhoods.shape[0],
432
- device=neighborhoods.device,
411
+ workers: int = 4,
412
+ ) -> tuple[torch.Tensor, torch.Tensor]:
413
+ """Map channels to registered target channels and neighborhood ids"""
414
+ shifted_neighbs = static_neighbs.copy()
415
+ shifted_neighbs[:, :, 1] += n_pitches_shift[:, None] * motion.pitch
416
+ _, umatch = motion.rgeom_kdt.query(
417
+ shifted_neighbs[channel_index_valid_inds],
418
+ distance_upper_bound=motion.min_dist,
419
+ workers=workers,
433
420
  )
421
+ index = np.full(channel_index.shape, motion.rgeom.shape[0])
422
+ index[channel_index_valid_inds] = umatch
423
+ index = torch.asarray(index, device=neighborhoods.device)
424
+ assert index.shape[1] == neighborhoods.shape[1]
425
+
426
+ mapping = _outer_all_equal(index, neighborhoods)
427
+ _chans, _chan_nids = mapping.nonzero(as_tuple=True)
428
+ nids = torch.full(
429
+ (channel_index.shape[0],), neighborhoods.shape[0], device=neighborhoods.device
430
+ )
431
+ nids[_chans] = _chan_nids
434
432
 
435
- for j, t in enumerate(t_s):
436
- probe_disp = -motion.disp_at_s(
437
- times_s=t, depths_um=motion.geom[:, 1], grid=True
438
- )
439
- if shift_mode == "floor":
440
- n_pitches_shift = (probe_disp / motion.pitch).astype(np.int32)
441
- elif shift_mode == "round":
442
- n_pitches_shift = np.round(probe_disp / motion.pitch).astype(np.int32)
443
- else:
444
- panic(shift_mode)
445
- shift = n_pitches_shift * motion.pitch
446
- shifted_neighbs = static_neighbs.copy()
447
- shifted_neighbs[:, :, 1] += shift
448
- _, umatch = motion.rgeom_kdt.query(
449
- shifted_neighbs[channel_index_valid_inds],
450
- distance_upper_bound=motion.min_dist,
451
- workers=workers,
452
- )
453
- index = np.full(channel_index.shape, motion.rgeom.shape[0])
454
- index[channel_index_valid_inds] = umatch
455
- index = torch.asarray(index, device=neighborhoods.device)
456
- assert index.shape[1] == neighborhoods.shape[1]
457
-
458
- index_at_time[j] = index
459
-
460
- mapping = _outer_all_equal(index, neighborhoods)
461
- _chans, _chan_nids = mapping.nonzero(as_tuple=True)
462
- nids_at_time[j, _chans] = _chan_nids
463
-
464
- assert (index_at_time >= 0).all()
465
-
466
- return index_at_time, nids_at_time
433
+ return index, nids
467
434
 
468
435
 
469
436
  @torch_compile