pynwb.validation module
Module to validate an NWB file against a namespace.
- pynwb.validation.get_cached_namespaces_to_validate(path: str | None = None, driver: str | None = None, aws_region: str | None = None, io: HDMFIO | 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.validation 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.validation.validate(io=None, namespace=None, paths=None, path=None, use_cached_namespaces=True, verbose=False, driver=None)[source]
Validate NWB file(s) against a namespace or its cached namespaces.
Note: this function checks for compliance with the NWB schema. It is recommended to use the NWBInspector for more comprehensive validation of both compliance with the schema and compliance of data with NWB best practices.
- 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. This argument will be deprecated in PyNWB 4.0. Use ‘path’ instead.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: