-
Notifications
You must be signed in to change notification settings - Fork 88
Add methods to find objects of a given neurodata type / pynwb class #1737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -349,6 +349,32 @@ def export(self, **kwargs): | |
| kwargs['container'] = nwbfile | ||
| super().export(**kwargs) | ||
|
|
||
| @docval({'name': 'neurodata_type', 'type': str, 'doc': 'The neurodata type to search for.'}, | ||
| {'name': 'namespace', 'type': str, 'doc': 'The namespace of the neurodata type to search for.'},) | ||
| def get_neurodata_type_objs(self, neurodata_type: str, namespace: str): | ||
| """Return all PyNWB objects in the file that have a neurodata type from a namespace. | ||
|
|
||
| This works regardless of whether the extension was imported earlier in the python execution. | ||
|
|
||
| All objects that are instances of the class associated with the given neurodata_type in the | ||
| given namespace will be returned. This includes objects that are instances of a subclass. | ||
|
|
||
| For example, if an extension defines a new neurodata type OnePhotonSeries that extends | ||
| ImageSeries, then `get_neurodata_type_objects_in_file(io, "ImageSeries", "core")` will | ||
| include all OnePhotonSeries objects. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| from pynwb import NWBHDF5IO | ||
| with NWBHDF5IO(filepath, mode="r", load_namespaces=True) as io: | ||
| obj_list = io.get_neurodata_type_objs("Subject", "core") | ||
|
|
||
| """ | ||
| pynwb_cls = self.manager.type_map.get_dt_container_cls(neurodata_type, namespace) | ||
|
|
||
| read_nwbfile = self.read() | ||
| return read_nwbfile.find_all_of_class(pynwb_cls) | ||
|
||
|
|
||
|
|
||
| from . import io as __io # noqa: F401,E402 | ||
| from .core import NWBContainer, NWBData # noqa: F401,E402 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.