from_nwb_file#

movement.io.load_poses.from_nwb_file(file, processing_module_key='behavior', pose_estimation_key='PoseEstimation')[source]#

Create a movement poses dataset from an NWB file.

The input can be a path to an NWB file on disk or a pynwb.file.NWBFile object. The data will be extracted from the NWB file’s pynwb.base.ProcessingModule (specified by processing_module_key) that contains the ndx_pose.PoseEstimation object (specified by pose_estimation_key) formatted according to the ndx-pose NWB extension [1].

Parameters:
  • file (str | Path | pynwb.file.NWBFile) – Path to the NWB file on disk (ending in “.nwb”), or an NWBFile object.

  • processing_module_key (str, optional) – Name of the pynwb.base.ProcessingModule in the NWB file that contains the pose estimation data. Default is “behavior”.

  • pose_estimation_key (str, optional) – Name of the ndx_pose.PoseEstimation object in the processing module (specified by processing_module_key). Default is “PoseEstimation”.

Returns:

A single-individual movement dataset containing the pose tracks, confidence scores, and associated metadata.

Return type:

xarray.Dataset

References

Examples

Open an NWB file and load pose tracks from the pynwb.file.NWBFile object:

>>> import pynwb
>>> import xarray as xr
>>> from movement.io import load_poses
>>> with pynwb.NWBHDF5IO("path/to/file.nwb", mode="r") as io:
...     nwb_file = io.read()
...     ds = load_poses.from_nwb_file(nwb_file)

Or, directly load pose tracks from an NWB file on disk:

>>> ds = load_poses.from_nwb_file("path/to/file.nwb")

Load two single-individual datasets from two NWB files and merge them into a multi-individual dataset:

>>> ds_singles = [
...     load_poses.from_nwb_file(f) for f in ["id1.nwb", "id2.nwb"]
... ]
>>> ds_multi = xr.merge(ds_singles)