Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: DynamicTable.to_dataframe doesn't resolve TimeSeriesReference #1776

Closed
3 tasks done
sneakers-the-rat opened this issue Sep 23, 2023 · 3 comments
Closed
3 tasks done

Comments

@sneakers-the-rat
Copy link
Contributor

sneakers-the-rat commented Sep 23, 2023

What happened?

Using an allen institute dataset as testing data (specifically https://dandiarchive.org/dandiset/000021/ , sub-738651046_ses-760693773.nwb ) trying to get an expected result for dataframes produced from dynamic tables, and it looks like it is left unresolved as a TimeSeriesReference object.

There seems to be some mismatch in version of model used here, because this dataset is using 2.2.2 and TimeSeriesReferenceVectorData wasn't present in the schema then as far as I can tell. Not sure if this is expected behavior or if there's some other call I need to make to resolve references. Still trying to figure out how all these multi-index objects are supposed to work so this could be nothing idk

Steps to Reproduce

# download the above dataset and say it's named data.nwb

from pynwb import NWBHDF5IO

with open('data.nwb', 'r', load_namespaces=True) as io:
    data = io.read()
    df = data.intervals['drifting_gratings_presentations'].to_dataframe()

and then

>>> df['timeseries'][0][0]
TimeSeriesReference(idx_start=3798, count=1, timeseries=timestamps pynwb.base.TimeSeries at 0x5319380240
Fields:
  comments: no comments
  conversion: 1.0
  description: no description
  interval: 1
  offset: 0.0
  resolution: -1.0
  timestamps_unit: seconds
  unit: s
)


### Traceback

```python
(no traceback)

Operating System

macOS

Python Executable

Python

Python Version

3.11

Package Versions

pynwb: 2.5.0
hdmf: 3.9.0
h5py: 3.9.0

Code of Conduct

@oruebel
Copy link
Contributor

oruebel commented Sep 24, 2023

While TimeSeriesReferenceVectorData was added as a type later, the schema existed. That is, we just gave the type a name so that it can be reused, but the structure of the data itself did not change. To support consistent interaction across the data, PyNWB therefore is able to use the same updated data structures to represent the data to the user on read for this data. I.e., the behavior you are describing is expected. TimeSeriesReference is the resolution of the reference as it holds the TimeSeries that is being pointed to as well as the information about the indices to be accessed. TimeSeriesReference provides convenience properties that allows direct access to the selected data subset via its .data and .timestamps properties. See here for details: https://pynwb.readthedocs.io/en/stable/tutorials/general/plot_timeintervals.html#accessing-referenced-timeseries

@oruebel
Copy link
Contributor

oruebel commented Sep 24, 2023

Closing this issue for now. Please reopen if my response does not sufficiently resolve the issue.

@oruebel oruebel closed this as completed Sep 24, 2023
@sneakers-the-rat
Copy link
Contributor Author

alright! if that's expected behavior then yes close the issue! I assumed (incorrectly) that the reference should just be replaced with the data that is referenced, but if the references should remain then great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants