pynwb.validate module

Command line tool to Validate an NWB file against a namespace.

pynwb.validate.get_cached_namespaces_to_validate(path: str, driver: str | None = None, aws_region: str | None = None) Tuple[List[str], BuildManager, Dict[str, str]][source]

Determine the most specific namespace(s) that are cached in the given NWBFile that can be used for validation.

Example

The following example illustrates how we can use this function to validate against namespaces cached in a file. This is useful, e.g., when a file was created using an extension

from pynwb import validate
from pynwb.validate import get_cached_namespaces_to_validate
path = "my_nwb_file.nwb"
validate_namespaces, manager, cached_namespaces = get_cached_namespaces_to_validate(path)
with NWBHDF5IO(path, "r", manager=manager) as reader:
    errors = []
    for ns in validate_namespaces:
        errors += validate(io=reader, namespace=ns)
Parameters:

path – Path for the NWB file

Returns:

Tuple with: - List of strings with the most specific namespace(s) to use for validation. - BuildManager object for opening the file for validation - Dict with the full result from NWBHDF5IO.load_namespaces

pynwb.validate.validate(io=None, namespace=None, paths=None, use_cached_namespaces=True, verbose=False, driver=None)[source]

Validate NWB file(s) against a namespace or its cached namespaces.

NOTE: If an io object is provided and no namespace name is specified, then the file will be validated against the core namespace, even if use_cached_namespaces is True.

Parameters:
  • io (HDMFIO) – An open IO to an NWB file.

  • namespace (str) – A specific namespace to validate against.

  • paths (list) – List of NWB file paths.

  • use_cached_namespaces (bool) – Whether to use namespaces cached within the file for validation.

  • verbose (bool) – Whether or not to print messages to stdout.

  • driver (str) – Driver for h5py to use when opening the HDF5 file.

Returns:

Validation errors in the file.

Return type:

list or list, bool

pynwb.validate.validate_cli()[source]

CLI wrapper around pynwb.validate.