Skip to content

Commit

Permalink
Remove remaining array.ptp()s
Browse files Browse the repository at this point in the history
  • Loading branch information
cwindolf committed Nov 1, 2024
1 parent 5bdcfce commit 74ef4eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
10 changes: 6 additions & 4 deletions src/spikeinterface/postprocessing/localization_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import warnings

import numpy as np
from spikeinterface.core import SortingAnalyzer, Templates, compute_sparsity
from spikeinterface.core.template_tools import (_get_nbefore,
get_dense_templates_array,
get_template_extremum_channel)

try:
import numba
Expand All @@ -12,8 +16,6 @@
HAVE_NUMBA = False


from spikeinterface.core import compute_sparsity, SortingAnalyzer, Templates
from spikeinterface.core.template_tools import get_template_extremum_channel, _get_nbefore, get_dense_templates_array


def compute_monopolar_triangulation(
Expand Down Expand Up @@ -110,7 +112,7 @@ def compute_monopolar_triangulation(
# wf is (nsample, nchan) - chann is only nieghboor
wf = templates[i, :, :][:, chan_inds]
if feature == "ptp":
wf_data = wf.ptp(axis=0)
wf_data = np.ptp(wf, axis=0)
elif feature == "energy":
wf_data = np.linalg.norm(wf, axis=0)
elif feature == "peak_voltage":
Expand Down Expand Up @@ -188,7 +190,7 @@ def compute_center_of_mass(
wf = templates[i, :, :]

if feature == "ptp":
wf_data = (wf[:, chan_inds]).ptp(axis=0)
wf_data = np.ptp(wf[:, chan_inds], axis=0)
elif feature == "mean":
wf_data = (wf[:, chan_inds]).mean(axis=0)
elif feature == "energy":
Expand Down
18 changes: 6 additions & 12 deletions src/spikeinterface/sortingcomponents/motion/dredge.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,15 @@
"""

import gc
import warnings

from tqdm.auto import trange
import numpy as np
from tqdm.auto import trange

import gc

from .motion_utils import (
Motion,
get_spatial_windows,
get_window_domains,
scipy_conv1d,
make_2d_motion_histogram,
get_spatial_bin_edges,
)
from .motion_utils import (Motion, get_spatial_bin_edges, get_spatial_windows,
get_window_domains, make_2d_motion_histogram,
scipy_conv1d)


# simple class wrapper to be compliant with estimate_motion
Expand Down Expand Up @@ -979,7 +973,7 @@ def xcorr_windows(

if max_disp_um is None:
if rigid:
max_disp_um = int(spatial_bin_edges_um.ptp() // 4)
max_disp_um = int(np.ptp(spatial_bin_edges_um) // 4)
else:
max_disp_um = int(win_scale_um // 4)

Expand Down

0 comments on commit 74ef4eb

Please sign in to comment.