pynwb icon indicating copy to clipboard operation
pynwb copied to clipboard

method for TimeSeries: get_values

Open bendichter opened this issue 7 years ago • 3 comments

I'd like a function for TimeSeries that gets me the data values that correspond to a specific start and end time. I'd like this to work whether the time is stored as starting_time and rate or as timestamps. Does this already exist?

bendichter avatar Jun 22 '18 21:06 bendichter

No, it doesn’t exist yet, but we’ve done a little work on internal infrastructure needed for doing this.

ajtritt avatar Jun 22 '18 21:06 ajtritt

In addition to what Andrew mentioned. As a bit of a side-project, I started experimenting with how this might look in the special case of a TimeSeries on a branch but it's experimental at this point and I think the final solution will likely look different and will use some more of the general infrastructure that Andrew mentioned. I.e., I would not recommend to rely on what I'm describing next as it is experimental and will very likely change. I just wanted to mention it in case you need something quick-and-dirty for some time-critical task.

If you want, you can have a look at the class TimeSeriesHelper on the branch enh/select_timeseries. The class just wraps an existing TimeSeries to provide additional functions. In particular, have a look at the function subset_series which can take a time_range and/or an index_select (e.g., numpy.s_[:,1:10]) to select data from the TimeSeries and creates a new TimeSeries for the corresponding data subset. I have not tested it extensively, but it should in principle work with any TimeSeries, i.e., subset_series should create a new series of the same derived type as the input TimeSeries and all fields should be copied over. Here is a simple test case which shows how it should work. The TimeSeriesHelper class also has a number of other experimental functions to deal with the timestamps issued, e.g., to convert between stamps and index or to convert the timestamps (which are relative to the session_start_time) into absolute timestamps. There are also some functions to convert a TimeSeries to an xarray or pandas series

I don't want to merge this stuff back right now because a) it introduces a bunch of heavy dependencies (xarray, pandas), b) its not well tested, c) the interface is not really how it should look in PyNWB (it's really just me playing with it).

oruebel avatar Jun 22 '18 22:06 oruebel

analogous to https://github.com/NeurodataWithoutBorders/matnwb/pull/52

bendichter avatar Jul 30 '18 22:07 bendichter