Open luiztauffer opened 5 years ago
Here is a demonstration of reshaping a dataset that has already been written. Note that maxshape
must be set to (None,)
for this to work.
from datetime import datetime
from dateutil.tz import tzlocal
from pynwb import NWBFile, NWBHDF5IO
from pynwb import TimeSeries
from hdmf.backends.hdf5.h5tools import H5DataIO
start_time = datetime(2017, 4, 3, 11, tzinfo=tzlocal())
nwbfile = NWBFile(session_description='demonstrate NWBFile basics',
identifier='NWB123',
session_start_time=start_time)
data = list(range(100, 200, 10))
timestamps = list(range(10))
test_ts = TimeSeries(name='test_timeseries', data=H5DataIO(data, maxshape=(None,)), unit='m', timestamps=timestamps)
nwbfile.add_acquisition(test_ts)
with NWBHDF5IO('example_file_path.nwb', 'w') as io:
io.write(nwbfile)
with NWBHDF5IO('example_file_path.nwb', 'a') as io:
nwb = io.read()
nwb.acquisition['test_timeseries'].data.resize((12,))
nwb.acquisition['test_timeseries'].data[-2:] = [-1, -2]
print(nwb.acquisition['test_timeseries'].data[:])
Feature Request
According to the documentation, the pynwb.epoch.TimeIntervals class accepts several data formats (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or HDMFDataset), but the methods to add new intervals only works for lists.
Problem/Use Case
In an instance with invalid intervals values initiated from an HDF5 file, the methods for adding new intervals won’t work. I tried it with 3 different methods:
All raise the AttributeError: 'Dataset' object has no attribute 'append', from different locations inside the ‘core.py’ module.
Here's a reproducible example:
This will raise the following
It seems to me we should be testing the data format before the append() method, in different places of core.py.
Checklist