Skip to content

Commit 151947a

Browse files
authored
Merge pull request #3516 from cwindolf/np_ptp
Remove remaining array.ptp()s
2 parents 5bdcfce + 43b085f commit 151947a

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/spikeinterface/postprocessing/localization_tools.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import warnings
44

55
import numpy as np
6+
from spikeinterface.core import SortingAnalyzer, Templates, compute_sparsity
7+
from spikeinterface.core.template_tools import _get_nbefore, get_dense_templates_array, get_template_extremum_channel
68

79
try:
810
import numba
@@ -12,10 +14,6 @@
1214
HAVE_NUMBA = False
1315

1416

15-
from spikeinterface.core import compute_sparsity, SortingAnalyzer, Templates
16-
from spikeinterface.core.template_tools import get_template_extremum_channel, _get_nbefore, get_dense_templates_array
17-
18-
1917
def compute_monopolar_triangulation(
2018
sorting_analyzer_or_templates: SortingAnalyzer | Templates,
2119
unit_ids=None,
@@ -110,7 +108,7 @@ def compute_monopolar_triangulation(
110108
# wf is (nsample, nchan) - chann is only nieghboor
111109
wf = templates[i, :, :][:, chan_inds]
112110
if feature == "ptp":
113-
wf_data = wf.ptp(axis=0)
111+
wf_data = np.ptp(wf, axis=0)
114112
elif feature == "energy":
115113
wf_data = np.linalg.norm(wf, axis=0)
116114
elif feature == "peak_voltage":
@@ -188,7 +186,7 @@ def compute_center_of_mass(
188186
wf = templates[i, :, :]
189187

190188
if feature == "ptp":
191-
wf_data = (wf[:, chan_inds]).ptp(axis=0)
189+
wf_data = np.ptp(wf[:, chan_inds], axis=0)
192190
elif feature == "mean":
193191
wf_data = (wf[:, chan_inds]).mean(axis=0)
194192
elif feature == "energy":

src/spikeinterface/sortingcomponents/motion/dredge.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@
2222
2323
"""
2424

25+
import gc
2526
import warnings
2627

27-
from tqdm.auto import trange
2828
import numpy as np
29-
30-
import gc
29+
from tqdm.auto import trange
3130

3231
from .motion_utils import (
3332
Motion,
33+
get_spatial_bin_edges,
3434
get_spatial_windows,
3535
get_window_domains,
36-
scipy_conv1d,
3736
make_2d_motion_histogram,
38-
get_spatial_bin_edges,
37+
scipy_conv1d,
3938
)
4039

4140

@@ -979,7 +978,7 @@ def xcorr_windows(
979978

980979
if max_disp_um is None:
981980
if rigid:
982-
max_disp_um = int(spatial_bin_edges_um.ptp() // 4)
981+
max_disp_um = int(np.ptp(spatial_bin_edges_um) // 4)
983982
else:
984983
max_disp_um = int(win_scale_um // 4)
985984

0 commit comments

Comments
 (0)