Skip to content

Improve get_times function to slice timestamps#4512

Open
alejoe91 wants to merge 29 commits intoSpikeInterface:mainfrom
alejoe91:improve-get-times
Open

Improve get_times function to slice timestamps#4512
alejoe91 wants to merge 29 commits intoSpikeInterface:mainfrom
alejoe91:improve-get-times

Conversation

@alejoe91
Copy link
Copy Markdown
Member

This is needed for chronic data, since times can't fit in memory....

@alejoe91 alejoe91 added the core Changes to core module label Apr 14, 2026
@samuelgarcia
Copy link
Copy Markdown
Member

cool

Copy link
Copy Markdown
Member

@chrishalcrow chrishalcrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Widgets all working for me locally.

Copy link
Copy Markdown
Collaborator

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The path of slicing a time vector with args is not covered:

def test_get_times_with_time_vector_slicing():
    sampling_frequency = 10_000.0
    recording = generate_recording(durations=[1.0], num_channels=3, sampling_frequency=sampling_frequency)
    times = 1.0 + np.arange(0, 10_000) / sampling_frequency
    recording.set_times(times=times, segment_index=0, with_warning=False)

    # Full get_times should return the complete time vector
    times_full = recording.get_times(segment_index=0)
    assert np.allclose(times_full, times)

    # Sliced get_times should match slicing the full vector
    times_slice = recording.get_times(segment_index=0, start_frame=1000, end_frame=8000)
    assert np.allclose(times_slice, times[1000:8000])

    # Only start_frame provided
    times_from_start = recording.get_times(segment_index=0, start_frame=5000)
    assert np.allclose(times_from_start, times[5000:])

    # Only end_frame provided
    times_to_end = recording.get_times(segment_index=0, end_frame=3000)
    assert np.allclose(times_to_end, times[:3000])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants