Skip to content

Commit

Permalink
Merge pull request #3414 from alejoe91/fix-motion-plot
Browse files Browse the repository at this point in the history
Fix plot motion for multi-segment
  • Loading branch information
alejoe91 authored Sep 16, 2024
2 parents b4dceac + 36251ef commit a36615a
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 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 @@ -340,12 +333,12 @@ def __init__(
raise ValueError(
"plot drift map : the Motion object is multi-segment you must provide segment_index=XX"
)

times = recording.get_times() if recording is not None else None
assert recording.get_num_segments() == len(
motion.displacement
), "The number of segments in the recording must be the same as the number of segments in the motion object"

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 a36615a

Please sign in to comment.