@@ -200,18 +200,11 @@ def __init__(
200200 if peak_amplitudes is not None :
201201 peak_amplitudes = peak_amplitudes [peak_mask ]
202202
203- if recording is not None :
204- sampling_frequency = recording .sampling_frequency
205- times = recording .get_times (segment_index = segment_index )
206- else :
207- times = None
208-
209203 plot_data = dict (
210204 peaks = peaks ,
211205 peak_locations = peak_locations ,
212206 peak_amplitudes = peak_amplitudes ,
213207 direction = direction ,
214- times = times ,
215208 sampling_frequency = sampling_frequency ,
216209 segment_index = segment_index ,
217210 depth_lim = depth_lim ,
@@ -238,10 +231,10 @@ def plot_matplotlib(self, data_plot, **backend_kwargs):
238231
239232 self .figure , self .axes , self .ax = make_mpl_figure (** backend_kwargs )
240233
241- if dp .times is None :
234+ if dp .recording is None :
242235 peak_times = dp .peaks ["sample_index" ] / dp .sampling_frequency
243236 else :
244- peak_times = dp .times [ dp .peaks ["sample_index" ]]
237+ peak_times = dp .recording . sample_index_to_time ( dp .peaks ["sample_index" ], segment_index = dp . segment_index )
245238
246239 peak_locs = dp .peak_locations [dp .direction ]
247240 if dp .scatter_decimate is not None :
@@ -340,12 +333,12 @@ def __init__(
340333 raise ValueError (
341334 "plot drift map : the Motion object is multi-segment you must provide segment_index=XX"
342335 )
343-
344- times = recording .get_times () if recording is not None else None
336+ assert recording .get_num_segments () == len (
337+ motion .displacement
338+ ), "The number of segments in the recording must be the same as the number of segments in the motion object"
345339
346340 plot_data = dict (
347341 sampling_frequency = motion_info ["parameters" ]["sampling_frequency" ],
348- times = times ,
349342 segment_index = segment_index ,
350343 depth_lim = depth_lim ,
351344 motion_lim = motion_lim ,
0 commit comments