@@ -227,9 +227,9 @@ def __init__(self, **kwargs):
227
227
# For more information on writing NWB files, see :ref:`basic_writing`.
228
228
229
229
####################
230
- # By default, PyNWB does not use the namespaces cached in a file--you must explicitly specify this.
231
- # This behavior is enabled by the *load_namespaces* argument to the :py:class:`~pynwb.NWBHDF5IO`
232
- # constructor.
230
+ # By default, PyNWB does not use the namespaces cached in a file--you must
231
+ # explicitly specify this. This behavior is enabled by the *load_namespaces*
232
+ # argument to the :py:class:`~pynwb.NWBHDF5IO` constructor.
233
233
234
234
io = NWBHDF5IO ('cache_spec_example.nwb' , mode = 'r' , load_namespaces = True )
235
235
nwbfile = io .read ()
@@ -238,9 +238,11 @@ def __init__(self, **kwargs):
238
238
# .. _MultiContainerInterface:
239
239
# Creating and using a custom MultiContainerInterface
240
240
# -----------------------------------------------------
241
- # It is sometimes the case that we need a group to hold zero-or-more or one-or-more of the same object.
242
- # Here we show how to create an extension that defines a group (`PotatoSack`) that holds multiple objects (`Pototo`es)
243
- # and then how to use the new data types. First, we use `pynwb` to define the new data types.
241
+ # It is sometimes the case that we need a group to hold zero-or-more or
242
+ # one-or-more of the same object. Here we show how to create an extension that
243
+ # defines a group (`PotatoSack`) that holds multiple objects (`Pototo` es) and
244
+ # then how to use the new data types. First, we use `pynwb` to define the new
245
+ # data types.
244
246
245
247
from pynwb .spec import NWBNamespaceBuilder , NWBGroupSpec , NWBAttributeSpec
246
248
@@ -283,7 +285,8 @@ def __init__(self, **kwargs):
283
285
ns_builder .export (ns_path )
284
286
285
287
####################
286
- # Then create Container classes registered to the new data types (this is generally done in a different file)
288
+ # Then create Container classes registered to the new data types (this is
289
+ # generally done in a different file)
287
290
288
291
from pynwb import register_class , load_namespaces
289
292
from pynwb .file import MultiContainerInterface , NWBContainer
@@ -337,3 +340,14 @@ class PotatoSack(MultiContainerInterface):
337
340
338
341
with NWBHDF5IO ('test_multicontainerinterface.nwb' , 'w' ) as io :
339
342
io .write (nwbfile )
343
+
344
+ ####################
345
+ # This is how you read the NWB file (again, this would often be done in a
346
+ # different file).
347
+
348
+ load_namespaces (ns_path )
349
+ # from xxx import PotatoSack, Potato
350
+ io = NWBHDF5IO ('test_multicontainerinterface.nwb' , 'r' )
351
+ nwb = io .read ()
352
+ print (nwb .get_processing_module ()['potato_sack' ].get_potato ().weight )
353
+ io .close ()
0 commit comments