pynwb icon indicating copy to clipboard operation
pynwb copied to clipboard

Cannot add epochs to file which already contains epochs

Open luiztauffer opened this issue 4 years ago • 2 comments

1) Bug

Cannot add epochs to file which already contains epochs.

Steps to Reproduce

from pynwb import NWBFile, NWBHDF5IO
from datetime import datetime

# Make data source file
nwb = NWBFile('aa','aa', datetime.now().astimezone())
with NWBHDF5IO('test.nwb', 'w') as io:
    nwb.add_epoch(start_time=3., stop_time=5., tags='name1')
    io.write(nwb)
    
# Open and try to add new epoch
with NWBHDF5IO('test.nwb', 'r+') as io:
    nwb = io.read()
    nwb.add_epoch(start_time=44., stop_time=55., tags='name3')
    io.write(nwb)

This raises the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-e5b873156dff> in <module>
     11 with pynwb.NWBHDF5IO('test.nwb', 'r+') as io:
     12     nwb = io.read()
---> 13     nwb.add_epoch(start_time=44., stop_time=55., tags='name3')
     14     io.write(nwb)

~\Anaconda3\envs\spike_extract\lib\site-packages\hdmf\utils.py in func_call(*args, **kwargs)
    434                         raise_from(ExceptionType(msg), None)
    435 
--> 436                 return func(self, **parsed['args'])
    437         else:
    438             def func_call(*args, **kwargs):

~\Anaconda3\envs\spike_extract\lib\site-packages\pynwb\file.py in add_epoch(self, **kwargs)
    440         if kwargs['tags'] is not None:
    441             self.epoch_tags.update(kwargs['tags'])
--> 442         call_docval_func(self.epochs.add_interval, kwargs)
    443 
    444     def __check_electrodes(self):

~\Anaconda3\envs\spike_extract\lib\site-packages\hdmf\utils.py in call_docval_func(func, kwargs)
    323 def call_docval_func(func, kwargs):
    324     fargs, fkwargs = fmt_docval_args(func, kwargs)
--> 325     return func(*fargs, **fkwargs)
    326 
    327 

~\Anaconda3\envs\spike_extract\lib\site-packages\hdmf\utils.py in func_call(*args, **kwargs)
    434                         raise_from(ExceptionType(msg), None)
    435 
--> 436                 return func(self, **parsed['args'])
    437         else:
    438             def func_call(*args, **kwargs):

~\Anaconda3\envs\spike_extract\lib\site-packages\pynwb\epoch.py in add_interval(self, **kwargs)
     61             timeseries = tmp
     62             rkwargs['timeseries'] = timeseries
---> 63         return super(TimeIntervals, self).add_row(**rkwargs)
     64 
     65     def __calculate_idx_count(self, start_time, stop_time, ts_data):

~\Anaconda3\envs\spike_extract\lib\site-packages\hdmf\utils.py in func_call(*args, **kwargs)
    434                         raise_from(ExceptionType(msg), None)
    435 
--> 436                 return func(self, **parsed['args'])
    437         else:
    438             def func_call(*args, **kwargs):

~\Anaconda3\envs\spike_extract\lib\site-packages\pynwb\core.py in add_row(self, **kwargs)
   1157         if row_id is None:
   1158             row_id = len(self)
-> 1159         self.id.data.append(row_id)
   1160 
   1161         for colname, colnum in self.__colids.items():

AttributeError: 'Dataset' object has no attribute 'append'

Checklist

  • [x] Have you ensured the feature or change was not already reported ?
  • [x] Have you included a brief and descriptive title?
  • [x] Have you included a clear description of the problem you are trying to solve?
  • [x] Have you included a minimal code snippet that reproduces the issue you are encountering?
  • [x] Have you checked our Contributing document?

luiztauffer avatar Sep 09 '19 07:09 luiztauffer