-
Notifications
You must be signed in to change notification settings - Fork 226
Description
From today's meeting.
Context:
Spikeinterface has two internal representation time:
cheap: sampling_frequency and t_start
expensive: time_vector
Fine control of the time
Right now t_start is a public attribute at the RecordingSegment level and it is harder to access than maybe it needs be. We need a more comfortable setter. Plus, the setter should handle the fact that the cheap and expensive representations are mutually exclusive.
- A proposal implementation that overloads the current
set_timesis in Exposet_startinBaseRecording#3117. - @alejoe91 proposal,
set_times_infoas a setter that handles the above. I think this is a good idea because it reflects the other method we haveget_times_kwargsand it is a nice symmetry from getters to setters. I am +1 on that
End user API
My proposal for how end users should interact with time:
- set_times always sets the the time vector
set_timesand this is the final source of truth after setting. - I propose adding a second function
set_starting_timeorshift_starting_time(do not know what's better) that is agnostic to the internal implementation. If there is a time vector it shifts sotime_vector[0] = start_timeand if there is at_startthen it just shifts or changes that values.
Setting the correct times and shifting the current times are natural concepts that don't rely on internal implementation details and the functions above don't leak internal details to users.
Some extra notes:
- This enables the workflow of shifting or doing whatever you want with the
time_vectorbefore setting it. So it does not get in the way of @JoeZiminski workflow (set_timesis stillset_times). - @alejoe91 mention that you could use the workflow of
get_times(), modify the vector and finally useset_timesagain. I think this is good and very close to what I want but has the drawback that you always end with the expensive representation internally which I think we can avoid. Plus, right now this workflow throws a warning - @samuelgarcia mentioned that the same mechanism should be implemented for the sorting. Maybe using the registered recording method is an overkill.
In brief, I think we should create an API that does not leak the internal implementation details of how spikeinterface represents time. We might decide down the line to change the internal representation of time and this should not affect the API. Thus, I think those functions and their docstrings should not make references or rely on understanding of t_start and time_vector.