|
25 | 25 | from spikeinterface.core.testing import check_sorted_arrays_equal, check_sortings_equal |
26 | 26 | from spikeinterface.core.generate import generate_sorting |
27 | 27 |
|
28 | | -from spikeinterface.core import generate_recording |
| 28 | +from spikeinterface.core import generate_recording, generate_ground_truth_recording |
29 | 29 |
|
30 | 30 |
|
31 | 31 | def test_BaseSorting(create_cache_folder): |
@@ -211,12 +211,27 @@ def test_empty_sorting(): |
211 | 211 | def test_time_slice(): |
212 | 212 |
|
213 | 213 | sampling_frequency = 10_000.0 |
214 | | - recording = generate_recording(durations=[1.0], num_channels=3, sampling_frequency=sampling_frequency) |
215 | 214 |
|
216 | | - sliced_recording_times = recording.time_slice(start_time=0.1, end_time=0.8) |
217 | | - sliced_recording_frames = recording.frame_slice(start_frame=1000, end_frame=8000) |
| 215 | + # no recording attached to sorting |
| 216 | + sorting = generate_sorting(durations=[1.0], sampling_frequency=sampling_frequency) |
218 | 217 |
|
219 | | - assert np.allclose(sliced_recording_times.get_traces(), sliced_recording_frames.get_traces()) |
| 218 | + sliced_sorting_times = sorting.time_slice(start_time=0.1, end_time=0.8) |
| 219 | + sliced_sorting_frames = sorting.frame_slice(start_frame=1000, end_frame=8000) |
| 220 | + |
| 221 | + assert np.allclose( |
| 222 | + sliced_sorting_times.to_spike_vector()["sample_index"], sliced_sorting_frames.to_spike_vector()["sample_index"] |
| 223 | + ) |
| 224 | + |
| 225 | + # with recording |
| 226 | + recording, sorting = generate_ground_truth_recording(durations=[1.0], sampling_frequency=sampling_frequency) |
| 227 | + sorting.register_recording(recording) |
| 228 | + |
| 229 | + sliced_sorting_times = sorting.time_slice(start_time=0.1, end_time=0.8) |
| 230 | + sliced_sorting_frames = sorting.frame_slice(start_frame=1000, end_frame=8000) |
| 231 | + |
| 232 | + assert np.allclose( |
| 233 | + sliced_sorting_times.to_spike_vector()["sample_index"], sliced_sorting_frames.to_spike_vector()["sample_index"] |
| 234 | + ) |
220 | 235 |
|
221 | 236 |
|
222 | 237 | if __name__ == "__main__": |
|
0 commit comments