Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/pynwb/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,30 @@ def objects(self):
self.all_children()
return self.__obj

@docval({'name': 'neurodata_types', 'type': (type, str),
'doc': ('The PyNWB container class to search for instances of, or the string with the name of '
'the neurodata_type')},)
def find_all(self, neurodata_type):
"""Return all PyNWB objects in the file that are instances of the neurodata_type class.

This includes objects that are instances of a subclass of the class. A string with the name of the
neurodata_type can also be passed in.

.. code-block:: python

from pynwb import ImageSeries
obj_list = find_all(nwbfile, ImageSeries)
obj_list = find_all(nwbfile, "EcephysSpecimen") # EcephysSpecimen is defined in a loaded extension

"""
if isinstance(neurodata_type, str):
pynwb_cls = self.io.manager.type_map.get_dt_container_cls(neurodata_type)
else:
pynwb_cls = neurodata_type

ret = [obj for obj in self.objects.values() if isinstance(obj, pynwb_cls)]
return ret

@property
def modules(self):
warn("NWBFile.modules has been replaced by NWBFile.processing.", DeprecationWarning)
Expand Down