### Install NWBInspector using pip Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/installation.html Use this command to install the NWBInspector package in a Python v3.10+ environment. ```bash pip install nwbinspector ``` -------------------------------- ### Install NWBInspector using Conda Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/installation.html Install NWBInspector from the conda-forge release. This is recommended for MatNWB users. ```bash conda install -c conda-forge nwbinspector ``` -------------------------------- ### Install DANDI Streaming Dependencies Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Install additional dependencies required for streaming NWB files directly from the DANDI archive using `pip`. ```bash pip install "nwbinspector[dandi]" ``` -------------------------------- ### Example Check Implementation Source: https://nwbinspector.readthedocs.io/en/dev/contributing_checks.html Demonstrates a well-implemented check function for NWB files, ensuring experimenter information is present. This check is registered with specific importance and targets NWBFile neurodata types. ```python import typing as tp from pynwb.file import NWBFile from ..inspector import InspectorMessage, Importance from ..utils import register_check @register_check( importance=Importance.BEST_PRACTICE_SUGGESTION, neurodata_type=NWBFile ) def check_experimenter(nwbfile: NWBFile) -> tp.Optional[InspectorMessage]: """Check if an experimenter has been added for the session.""" if not nwbfile.experimenter: return InspectorMessage( message="Experimenter is missing. Add experimenter information to improve metadata completeness." ) return None ``` -------------------------------- ### Unit Tests for a New NWBInspector Check Source: https://nwbinspector.readthedocs.io/en/dev/contributing_checks.html Example unit tests for a new check, demonstrating how to test both passing and failing scenarios. The `assert` statements verify that the check returns `None` for valid inputs and an `InspectorMessage` for invalid inputs. ```python from src.nwbinspector.checks._my_feature import check_my_feature from src.nwbinspector.testing import make_minimal_nwbfile from nwbinspector.core import InspectorMessage def test_my_feature_pass(): # Test case where check should pass assert check_my_feature(nwbfile=NWBFile(...)) is None def test_my_feature_fail(): # Test case where check should fail assert check_my_feature(nwbfile=make_minimal_nwbfile()) == InspectorMessage( message="Expected message" ) ``` -------------------------------- ### is_module_installed() Source: https://nwbinspector.readthedocs.io/en/dev/api/utils.html Checks if a given module is installed on the system. ```APIDOC ## is_module_installed() ### Description Check if the given module is installed on the system. Used for lazy imports. ### Method N/A (Function) ### Parameters #### Input Parameters - **module_name** (str) - The name of the module to check. ### Returns - bool: True if the module is installed, False otherwise. ``` -------------------------------- ### Linking Check to Best Practice Documentation (Standard) Source: https://nwbinspector.readthedocs.io/en/dev/contributing_checks.html This example shows how to link a check function to its corresponding best practice documentation using a standard reStructuredText format. The `:py:meth:` directive is used to create a link to the check function's API documentation. ```rst .. _best_practice_my_feature: My Feature ~~~~~~~~~~ Description of the best practice. Check function: :py:meth:`~nwbinspector.checks._tables.check_my_feature` ``` -------------------------------- ### Template for a New NWBInspector Check Source: https://nwbinspector.readthedocs.io/en/dev/contributing_checks.html This is a template for creating a new check function. It includes the necessary decorator, type hints, and return structure for a valid check. Ensure the function name starts with 'check_' and the message is clear and actionable. ```python import { Importance, InspectorMessage, register_check } from "@nwbinspector/core" import { NWBFile } from "@nwbinspector/types" import { Optional } from "@nwbinspector/utils" @register_check( importance=Importance.BEST_PRACTICE_SUGGESTION, # Choose appropriate level neurodata_type=NWBFile # Most general applicable type ) def check_my_feature(nwbfile: NWBFile) -> Optional[InspectorMessage]: """One-line description of what this check validates.""" if problem_detected: return InspectorMessage( message="Clear description of the issue and how to fix it." ) return None ``` -------------------------------- ### Linking Check to Best Practice Documentation (Custom Ref) Source: https://nwbinspector.readthedocs.io/en/dev/contributing_checks.html This example demonstrates how to link a check function to a specific best practice section using a custom reference label within the docstring. This is useful when the best practice section label does not automatically match the check function name. ```python def check_my_feature(nwbfile: NWBFile) -> Optional[InspectorMessage]: """ One-line description of what this check validates. Best Practice: :ref:`best_practice_my_feature_unique_label` """ ``` -------------------------------- ### Object Reference Data Type for Links Source: https://nwbinspector.readthedocs.io/en/dev/best_practices/extensions.html Use a dataset with an object reference data type to store collections of links to other objects. This example shows a dtype for a dataset of links to TimeSeries. ```yaml dtype: target_type: TimeSeries reftype: object ``` -------------------------------- ### Custom JSONEncoder for NWBInspector Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Subclass JSONEncoder to handle objects that cannot be serialized by default. This example shows how to support arbitrary iterators by converting them to lists. ```python def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o) ``` -------------------------------- ### Inspect a Dandiset by ID Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_library.html Use `inspect_dandiset` to stream and inspect data directly from the DANDI Archive using its ID. This is efficient for large datasets that are impractical to download fully. Ensure `nwbinspector[dandi]` is installed. ```python from nwbinspector import inspect_dandiset dandiset_id = "000004" messages = list(inspect_dandiset(dandiset_id=dandiset_id)) ``` ```python from nwbinspector import inspect_dandiset dandiset_id = "000004" dandiset_version = "0.220126.1851" messages = list(inspect_dandiset(dandiset_id=dandiset_id, dandiset_version=dandiset_version)) ``` -------------------------------- ### View All CLI Options Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Call the `nwbinspector --help` command to view all available options and arguments for the CLI. ```bash nwbinspector --help ``` -------------------------------- ### Loading Configuration Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Use `load_config` to load configuration settings, either from a specified file path or by using internal keywords like 'dandi'. ```python load_config(_filepath_or_keyword : str | Path_) → dict Load a config dictionary either via keyword search of the internal configs, or an explicit filepath. ``` -------------------------------- ### check_time_intervals_stop_after_start Source: https://nwbinspector.readthedocs.io/en/dev/api/checks.html Checks that all stop times on a TimeInterval object occur after their corresponding start times. This is crucial for valid time interval data. ```APIDOC ## check_time_intervals_stop_after_start ### Description Check that all stop times on a TimeInterval object occur after their corresponding start times. Best Practice: Timing Columns ### Method N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **_time_intervals** (TimeIntervals_) - The TimeIntervals object to check. * **_nelems** (int | None, optional) - Only check the first {nelems} elements. This is useful in case there columns are very long so you don’t need to load the entire array into memory. Use None to load the entire arrays. Defaults to 200. ``` -------------------------------- ### get_nwbfiles_from_path Source: https://nwbinspector.readthedocs.io/en/dev/api/utils.html Given a path, return a list of NWB files. A directory whose name ends with `.nwb.zarr` is treated as a single NWB file (a Zarr store), not as a folder to recurse into. Other directories are recursed for `*.nwb*` paths. ```APIDOC ## get_nwbfiles_from_path ### Description Given a path, return a list of NWB files. A directory whose name ends with `.nwb.zarr` is treated as a single NWB file (a Zarr store), not as a folder to recurse into. Other directories are recursed for `*.nwb*` paths. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Method N/A (Python function) ### Endpoint N/A (Python function) ### Parameters * **path** (_PathType_) – Path to search for NWB files. ### Response #### Success Response **list[Path]** – A list of paths to NWB files. Return type: list[Path] ``` -------------------------------- ### ImageSeries Checks Source: https://nwbinspector.readthedocs.io/en/dev/api/register_check.html Functions for validating ImageSeries data, including external file validity, relative paths, data size, and starting frames. ```APIDOC ## ImageSeries Checks ### Description Functions for validating ImageSeries data, including external file validity, relative paths, data size, and starting frames. ### Functions - `check_image_series_external_file_valid()` - `check_image_series_external_file_relative()` - `check_image_series_data_size()` - `check_image_series_starting_frame_without_external_file() ``` -------------------------------- ### check_time_series_duration Source: https://nwbinspector.readthedocs.io/en/dev/api/checks.html Checks if the duration of a TimeSeries exceeds a specified threshold, calculated from timestamps or start time, rate, and data length. Defaults to 1 year. ```APIDOC ## check_time_series_duration ### Description Check if the TimeSeries duration is longer than the specified threshold. The default threshold is 1 year (31,557,600 seconds = 365.25 days). Duration is calculated from either timestamps or starting_time + rate + data length. Best Practice: Units of Measurement ### Method N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **_time_series** (TimeSeries_) - Required - The TimeSeries object to check. * **_duration_threshold** (float) - Optional - Defaults to 31557600.0. The duration threshold in seconds. ### Response #### Success Response - **InspectorMessage | None** - Returns an InspectorMessage if the duration exceeds the threshold, otherwise None. ``` -------------------------------- ### Create and Push Git Tag for Release Source: https://nwbinspector.readthedocs.io/en/dev/developer_guide.html Create a signed Git tag for a new release and push it to GitHub. This is a step in the release process to mark a specific version. ```bash release=X.Y.Z git tag ${release} --sign -m "nwbinspector ${release}" git push --tags ``` -------------------------------- ### inspect_all Source: https://nwbinspector.readthedocs.io/en/dev/api/utils.html Inspects a local NWBFile or a folder of NWBFiles and returns suggestions for improvements according to best practices. It can recursively scan all NWBFiles present in a directory. ```APIDOC ## inspect_all ### Description Inspect a local NWBFile or folder of NWBFiles and return suggestions for improvements according to best practices. ### Method N/A (Function Signature) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **path** (_PathType_) – File path to an NWBFile, folder path to iterate over recursively and scan all NWBFiles present, or a six-digit identifier of the DANDISet. * **config** (_dict, optional_) – If a dictionary, it must be valid against our JSON configuration schema. Can specify a mapping of importance levels and list of check functions whose importance you wish to change. Typically loaded via json.load from a valid .json file * **ignore** (_list of strings, optional_) – Names of functions to skip. * **select** (_list of strings, optional_) – Names of functions to pick out of available checks. * **importance_threshold** (_string or Importance, optional_) – Ignores tests with an assigned importance below this threshold. Importance has three levels: CRITICAL, BEST_PRACTICE_VIOLATION, BEST_PRACTICE_SUGGESTION. The default is the lowest level, BEST_PRACTICE_SUGGESTION. * **n_jobs** (_int_) – Number of jobs to use in parallel. Set to -1 to use all available resources. This may also be a negative integer x from -2 to -(number_of_cpus - 1) which acts like negative slicing by using all available CPUs minus x. Set to 1 (also the default) to disable. * **skip_validate** (_bool, optional_) – Skip the PyNWB validation step. The default is False, which is recommended. * **progress_bar** (_bool, optional_) – Display a progress bar while scanning NWBFiles. Defaults to True. * **progress_bar_class** (_type of tqdm.tqdm, optional_) – The specific child class of tqdm.tqdm to use to make progress bars. Defaults to tqdm.tqdm, the most generic parent. * **progress_bar_options** (_dict, optional_) – Dictionary of keyword arguments to pass directly to the progress_bar_class. * **modules** (_list of strings, optional_) – List of external module names to load; examples would be namespace extensions. These modules may also contain their own custom checks for their extensions. ### Returns Iterable[InspectorMessage | None] ``` -------------------------------- ### inspect_all Source: https://nwbinspector.readthedocs.io/en/dev/api/nwbinspector.html Inspects a local NWBFile or folder of NWBFiles and returns suggestions for improvements according to best practices. It can process multiple files in parallel and offers various configuration options. ```APIDOC ## inspect_all ### Description Inspect a local NWBFile or folder of NWBFiles and return suggestions for improvements according to best practices. ### Method inspect_all ### Parameters #### Path Parameters * **path** (PathType) - Required - File path to an NWBFile, folder path to iterate over recursively and scan all NWBFiles present, or a six-digit identifier of the DANDISet. #### Optional Parameters * **config** (dict | None) - If a dictionary, it must be valid against our JSON configuration schema. Can specify a mapping of importance levels and list of check functions whose importance you wish to change. Typically loaded via json.load from a valid .json file. * **ignore** (list[str] | None) - Names of functions to skip. * **select** (list[str] | None) - Names of functions to pick out of available checks. * **importance_threshold** (str | Importance) - Ignores tests with an assigned importance below this threshold. Importance has three levels: CRITICAL (potentially incorrect data), BEST_PRACTICE_VIOLATION (very suboptimal data representation), BEST_PRACTICE_SUGGESTION (improvable data representation). The default is the lowest level, BEST_PRACTICE_SUGGESTION. * **n_jobs** (int) - Number of jobs to use in parallel. Set to -1 to use all available resources. This may also be a negative integer x from -2 to -(number_of_cpus - 1) which acts like negative slicing by using all available CPUs minus x. Set to 1 (also the default) to disable. * **skip_validate** (bool) - Skip the PyNWB validation step. The default is False, which is recommended. * **progress_bar** (bool) - Display a progress bar while scanning NWBFiles. Defaults to True. * **progress_bar_class** (Type[tqdm]) - The specific child class of tqdm.tqdm to use to make progress bars. Defaults to tqdm.tqdm, the most generic parent. * **progress_bar_options** (dict | None) - Dictionary of keyword arguments to pass directly to the progress_bar_class. * **stream** (bool) - Stream results. * **version_id** (str | None) - Version identifier. * **modules** (list[str] | None) - List of external module names to load; examples would be namespace extensions. These modules may also contain their own custom checks for their extensions. ### Returns Iterable[InspectorMessage | None] ``` -------------------------------- ### Load External Modules with NWBI Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Use the `--modules` flag to load external check registries. Provide module names exactly as they are imported in Python, comma-separated without spaces if multiple. ```bash nwbinspector path/to/my/data.nwb --modules my_extension_module1,my_extension_module2 ``` -------------------------------- ### Define New Neurodata Type with CamelCase Source: https://nwbinspector.readthedocs.io/en/dev/best_practices/extensions.html When defining a new neurodata type using `neurodata_type_def`, use camelCase notation. Names should not include spaces, must start with an uppercase letter, and use a single capitalized letter to separate parts of the name. ```python neurodata_type_def: LaserMeasurement ``` -------------------------------- ### load_config Function Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Loads a configuration dictionary either via keyword search or an explicit filepath. ```APIDOC ## load_config ### Description Load a config dictionary either via keyword search of the internal configs, or an explicit filepath. ### Parameters - **filepath_or_keyword** (str | Path) - Required - Either a file path to the configuration file or a keyword (e.g., 'dandi') to load predefined configurations. ``` -------------------------------- ### Inspect a Single NWB File Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Supply a path to a single NWB file to perform a basic inspection and display a report to the console. ```bash nwbinspector path/to/my/data.nwb ``` -------------------------------- ### _get_report_header Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Grabs basic system information at the time of report generation. ```APIDOC ## _get_report_header ### Description Grab basic information from system at time of report generation. ### Method N/A (Python function) ### Parameters None ### Returns * **dict[str, str]** - A dictionary containing basic system information. ``` -------------------------------- ### Run Checks on NWBFile Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Executes a list of check functions on an NWBFile object. Supports optional progress bar customization. ```python run_checks(_nwbfile : NWBFile_, _checks : list_, _progress_bar_class : Type[tqdm] | None = None_, _progress_bar_options : dict | None = None_, _nwb_schema_version : Version | None = None_) → Iterable[InspectorMessage | None] ``` -------------------------------- ### Inspect All NWB Files in a Directory or List Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_library.html Use `inspect_all` to replicate the command-line interface behavior by inspecting all NWB files within a specified directory or a list of file paths. The return structure is identical to `inspect_nwbfile`. ```python from nwbinspector import inspect_all all_results = list(inspect_all(path=file_paths_or_folder, ...)) ``` -------------------------------- ### Inspect an NWB Directory Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Supply a path to a directory containing NWB files. The tool will recursively inspect all NWB files within the directory and its subdirectories. ```bash nwbinspector path/to/my/data/dir/ ``` -------------------------------- ### inspect_nwbfile Source: https://nwbinspector.readthedocs.io/en/dev/api/nwbinspector.html Opens an NWB file, inspects its contents, and returns suggestions for improvements according to best practices. This function is suitable for inspecting individual NWB files. ```APIDOC ## inspect_nwbfile ### Description Open an NWB file, inspect the contents, and return suggestions for improvements according to best practices. ### Method inspect_nwbfile ### Parameters #### Path Parameters * **nwbfile_path** (FilePathType) - Required - Path to the NWB file on disk or on S3. #### Optional Parameters * **driver** (str | None) - Driver to use for opening the file. * **skip_validate** (bool) - Skip the PyNWB validation step. The default is False, which is recommended. * **max_retries** (int | None) - Maximum number of retries for opening the file. * **checks** (list | None) - List of checks to run. * **config** (dict) - Dictionary valid against our JSON configuration schema. Can specify a mapping of importance levels and list of check functions whose importance you wish to change. Typically loaded via json.load from a valid .json file. * **ignore** (list | None) - Names of functions to skip. * **select** (list | None) - Names of functions to pick out of available checks. * **importance_threshold** (str | Importance) - Ignores tests with an assigned importance below this threshold. Importance has three levels: CRITICAL (potentially incorrect data), BEST_PRACTICE_VIOLATION (very suboptimal data representation), BEST_PRACTICE_SUGGESTION (improvable data representation). The default is the lowest level, BEST_PRACTICE_SUGGESTION. ### Returns Iterable[InspectorMessage | None] ``` -------------------------------- ### inspect_nwbfile_object Source: https://nwbinspector.readthedocs.io/en/dev/api/utils.html Inspects an in-memory NWBFile object and returns suggestions for improvements based on best practices. ```APIDOC ## inspect_nwbfile_object ### Description Inspect an in-memory NWBFile object and return suggestions for improvements according to best practices. ### Method Not applicable (Python function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **nwbfile_object** (_NWBFile_) – An in-memory NWBFile object. * **checks** (_list, optional_) – list of checks to run * **config** (_dict, optional_) – Dictionary valid against our JSON configuration schema. Can specify a mapping of importance levels and list of check functions whose importance you wish to change. Typically loaded via json.load from a valid .json file * **ignore** (_list, optional_) – Names of functions to skip. * **select** (_list, optional_) – Names of functions to pick out of available checks. * **importance_threshold** (_string or Importance, optional_) – Ignores tests with an assigned importance below this threshold. Importance has three levels: * CRITICAL: potentially incorrect data * BEST_PRACTICE_VIOLATION: very suboptimal data representation * BEST_PRACTICE_SUGGESTION: improvable data representation The default is the lowest level, BEST_PRACTICE_SUGGESTION. ### Response #### Success Response Yields: **results** (_a generator of InspectorMessage objects_) – A generator that returns a message on each iteration, if any are triggered by downstream conditions. Otherwise, has length zero (if cast as list), or raises StopIteration (if explicitly calling next). #### Response Example None provided. ``` -------------------------------- ### Apply DANDI Configuration for Inspection Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_library.html Load the DANDI configuration using `load_config("dandi")` to adjust check importance levels for DANDI Archive compliance. Apply this configuration to inspection functions like `inspect_nwbfile`. ```python from nwbinspector import inspect_nwbfile, load_config dandi_config = load_config("dandi") results = list(inspect_nwbfile(nwbfile_path="path_to_single_nwbfile", config=dandi_config)) ``` -------------------------------- ### General NWB File Checks Source: https://nwbinspector.readthedocs.io/en/dev/api/register_check.html General utility functions for checking common naming conventions and descriptions within NWB files. ```APIDOC ## General NWB File Checks ### Description General utility functions for checking common naming conventions and descriptions within NWB files. ### Functions - `check_name_slashes()` - `check_name_colons()` - `check_description() ``` -------------------------------- ### check_small_dataset_compression Source: https://nwbinspector.readthedocs.io/en/dev/api/checks.html Checks if h5py Datasets within an NWBContainer have compression enabled. A warning is issued if the dataset size falls within a specified range and lacks compression. ```APIDOC ## check_small_dataset_compression ### Description Checks if h5py Datasets within an NWBContainer have compression enabled. A warning is issued if the dataset size falls within a specified range and lacks compression. ### Method None (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **_nwb_container** (NWBContainer) - The NWBContainer to check. * **_gb_severity_threshold** (float, optional) - A severity threshold in GB. Defaults to 10.0. * **_mb_lower_bound** (float, optional) - The lower bound in MB for a dataset to be checked. Defaults to 50.0. * **_gb_upper_bound** (float, optional) - The upper bound in GB for a dataset to be checked. Defaults to 20.0. ### Response * **InspectorMessage | None** - Returns an InspectorMessage if compression is not enabled for a dataset within the specified bounds, otherwise None. ``` -------------------------------- ### Stream Inspect NWB Data from DANDI Archive Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Specify the DANDI set ID as the path and use the `--stream` flag to inspect NWB files directly from the DANDI archive without downloading. The default configuration becomes 'dandi' when streaming. ```bash nwbinspector 000017 --stream ``` -------------------------------- ### inspect_nwbfile_object Source: https://nwbinspector.readthedocs.io/en/dev/api/nwbinspector.html Inspects an in-memory NWBFile object and returns suggestions for improvements based on best practices. Allows for customization of checks, configuration, and importance thresholds. ```APIDOC ## inspect_nwbfile_object ### Description Inspect an in-memory NWBFile object and return suggestions for improvements according to best practices. ### Method N/A (Function Call) ### Parameters #### Function Parameters - **nwbfile_object** (NWBFile) - Required - An in-memory NWBFile object. - **checks** (list | None) - Optional - list of checks to run - **config** (dict | None) - Optional - Dictionary valid against our JSON configuration schema. Can specify a mapping of importance levels and list of check functions whose importance you wish to change. Typically loaded via json.load from a valid .json file - **ignore** (list[str] | None) - Optional - Names of functions to skip. - **select** (list[str] | None) - Optional - Names of functions to pick out of available checks. - **importance_threshold** (str | Importance) - Optional - Ignores tests with an assigned importance below this threshold. Importance has three levels: CRITICAL (* potentially incorrect data), BEST_PRACTICE_VIOLATION (* very suboptimal data representation), BEST_PRACTICE_SUGGESTION (* improvable data representation). The default is the lowest level, BEST_PRACTICE_SUGGESTION. ### Returns Iterable[InspectorMessage | None] - An iterable of InspectorMessage objects or None. ``` -------------------------------- ### Parallel Inspection with N-Jobs Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Use the `--n-jobs` flag to enable parallel processing over a directory. Set to a positive integer for specific CPU count or -1 to use all available resources. ```bash nwbinspector path/to/my/data/dir/ --n-jobs -1 ``` -------------------------------- ### Format Report by Levels Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Organize the report output by specifying a comma-separated list of attributes from InspectorMessage. The order of levels can be customized. ```bash nwbinspector path/to/my/data/dir/ --levels check_function_name,object_type,file_path ``` -------------------------------- ### run_checks Source: https://nwbinspector.readthedocs.io/en/dev/api/utils.html Runs checks on an open NWBFile object. ```APIDOC ## run_checks ### Description Run checks on an open NWBFile object. ### Method Not applicable (Python function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **nwbfile** (_pynwb.NWBFile_) – The in-memory pynwb.NWBFile object to run the checks on. * **checks** (_list of check functions_) – The list of check functions that will be run on the in-memory pynwb.NWBFile object. * **progress_bar_class** (_type of tqdm.tqdm, optional_) – The specific child class of tqdm.tqdm to use to make progress bars. Defaults to not displaying progress per set of checks over an individual file. * **progress_bar_options** (_dict, optional_) – Dictionary of keyword arguments to pass directly to the progress_bar_class. * **nwb_schema_version** (_packaging.version.Version, optional_) – The NWB schema version of the file being inspected. If not provided, will be read from nwbfile.read_io.nwb_version if available. This arg is mostly used for tests. Usually it is best to leave as None. ### Response #### Success Response Yields: **results** (_a generator of InspectorMessage objects_) – A generator that returns a message on each iteration, if any are triggered by downstream conditions. Otherwise, has length zero (if cast as list), or raises StopIteration (if explicitly calling next). #### Response Example None provided. ``` -------------------------------- ### General NWB Checks Source: https://nwbinspector.readthedocs.io/en/dev/index.html General utility functions for checking common naming conventions and descriptions within NWB files. ```APIDOC ## General NWB Checks ### Description General utility functions for checking common naming conventions and descriptions within NWB files. ### Functions - `check_name_slashes()` - `check_name_colons()` - `check_description() ``` -------------------------------- ### Select Specific Checks Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Use the `--select` flag to specify a comma-separated list of checks to run. This is useful when you only want to execute a subset of available checks. ```bash nwbinspector path/to/my/data.nwb --select check_subject_exists,check_subject_species_exists ``` -------------------------------- ### NWB Container Checks Source: https://nwbinspector.readthedocs.io/en/dev/api/nwbinspector.html Functions to check compression settings for datasets within NWB containers. ```APIDOC ## NWB Container Checks ### Description Checks related to compression settings for datasets within NWB containers. ### Functions - `check_large_dataset_compression()` - `check_small_dataset_compression()` - `check_empty_string_for_optional_attribute()` ``` -------------------------------- ### General Checks Source: https://nwbinspector.readthedocs.io/en/dev/api/utils.html General utility functions for checking string formats and descriptions. ```APIDOC ## Check Functions: General ### Description General utility functions for validating common data formats. ### Functions - `check_name_slashes()` - `check_name_colons()` - `check_description() ``` -------------------------------- ### check_large_dataset_compression Source: https://nwbinspector.readthedocs.io/en/dev/api/checks.html Checks if large h5py Datasets within an NWBContainer have compression enabled. A warning is issued if the dataset size exceeds a specified bound. ```APIDOC ## check_large_dataset_compression ### Description Checks if large h5py Datasets within an NWBContainer have compression enabled. A warning is issued if the dataset size exceeds a specified bound. ### Method None (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **_nwb_container** (NWBContainer) - The NWBContainer to check. * **_gb_lower_bound** (float, optional) - The lower bound in GB for a dataset to be considered 'large'. Defaults to 20.0. ### Response * **InspectorMessage | None** - Returns an InspectorMessage if compression is not enabled for a large dataset, otherwise None. ``` -------------------------------- ### calculate_number_of_cpu() Source: https://nwbinspector.readthedocs.io/en/dev/api/utils.html Calculates the number of CPUs to use, considering requested and available resources. ```APIDOC ## calculate_number_of_cpu() ### Description Calculate the number CPUs to use with respect to negative slicing and check against maximal available resources. ### Method N/A (Function) ### Parameters #### Input Parameters - **requested_cpu** (int, optional) - The desired number of CPUs to use. The default is 1. ### Returns - int: The calculated number of CPUs to use. ``` -------------------------------- ### print_to_console Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Prints a list of formatted messages to the console. ```APIDOC ## print_to_console ### Description Print report file contents to console. ### Parameters * **_formatted_messages** (_list[str]_) – ### Returns None ``` -------------------------------- ### get_package_version() Source: https://nwbinspector.readthedocs.io/en/dev/api/utils.html Retrieves the version of a package. ```APIDOC ## get_package_version() ### Description Retrieve the version of a package regardless of if it has a __version__ attribute set. ### Method N/A (Function) ### Parameters #### Input Parameters - **name** (str) - Name of package. ### Returns - Version: The package version as an object from packaging.version.Version, which allows comparison to other versions. ``` -------------------------------- ### run_checks Source: https://nwbinspector.readthedocs.io/en/dev/api/nwbinspector.html Runs a specified list of checks on an open NWBFile object. Supports progress bar customization for monitoring check execution. ```APIDOC ## run_checks ### Description Run checks on an open NWBFile object. ### Method N/A (Function Call) ### Parameters #### Function Parameters - **nwbfile** (NWBFile) - Required - The in-memory pynwb.NWBFile object to run the checks on. - **checks** (list) - Required - The list of check functions that will be run on the in-memory pynwb.NWBFile object. - **progress_bar_class** (Type[tqdm] | None) - Optional - The specific child class of tqdm.tqdm to use to make progress bars. Defaults to not displaying progress per set of checks over an individual file. - **progress_bar_options** (dict | None) - Optional - Dictionary of keyword arguments to pass directly to the progress_bar_class. - **nwb_schema_version** (Version | None) - Optional - The NWB schema version of the file being inspected. If not provided, will be read from nwbfile.read_io.nwb_version if available. This arg is mostly used for tests. Usually it is best to leave as None. ### Yields Iterable[InspectorMessage | None] - A generator that returns a message on each iteration, if any are triggered by downstream conditions. Otherwise, has length zero (if cast as list), or raises StopIteration (if explicitly calling next). ``` -------------------------------- ### Core Functions Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Core functions for inspecting NWB files, DANDI datasets, and remote URLs. ```APIDOC ## Core Functions ### Description Core functions for inspecting NWB files and related data structures. ### Functions - `inspect_all()` - `_pickle_inspect_nwb()` - `inspect_nwbfile()` - `_intercept_in_vitro_protein()` - `inspect_nwbfile_object()` - `run_checks()` - `inspect_dandiset()` - `inspect_dandi_file_path()` - `inspect_url() ``` -------------------------------- ### NWB Containers Checks Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Functions to check compression settings for datasets within NWB containers. ```APIDOC ## Check Functions: NWB Containers ### Description Functions for checking compression settings on NWB container datasets. ### Functions - `check_large_dataset_compression()` - `check_small_dataset_compression()` - `check_empty_string_for_optional_attribute() ``` -------------------------------- ### check_emission_lambda_in_nm Source: https://nwbinspector.readthedocs.io/en/dev/api/checks.html Ensures that the emission lambda is within a feasible range for unit nanometers, following the 'Units of Measurement' best practice. ```APIDOC ## check_emission_lambda_in_nm ### Description Checks that emission lambda is in feasible range for unit nanometers. ### Method N/A (Function Call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response - **InspectorMessage | None**: Returns an InspectorMessage if a check fails, otherwise None. #### Response Example N/A ``` -------------------------------- ### format_messages() Source: https://nwbinspector.readthedocs.io/en/dev/api/utils.html Deploys recursive addition of sections, terminating with message display. ```APIDOC ## format_messages() ### Description Deploys recursive addition of sections, terminating with message display. ### Method N/A (Function) ### Parameters None ### Returns - list[str]: A list of formatted messages. ``` -------------------------------- ### Print Formatted Messages to Console Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Prints a list of pre-formatted messages to the console. ```python print_to_console(_formatted_messages : list[str]_) → None ``` -------------------------------- ### NWB Container Checks Source: https://nwbinspector.readthedocs.io/en/dev/index.html Functions to validate compression settings for datasets within NWB containers. ```APIDOC ## NWB Container Checks ### Description Functions to validate compression settings for datasets within NWB containers. ### Functions - `check_large_dataset_compression()` - `check_small_dataset_compression()` - `check_empty_string_for_optional_attribute() ``` -------------------------------- ### Save Report to File Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Specify a path to save the generated report for future reference. ```bash nwbinspector path/to/my/data.nwb --report-file-path path/to/my/nwbinspector_report.txt ``` -------------------------------- ### inspect_nwbfile_object Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Inspects an in-memory NWBFile object and returns suggestions for improvements according to best practices. This is useful for inspecting NWB data that has already been loaded into memory. ```APIDOC ## inspect_nwbfile_object ### Description Inspects an in-memory NWBFile object and returns suggestions for improvements according to best practices. ### Method Not specified (likely a function call in a Python SDK) ### Endpoint Not applicable (function call) ### Parameters #### Path Parameters * **nwbfile_object** (NWBFile) - Required - An in-memory NWBFile object. #### Query Parameters * **checks** (list) - Optional - list of checks to run * **config** (dict) - Optional - Dictionary valid against our JSON configuration schema. Can specify a mapping of importance levels and list of check functions whose importance you wish to change. Typically loaded via json.load from a valid .json file * **ignore** (list[str]) - Optional - Names of functions to skip. * **select** (list[str]) - Optional - Names of functions to pick out of available checks. * **importance_threshold** (string or Importance) - Optional - Ignores tests with an assigned importance below this threshold. Importance has three levels: CRITICAL, BEST_PRACTICE_VIOLATION, BEST_PRACTICE_SUGGESTION. The default is BEST_PRACTICE_SUGGESTION. ### Request Example Not applicable (function call) ### Response #### Success Response An Iterable of InspectorMessage or None. #### Response Example Not applicable (function call) ``` -------------------------------- ### NWB Container Checks Source: https://nwbinspector.readthedocs.io/en/dev/api/register_check.html Functions to validate compression settings for large and small datasets within NWB containers, and checks for empty strings in optional attributes. ```APIDOC ## NWB Container Checks ### Description Functions to validate compression settings for large and small datasets within NWB containers, and checks for empty strings in optional attributes. ### Functions - `check_large_dataset_compression()` - `check_small_dataset_compression()` - `check_empty_string_for_optional_attribute() ``` -------------------------------- ### FormatterOptions Class Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Defines formatting parameters for report generation, including indentation and section headers. Used by MessageFormatter. ```python class FormatterOptions(_indent_size : int = 2_, _indent : str | None = None_, _section_headers : tuple[str, ...] = ('=', '-', '~')_) Bases: `object` Class structure for defining all free attributes for the design of a report format. Class that defines all the format parameters used by the generic MessageFormatter. Parameters: * **indent_size** (_int, optional_) – Defines the spacing between numerical sectioning and section name or message. Defaults to 2 spaces. * **indent** (_str, optional_) – Defines the specific indentation to inject between numerical sectioning and section name or message. Overrides indent_size. Defaults to “ “ * indent_size. * **section_headers** (_tuple of strings_) – List of characters that will be injected under the display of each new section of the report. If levels is longer than this list, the last item will be repeated over the remaining levels. If levels is shorter than this list, only the first len(levels) of items will be used. Defaults to the .rst style for three subsections: [“=”, “-”, “~”] ``` -------------------------------- ### Inspect NWB File from a Cloud URL Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_library_advanced.html Use `inspect_url` to inspect an NWB file directly from a cloud storage URL. This function also returns a generator that can be converted to a list. ```python from nwbinspector import inspect_url url = "https://dandiarchive.s3.amazonaws.com/blobs/3d7/39a/3d739ac0-10fb-41ef-80be-f1479cec44c0" messages = list(inspect_url(url=url)) ``` -------------------------------- ### check_time_intervals_start_time_not_constant Source: https://nwbinspector.readthedocs.io/en/dev/api/checks.html Checks if all start_time values in a TimeIntervals object are identical. This helps identify potential issues with timing data. ```APIDOC ## check_time_intervals_start_time_not_constant ### Description Check if all start_time values are identical. Best Practice: Timing Columns ### Method N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **_time_intervals** (TimeIntervals_) - The TimeIntervals object to check. * **_nelems** (int | None, optional) - Only check the first {nelems} elements. This is useful in case there columns are very long so you don’t need to load the entire array into memory. Use None to load the entire arrays. Defaults to 200. ``` -------------------------------- ### format_byte_size() Source: https://nwbinspector.readthedocs.io/en/dev/api/utils.html Formats a number representing bytes into a human-readable string with appropriate units. ```APIDOC ## format_byte_size() ### Description Format a number representing a total number of bytes into a convenient unit. ### Method N/A (Function) ### Parameters #### Input Parameters - **byte_size** (int) - Total number of bytes to format. - **units** (str, optional) - Convention for orders of magnitude to apply. May be either SI (orders of 1000) or binary (in memory, orders of 1024). The default is SI. ### Returns - str: A formatted string representing the byte size. ``` -------------------------------- ### Use DANDI Configuration for Inspection Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_command_line_interface.html Use the `--config dandi` flag to apply the built-in DANDI configuration, which adjusts check importance levels to match DANDI Archive requirements. This is useful when preparing files for DANDI upload. ```bash nwbinspector path/to/my/data.nwb --config dandi ``` -------------------------------- ### check_excitation_lambda_in_nm Source: https://nwbinspector.readthedocs.io/en/dev/api/checks.html Validates that the excitation lambda is within a feasible range for unit nanometers, aligning with the 'Units of Measurement' best practice. ```APIDOC ## check_excitation_lambda_in_nm ### Description Checks that excitation lambda is in feasible range for unit nanometers. ### Method N/A (Function Call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response - **InspectorMessage | None**: Returns an InspectorMessage if a check fails, otherwise None. #### Response Example N/A ``` -------------------------------- ### Validating Configuration Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html The `validate_config` function ensures that a given configuration dictionary conforms to the expected schema. ```python validate_config(_config : dict_) → None Validate an instance of configuration against the official schema. ``` -------------------------------- ### Cache Extension Specification Source: https://nwbinspector.readthedocs.io/en/dev/best_practices/extensions.html Explicitly cache the extension specification when writing an NWB file. This ensures that the data's interpretation is self-contained. In PyNWB, this is often handled automatically. ```python io.write(filepath, cache_spec=True) ``` -------------------------------- ### Inspect an NWBFile Object in Memory Source: https://nwbinspector.readthedocs.io/en/dev/user_guide/using_the_library.html When an `NWBFile` object is already loaded into memory, use `inspect_nwbfile_object`. This is useful for inspecting files that have been read using `pynwb.NWBHDF5IO` or `hdmf_zarr.nwb.NWBZarrIO`. ```python from nwbinspector import inspect_nwbfile_object from pynwb import NWBHDF5IO with NWBHDF5IO(path="path_to_single_nwbfile", mode="r", load_namespaces=True) as io: nwbfile = io.read() messages = list(inspect_nwbfile_object(nwbfile)) ``` ```python from hdmf_zarr.nwb import NWBZarrIO with NWBZarrIO("example_zarr.nwb", "r") as zarr_io: nwbfile = zarr_io.read() messages = list(inspect_nwbfile_object(nwbfile)) ``` -------------------------------- ### FormatterOptions Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Class structure for defining all free attributes for the design of a report format. ```APIDOC ## FormatterOptions ### Description Class that defines all the format parameters used by the generic MessageFormatter. Used for defining report format design. ### Method N/A (Python class) ### Constructor Parameters * **indent_size** (_int, optional_) - Defines the spacing for numerical sectioning and name/message. Defaults to 2. * **indent** (_str or None, optional_) - Defines specific indentation. Overrides indent_size. Defaults to " " * indent_size. * **section_headers** (_tuple of strings_) - Characters for new section display. Defaults to ('=', '-', '~'). ``` -------------------------------- ### General File Checks Source: https://nwbinspector.readthedocs.io/en/dev/api/nwbinspector.html Functions for performing general checks on file naming conventions and descriptions. ```APIDOC ## General File Checks ### Description General utility functions for validating file names and descriptions. ### Functions - `check_name_slashes()` - `check_name_colons()` - `check_description()` ``` -------------------------------- ### InspectorOutputJSONEncoder Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Custom JSONEncoder for NWBInspector, providing sensible defaults for JSON serialization. ```APIDOC ## InspectorOutputJSONEncoder ### Description Custom JSONEncoder for the NWBInspector. Provides sensible defaults for JSON serialization, with options to control skipping keys, ASCII encoding, circular reference checks, NaN/Infinity handling, key sorting, indentation, separators, and a default handler for unserializable objects. ### Method N/A (Python class) ### Constructor Parameters * **skipkeys** (_bool, optional_) - If false, raises TypeError for non-string/int/float/bool/None keys. Defaults to False. * **ensure_ascii** (_bool, optional_) - If true, escapes non-ASCII characters. Defaults to True. * **check_circular** (_bool, optional_) - If true, checks for circular references. Defaults to True. * **allow_nan** (_bool, optional_) - If true, encodes NaN, Infinity, -Infinity. Defaults to True. * **sort_keys** (_bool, optional_) - If true, sorts dictionary keys. Defaults to False. * **indent** (_int or None, optional_) - Pretty-prints JSON with the specified indent level. None for compact representation. Defaults to None. * **separators** (_tuple, optional_) - Specifies item and key separators. Defaults to (', ', ': ') if indent is None, otherwise (',', ': '). * **default** (_function, optional_) - A function called for objects that cannot be serialized. Defaults to None. ``` -------------------------------- ### Inspect a Dandiset for Common Issues Source: https://nwbinspector.readthedocs.io/en/dev/api/tools.html Use inspect_dandiset to analyze a Dandiset for common problems. You can specify the Dandiset ID, version, configuration, and which checks to run or ignore. ```python inspect_dandiset(_*_ , _dandiset_id : str_, _dandiset_version : str | Literal['draft'] | None = None_, _config : str | Path | dict | Literal['dandi'] | None = None_, _checks : list | None = None_, _ignore : list[str] | None = None_, _select : list[str] | None = None_, _importance_threshold : str | Importance = Importance.BEST_PRACTICE_SUGGESTION_, _skip_validate : bool = False_, _show_progress_bar : bool = True_, _client : dandi.dandiapi.DandiAPIClient | None = None_) ```