Skip to content

Commit

Permalink
Fix variable typo; add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
cwindolf committed Nov 21, 2024
1 parent b80bad7 commit c890603
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import numpy as np
from spikeinterface.core.core_tools import define_function_from_class
from spikeinterface.preprocessing import get_spatial_interpolation_kernel
from spikeinterface.preprocessing.basepreprocessor import BasePreprocessor, BasePreprocessorSegment
from spikeinterface.preprocessing.basepreprocessor import (
BasePreprocessor, BasePreprocessorSegment)
from spikeinterface.preprocessing.filter import fix_dtype

from .motion_utils import ensure_time_bin_edges, ensure_time_bins
Expand Down Expand Up @@ -155,7 +156,7 @@ def interpolate_motion_on_traces(
interp_times = np.empty(total_num_chans)
current_start_index = 0
for interp_bin_ind in interpolation_bins_here:
bin_time = bin_centers_s[interp_bin_ind]
bin_time = interpolation_time_bin_centers_s[interp_bin_ind]
interp_times.fill(bin_time)
channel_motions = motion.get_displacement_at_time_and_depth(
interp_times,
Expand Down
16 changes: 16 additions & 0 deletions src/spikeinterface/sortingcomponents/motion/motion_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,22 @@ def make_3d_motion_histograms(


def ensure_time_bins(time_bin_centers_s=None, time_bin_edges_s=None):
"""Ensure that both bin edges and bin centers are present
If either of the inputs are None but not both, the missing is reconstructed
from the present. Going from edges to centers is done by taking midpoints.
Going from centers to edges is done by taking midpoints and padding with the
left and rightmost centers.
Parameters
----------
time_bin_centers_s : None or np.array
time_bin_edges_s : None or np.array
Returns
-------
time_bin_centers_s, time_bin_edges_s
"""
if time_bin_centers_s is None and time_bin_edges_s is None:
raise ValueError("Need at least one of time_bin_centers_s or time_bin_edges_s.")

Expand Down

0 comments on commit c890603

Please sign in to comment.