Core Library

Primary functions for inspecting NWBFiles.

inspect_all(path: PathType, config: dict | None = None, ignore: list[str] | None = None, select: list[str] | None = None, importance_threshold: str | Importance = Importance.BEST_PRACTICE_SUGGESTION, n_jobs: int = 1, skip_validate: bool = False, progress_bar: bool = True, progress_bar_class: Type[tqdm] = <class 'tqdm.std.tqdm'>, progress_bar_options: dict | None = None, stream: bool = False, version_id: str | None = None, modules: list[str] | None = None) Iterable[InspectorMessage | None]

Inspect a local NWBFile or folder of NWBFiles and return suggestions for improvements according to best practices.

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
    • 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, 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.

_pickle_inspect_nwb(nwbfile_path: str, checks: list | None = None, skip_validate: bool = False) Iterable[InspectorMessage | None]

Auxiliary function for inspect_all to run in parallel using the ProcessPoolExecutor.

inspect_nwbfile(nwbfile_path: str | Path, driver: str | None = None, skip_validate: bool = False, max_retries: int | None = None, checks: list | None = None, config: dict | None = None, ignore: list[str] | None = None, select: list[str] | None = None, importance_threshold: str | Importance = Importance.BEST_PRACTICE_SUGGESTION) Iterable[InspectorMessage | None]

Open an NWB file, inspect the contents, and return suggestions for improvements according to best practices.

Parameters:
  • nwbfile_path (FilePathType) – Path to the NWB file on disk or on S3.

  • skip_validate (bool) – Skip the PyNWB validation step. The default is False, which is recommended.

  • checks (list, optional) – 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, 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.

_intercept_in_vitro_protein(nwbfile_object: NWBFile, checks: list | None = None) list

If the special ‘protein’ subject_id is specified, return a truncated list of checks to run.

This is a temporary method for allowing upload of certain in vitro data to DANDI and is expected to be replaced in future versions.

inspect_nwbfile_object(nwbfile_object: NWBFile, checks: list | None = None, config: dict | None = None, ignore: list[str] | None = None, select: list[str] | None = None, importance_threshold: str | Importance = Importance.BEST_PRACTICE_SUGGESTION) Iterable[InspectorMessage | None]

Inspect an in-memory NWBFile object and return suggestions for improvements according to best practices.

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.

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]

Run checks on an open NWBFile object.

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.

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).

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) Iterable[InspectorMessage | None]

Inspect a Dandiset for common issues.

Parameters:
  • dandiset_id (six-digit string, “draft”, or None) – The six-digit ID of the Dandiset to inspect.

  • dandiset_version (string) – The specific published version of the Dandiset to inspect. If None, the latest version is used. If there are no published versions, then ‘draft’ is used instead.

  • config (file path, dictionary, or “dandi”, default: “dandi”) – If a file path, loads the dictionary configuration from the file. If a dictionary, it must be valid against the configuration schema. If “dandi”, uses the requirements for DANDI validation.

  • checks (list, optional) – list of checks to run

  • 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.

  • skip_validate (bool, default: False) – Skip the PyNWB validation step. This may be desired for older NWBFiles (< schema version v2.10).

  • show_progress_bar (bool, optional) – Whether to display a progress bar while scanning the assets on the Dandiset.

  • client (dandi.dandiapi.DandiAPIClient) – The client object can be passed to avoid re-instantiation over an iteration.

inspect_dandi_file_path(*, dandi_file_path: str, dandiset_id: str, dandiset_version: str | Literal['draft'] | None = None, config: str | Path | dict | Literal['dandi'] | None = 'dandi', 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, client: dandi.dandiapi.DandiAPIClient | None = None) Iterable[InspectorMessage | None]

Inspect a Dandifile for common issues.

Parameters:
  • dandi_file_path (string) – The path to the Dandifile as seen on the archive; e.g., ‘sub-123_ses-456+ecephys.nwb’.

  • dandiset_id (six-digit string, “draft”, or None) – The six-digit ID of the Dandiset.

  • dandiset_version (string) – The specific published version of the Dandiset to inspect. If None, the latest version is used. If there are no published versions, then ‘draft’ is used instead.

  • config (file path, dictionary, “dandi”, or None, default: “dandi”) – If a file path, loads the dictionary configuration from the file. If a dictionary, it must be valid against the configuration schema. If “dandi”, uses the requirements for DANDI validation.

  • checks (list, optional) – list of checks to run

  • 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.

  • skip_validate (bool, default: False) – Skip the PyNWB validation step. This may be desired for older NWBFiles (< schema version v2.10).

  • client (dandi.dandiapi.DandiAPIClient) – The client object can be passed to avoid re-instantiation over an iteration.

inspect_url(*, url: str, config: str | Path | dict | Literal['dandi'] | None = 'dandi', 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) Iterable[InspectorMessage | None]

Inspect an explicit S3 URL.

Parameters:
  • url (string) – A URL referring to the cloud location of an NWB file. Commonly used with DANDI, where the URL has a form similar to: https://dandiarchive.s3.amazonaws.com/blobs/636/57e/63657e32-ad33-4625-b664-31699b5bf664

    Note: this must be the https URL, not the ‘s3://’ form.

  • config (file path, dictionary, “dandi”, or None, default: “dandi”) – If a file path, loads the dictionary configuration from the file. If a dictionary, it must be valid against the configuration schema. If “dandi”, uses the requirements for DANDI validation.

  • checks (list, optional) – list of checks to run

  • 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.

  • skip_validate (bool, default: False) – Whether to skip the PyNWB validation step.