Skip to content

Commit

Permalink
Let recording handle times
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Sep 16, 2024
1 parent 3d41aca commit 36251ef
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/spikeinterface/widgets/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,11 @@ def __init__(
if peak_amplitudes is not None:
peak_amplitudes = peak_amplitudes[peak_mask]

if recording is not None:
sampling_frequency = recording.sampling_frequency
times = recording.get_times(segment_index=segment_index)
else:
times = None

plot_data = dict(
peaks=peaks,
peak_locations=peak_locations,
peak_amplitudes=peak_amplitudes,
direction=direction,
times=times,
sampling_frequency=sampling_frequency,
segment_index=segment_index,
depth_lim=depth_lim,
Expand All @@ -238,10 +231,10 @@ def plot_matplotlib(self, data_plot, **backend_kwargs):

self.figure, self.axes, self.ax = make_mpl_figure(**backend_kwargs)

if dp.times is None:
if dp.recording is None:
peak_times = dp.peaks["sample_index"] / dp.sampling_frequency
else:
peak_times = dp.times[dp.peaks["sample_index"]]
peak_times = dp.recording.sample_index_to_time(dp.peaks["sample_index"], segment_index=dp.segment_index)

peak_locs = dp.peak_locations[dp.direction]
if dp.scatter_decimate is not None:
Expand Down Expand Up @@ -344,11 +337,8 @@ def __init__(
motion.displacement
), "The number of segments in the recording must be the same as the number of segments in the motion object"

times = recording.get_times(segment_index=segment_index)

plot_data = dict(
sampling_frequency=motion_info["parameters"]["sampling_frequency"],
times=times,
segment_index=segment_index,
depth_lim=depth_lim,
motion_lim=motion_lim,
Expand Down

0 comments on commit 36251ef

Please sign in to comment.