rly / ndx-structured-behavior

An NWB extension for storing structured behavior programs and data, such as from BAABL/BEADL
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

Cannot read NWB in Jupyter notebook produced by `ndx-structured-behavior` #44

Closed weiglszonja closed 1 week ago

weiglszonja commented 2 weeks ago

I'm trying to use ndx-structured-behavior to convert Bpod data from the Constantinople lab to NWB, but I'm having strange issues when trying to read the files using Jupyter Notebook. I get a "Namespace could not be resolved" ValueError, traceback:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[4], line 7
      4 nwbfile_path = "[/Volumes/T9/Constantinople/nwbfiles/C005_RWTautowait_20190909_1456293.nwb](http://localhost:8888/Volumes/T9/Constantinople/nwbfiles/C005_RWTautowait_20190909_1456293.nwb)"
      6 io = NWBHDF5IO(nwbfile_path, "r", load_namespaces=True)
----> 7 nwbfile = io.read()

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/pynwb/__init__.py:352](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/pynwb/__init__.py#line=351), in NWBHDF5IO.read(self, **kwargs)
    349         raise TypeError("NWB version %s not supported. PyNWB supports NWB files version 2 and above." %
    350                         str(file_version_str))
    351 # read the file
--> 352 file = super().read(**kwargs)
    353 return file

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/backends/hdf5/h5tools.py:500](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/backends/hdf5/h5tools.py#line=499), in HDF5IO.read(self, **kwargs)
    497     raise UnsupportedOperation("Cannot read from file %s in mode '%s'. Please use mode 'r', 'r+', or 'a'."
    498                                % (self.source, self.__mode))
    499 try:
--> 500     return super().read(**kwargs)
    501 except UnsupportedOperation as e:
    502     if str(e) == 'Cannot build data. There are no values.':  # pragma: no cover

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/backends/io.py:60](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/backends/io.py#line=59), in HDMFIO.read(self, **kwargs)
     57 if all(len(v) == 0 for v in f_builder.values()):
     58     # TODO also check that the keys are appropriate. print a better error message
     59     raise UnsupportedOperation('Cannot build data. There are no values.')
---> 60 container = self.__manager.construct(f_builder)
     61 container.read_io = self
     62 if self.herd_path is not None:

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:286](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=285), in BuildManager.construct(self, **kwargs)
    282     result = self.__type_map.construct(builder, self, parent)
    283 else:
    284     # we are at the top of the hierarchy,
    285     # so it must be time to resolve parents
--> 286     result = self.__type_map.construct(builder, self, None)
    287     self.__resolve_parents(result)
    288 self.prebuilt(result, builder)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:814](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=813), in TypeMap.construct(self, **kwargs)
    812     raise ValueError('No ObjectMapper found for builder of type %s' % dt)
    813 else:
--> 814     return obj_mapper.construct(builder, build_manager, parent)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py:1232](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py#line=1231), in ObjectMapper.construct(self, **kwargs)
   1230 cls = manager.get_cls(builder)
   1231 # gather all subspecs
-> 1232 subspecs = self.__get_subspec_values(builder, self.spec, manager)
   1233 # get the constructor argument that each specification corresponds to
   1234 const_args = dict()

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py:1161](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py#line=1160), in ObjectMapper.__get_subspec_values(self, builder, spec, manager)
   1159                 ret[subspec] = self.__flatten(sub_builder, subspec, manager)
   1160     # now process groups and datasets
-> 1161     self.__get_sub_builders(groups, spec.groups, manager, ret)
   1162     self.__get_sub_builders(datasets, spec.datasets, manager, ret)
   1163 elif isinstance(spec, DatasetSpec):

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py:1212](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py#line=1211), in ObjectMapper.__get_sub_builders(self, sub_builders, subspecs, manager, ret)
   1209     continue
   1210 if dt is None:
   1211     # recurse
-> 1212     ret.update(self.__get_subspec_values(sub_builder, subspec, manager))
   1213 else:
   1214     ret[subspec] = manager.construct(sub_builder)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py:1161](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py#line=1160), in ObjectMapper.__get_subspec_values(self, builder, spec, manager)
   1159                 ret[subspec] = self.__flatten(sub_builder, subspec, manager)
   1160     # now process groups and datasets
-> 1161     self.__get_sub_builders(groups, spec.groups, manager, ret)
   1162     self.__get_sub_builders(datasets, spec.datasets, manager, ret)
   1163 elif isinstance(spec, DatasetSpec):

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py:1204](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py#line=1203), in ObjectMapper.__get_sub_builders(self, sub_builders, subspecs, manager, ret)
   1202     sub_builder = builder_dt.get(dt)
   1203     if sub_builder is not None:
-> 1204         sub_builder = self.__flatten(sub_builder, subspec, manager)
   1205         ret[subspec] = sub_builder
   1206 else:

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py:1217](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py#line=1216), in ObjectMapper.__flatten(self, sub_builder, subspec, manager)
   1216 def __flatten(self, sub_builder, subspec, manager):
-> 1217     tmp = [manager.construct(b) for b in sub_builder]
   1218     if len(tmp) == 1 and not subspec.is_many():
   1219         tmp = tmp[0]

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py:1217](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/objectmapper.py#line=1216), in <listcomp>(.0)
   1216 def __flatten(self, sub_builder, subspec, manager):
-> 1217     tmp = [manager.construct(b) for b in sub_builder]
   1218     if len(tmp) == 1 and not subspec.is_many():
   1219         tmp = tmp[0]

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:282](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=281), in BuildManager.construct(self, **kwargs)
    280 if parent_builder is not None:
    281     parent = self._get_proxy_builder(parent_builder)
--> 282     result = self.__type_map.construct(builder, self, parent)
    283 else:
    284     # we are at the top of the hierarchy,
    285     # so it must be time to resolve parents
    286     result = self.__type_map.construct(builder, self, None)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:809](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=808), in TypeMap.construct(self, **kwargs)
    807 if build_manager is None:
    808     build_manager = BuildManager(self)
--> 809 obj_mapper = self.get_map(builder)
    810 if obj_mapper is None:
    811     dt = builder.attributes[self.namespace_catalog.group_spec_cls.type_key()]

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:728](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=727), in TypeMap.get_map(self, **kwargs)
    726     data_type = self.get_builder_dt(obj)
    727     namespace = self.get_builder_ns(obj)
--> 728     container_cls = self.get_cls(obj)
    729 # now build the ObjectMapper class
    730 mapper = self.__mappers.get(container_cls)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:657](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=656), in TypeMap.get_cls(self, **kwargs)
    655 if namespace is None:
    656     raise ValueError("No namespace found for builder %s" % builder.path)
--> 657 return self.get_dt_container_cls(data_type, namespace)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:538](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=537), in TypeMap.get_dt_container_cls(self, **kwargs)
    536 if cls is None and autogen:  # dynamically generate a class
    537     spec = self.__ns_catalog.get_spec(namespace, data_type)
--> 538     self.__check_dependent_types(spec, namespace)
    539     parent_cls = self.__get_parent_cls(namespace, data_type, spec)
    540     attr_names = self.__default_mapper_cls.get_attr_names(spec)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:569](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=568), in TypeMap.__check_dependent_types(self, spec, namespace)
    567 if isinstance(spec, GroupSpec):
    568     for child_spec in (spec.groups + spec.datasets + spec.links):
--> 569         __check_dependent_types_helper(child_spec, namespace)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:556](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=555), in TypeMap.__check_dependent_types.<locals>.__check_dependent_types_helper(spec, namespace)
    554 if isinstance(spec, (GroupSpec, DatasetSpec)):
    555     if spec.data_type_inc is not None:
--> 556         self.get_dt_container_cls(spec.data_type_inc, namespace)  # TODO handle recursive definitions
    557     if spec.data_type_def is not None:  # nested type definition
    558         self.get_dt_container_cls(spec.data_type_def, namespace)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:541](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=540), in TypeMap.get_dt_container_cls(self, **kwargs)
    539     parent_cls = self.__get_parent_cls(namespace, data_type, spec)
    540     attr_names = self.__default_mapper_cls.get_attr_names(spec)
--> 541     cls = self.__class_generator.generate_class(data_type=data_type,
    542                                                 spec=spec,
    543                                                 parent_cls=parent_cls,
    544                                                 attr_names=attr_names,
    545                                                 post_init_method=post_init_method,
    546                                                 type_map=self)
    547     self.register_container_type(namespace, data_type, cls)
    548 return cls

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/classgenerator.py:70](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/classgenerator.py#line=69), in ClassGenerator.generate_class(self, **kwargs)
     67     for class_generator in self.__custom_generators:  # pragma: no branch
     68         # each generator can update classdict and docval_args
     69         if class_generator.apply_generator_to_field(field_spec, bases, type_map):
---> 70             class_generator.process_field_spec(classdict, docval_args, parent_cls, attr_name,
     71                                                not_inherited_fields, type_map, spec)
     72             break  # each field_spec should be processed by only one generator
     74 for class_generator in self.__custom_generators:

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/classgenerator.py:227](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/classgenerator.py#line=226), in CustomClassGenerator.process_field_spec(cls, classdict, docval_args, parent_cls, attr_name, not_inherited_fields, type_map, spec)
    217 """Add __fields__ to the classdict and update the docval args for the field spec with the given attribute name.
    218 :param classdict: The dict to update with __fields__ (or a different parent_cls._fieldsname).
    219 :param docval_args: The list of docval arguments.
   (...)
    224 :param spec: The spec for the container class to generate.
    225 """
    226 field_spec = not_inherited_fields[attr_name]
--> 227 dtype = cls._get_type(field_spec, type_map)
    228 fields_conf = {'name': attr_name,
    229                'doc': field_spec['doc']}
    230 if cls._ischild(dtype) and issubclass(parent_cls, Container) and not isinstance(field_spec, LinkSpec):

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/classgenerator.py:173](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/classgenerator.py#line=172), in CustomClassGenerator._get_type(cls, spec, type_map)
    171 if isinstance(spec.dtype, RefSpec):
    172     try:
--> 173         container_type = cls._get_container_type(spec.dtype.target_type, type_map)
    174         return container_type
    175     except TypeDoesNotExistError:
    176         # TODO what happens when the attribute ref target is not (or not yet) mapped to a container class?
    177         # returning Data, Container works as a generic fallback for now but should be more specific

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/classgenerator.py:157](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/classgenerator.py#line=156), in CustomClassGenerator._get_container_type(cls, type_name, type_map)
    152 @classmethod
    153 def _get_container_type(cls, type_name, type_map):
    154     """Search all namespaces for the container class associated with the given data type.
    155     Raises TypeDoesNotExistError if type is not found in any namespace.
    156     """
--> 157     container_type = type_map.get_dt_container_cls(type_name)
    158     if container_type is None:  # pragma: no cover
    159         # this should never happen after hdmf#322
    160         raise TypeDoesNotExistError("Type '%s' does not exist." % type_name)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py:668](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/utils.py#line=667), in docval.<locals>.dec.<locals>.func_call(*args, **kwargs)
    666 def func_call(*args, **kwargs):
    667     pargs = _check_args(args, kwargs)
--> 668     return func(args[0], **pargs)

File [~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py:532](http://localhost:8888/~/anaconda3/envs/howe-lab-to-nwb3/lib/python3.11/site-packages/hdmf/build/manager.py#line=531), in TypeMap.get_dt_container_cls(self, **kwargs)
    530             break
    531 if namespace is None:
--> 532     raise ValueError("Namespace could not be resolved.")
    534 cls = self.__get_container_cls(namespace, data_type)
    536 if cls is None and autogen:  # dynamically generate a class

ValueError: Namespace could not be resolved.

I can read the file in Python, so I'm really not sure why this is not working in Jupyter notebook. @rly I'm happy to share this file with you privately, and would really appreciate the help with this.

I'm also seeing these UserWarnings The linked table for DynamicTableRegion 'event_type' does not share an ancestor with the DynamicTableRegion , though I'm not sure they are related to the problem above:

/Users/weian/anaconda3/envs/constantinople-lab-to-nwb/lib/python3.11/site-packages/hdmf/container.py:536: UserWarning: The linked table for DynamicTableRegion 'event_type' does not share an ancestor with the DynamicTableRegion.
  child._validate_on_set_parent()
/Users/weian/anaconda3/envs/constantinople-lab-to-nwb/lib/python3.11/site-packages/hdmf/container.py:536: UserWarning: The linked table for DynamicTableRegion 'state_type' does not share an ancestor with the DynamicTableRegion.
  child._validate_on_set_parent()
/Users/weian/anaconda3/envs/constantinople-lab-to-nwb/lib/python3.11/site-packages/hdmf/container.py:536: UserWarning: The linked table for DynamicTableRegion 'action_type' does not share an ancestor with the DynamicTableRegion.
  child._validate_on_set_parent()
weiglszonja commented 2 weeks ago

@rly this error can be replicated in the example notebook as well, if you try to read the beadl_test.nwb without importing from ndx-structured-behavior at the top, then you'll see the same error (even with load_namespaces=True).

Screenshot 2024-08-28 at 11 09 41 (2)

While importing ndx-structured-behavior before reading the same file works:

Screenshot 2024-08-28 at 11 10 50 (2)
rly commented 2 weeks ago

Hi @weiglszonja , I can reproduce the error and am looking into it. Thanks

rly commented 2 weeks ago

Hi @weiglszonja , I found the bug and created a fix in HDMF. In the meantime, I think you should be able to do something like this to make the read work:

from pynwb import NWBHDF5IO

with NWBHDF5IO("src/pynwb/tests/beadl_light_chasing_task.nwb", "r") as io:
    TaskSchema = io.manager.type_map.get_dt_container_cls('TaskSchema', 'ndx-structured-behavior')
    BEADLTaskSchema = io.manager.type_map.get_dt_container_cls('BEADLTaskSchema', 'ndx-structured-behavior')

    nwbfile = io.read()
    print(nwbfile.lab_meta_data["task"].task_program.schema)
weiglszonja commented 1 week ago

Thanks for fixing this, closing this issue as this was fixed in https://github.com/hdmf-dev/hdmf/pull/1183