catalystneuro / ecogVIS

Time series visualizer and data processing tools for Electrocorticography (ECoG) signals stored in NWB files, for Python.
BSD 3-Clause "New" or "Revised" License
23 stars 18 forks source link

Unable to create link when trying to save preprocessed data? #25

Closed jessierliu closed 5 years ago

jessierliu commented 5 years ago

In trying to preprocess a raw file, I'm getting this error when it tries to write to the nwb file. I've done processing on this block before (I made a copy of the original raw NWB file). Do you know what may be causing this? It was able to do downsampling, CAR, and notch filtering before this error came up.

RuntimeError                              Traceback (most recent call last)
~/ChangLab/projects/ecogVIS/ecogvis/functions/subDialogs.py in run(self)
    434                         mode=self.mode,
    435                         config=self.config,
--> 436                         new_file=self.new_fname)
    437 
    438 

~/ChangLab/projects/ecogVIS/ecogvis/signal_processing/processing_data.py in processing_data(path, subject, blocks, mode, config, new_file)
     26 
     27         if mode=='preprocess':
---> 28             preprocess_raw_data(block_path, config=config)
     29         elif mode=='decomposition':
     30             spectral_decomposition(block_path, bands_vals=config)

~/ChangLab/projects/ecogVIS/ecogvis/signal_processing/processing_data.py in preprocess_raw_data(block_path, config)
    298 
    299             # Write LFP to NWB file
--> 300             io.write(nwb)
    301             print('LFP saved in '+block_path)
    302 

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/utils.py in func_call(*args, **kwargs)
    386                         raise_from(ExceptionType(msg), None)
    387 
--> 388                 return func(self, **parsed['args'])
    389         else:
    390             def func_call(*args, **kwargs):

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/backends/hdf5/h5tools.py in write(self, **kwargs)
    217 
    218         cache_spec = popargs('cache_spec', kwargs)
--> 219         call_docval_func(super(HDF5IO, self).write, kwargs)
    220         if cache_spec:
    221             ref = self.__file.attrs.get(SPEC_LOC_ATTR)

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/utils.py in call_docval_func(func, kwargs)
    279 def call_docval_func(func, kwargs):
    280     fargs, fkwargs = fmt_docval_args(func, kwargs)
--> 281     return func(*fargs, **fkwargs)
    282 
    283 

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/utils.py in func_call(*args, **kwargs)
    386                         raise_from(ExceptionType(msg), None)
    387 
--> 388                 return func(self, **parsed['args'])
    389         else:
    390             def func_call(*args, **kwargs):

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/backends/io.py in write(self, **kwargs)
     40         container = popargs('container', kwargs)
     41         f_builder = self.__manager.build(container, source=self.__source)
---> 42         self.write_builder(f_builder, **kwargs)
     43 
     44     @abstractmethod

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/utils.py in func_call(*args, **kwargs)
    386                         raise_from(ExceptionType(msg), None)
    387 
--> 388                 return func(self, **parsed['args'])
    389         else:
    390             def func_call(*args, **kwargs):

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/backends/hdf5/h5tools.py in write_builder(self, **kwargs)
    444         f_builder, link_data = getargs('builder', 'link_data', kwargs)
    445         for name, gbldr in f_builder.groups.items():
--> 446             self.write_group(self.__file, gbldr)
    447         for name, dbldr in f_builder.datasets.items():
    448             self.write_dataset(self.__file, dbldr, link_data)

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/utils.py in func_call(*args, **kwargs)
    386                         raise_from(ExceptionType(msg), None)
    387 
--> 388                 return func(self, **parsed['args'])
    389         else:
    390             def func_call(*args, **kwargs):

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/backends/hdf5/h5tools.py in write_group(self, **kwargs)
    597         if links:
    598             for link_name, sub_builder in links.items():
--> 599                 self.write_link(group, sub_builder)
    600         attributes = builder.attributes
    601         self.set_attributes(group, attributes)

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/utils.py in func_call(*args, **kwargs)
    386                         raise_from(ExceptionType(msg), None)
    387 
--> 388                 return func(self, **parsed['args'])
    389         else:
    390             def func_call(*args, **kwargs):

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/hdmf/backends/hdf5/h5tools.py in write_link(self, **kwargs)
    634             msg = 'cannot create external link to %s' % path
    635             raise ValueError(msg)
--> 636         parent[name] = link_obj
    637         builder.written = True
    638         return link_obj

/anaconda3/envs/ecog_vis/lib/python3.7/site-packages/h5py/_hl/group.py in __setitem__(self, name, obj)
    390             with phil:
    391                 self.id.links.create_external(name, fn, self._e(obj.path),
--> 392                                               lcpl=lcpl, lapl=self._lapl)
    393 
    394     @with_phil

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5l.pyx in h5py.h5l.LinkProxy.create_external()

RuntimeError: Unable to create link (name already exists)
jessierliu commented 5 years ago

This same error seems to come up with any action that tries to write to the NWB file (calculating periodogram, getting high gamma, etc)

luiztauffer commented 5 years ago

Yes, there seems to be a problem with external links currently at pynwb. Could you try the same processing with block files that are not linked to one subject file?

jessierliu commented 5 years ago

Oh okay, it works fine when it's not linked to an external subject file! Do you know if this is something that will get fixed at some point?

luiztauffer commented 5 years ago

Hopefully soon! @bendichter is on top of that