sleap.io.format.ndx_pose#
Adaptor to read and write ndx-pose files.
- class sleap.io.format.ndx_pose.NDXPoseAdaptor[source]#
Adaptor to read and write ndx-pose files.
- property all_exts: List[str]#
List of all file extensions supported by adaptor.
- can_read_file(file: FileHandle) bool[source]#
Returns whether this adaptor can read this file.
- can_write_filename(filename: str) bool[source]#
Returns whether this adaptor can write format of this filename.
- property default_ext: str#
The default file extension, e.g., ‘json’ (without ‘.’).
- property handles: SleapObjectType#
Returns the type of object that can be read/written.
The Dispatch class calls this method on all registered adaptors to determine which to use for reading/writing.
- property name: str#
Human-reading name of the file format
- read(file: FileHandle) Labels[source]#
Read the NWB file and returns the appropriate deserialized
Labelsobject.- Parameters:
file –
FileHandleobject for the NWB file to read.- Returns:
A
Labelsobject.
- write(filename: str, labels: Labels, overwrite: bool = False, session_description: str = 'Processed SLEAP pose data', identifier: Optional[str] = None, session_start_time: Optional[datetime] = None)[source]#
Write all
PredictedInstanceobjects in aLabelsobject to an NWB file.Use
Labels.numpyto create apynwb.NWBFilewith a separatepynwb.ProcessingModulefor eachVideoin theLabelsobject.To access the
pynwb.ProcessingModulefor a specificVideo, use the key ‘SLEAP_VIDEO_{video_idx:03}_{video_fn.stem}’ whereisinstance(video_fn, pathlib.PurePath). Ex:video: ‘path_to_video/my_video.mp4’ video index: 3/5 key: ‘003_my_video’
Within each
pynwb.ProcessingModuleis andx_pose.PoseEstimationfor each unique track in theVideo.The
ndx_pose.PoseEstimationfor each uniqueTrackis stored under the key ‘track{track_idx:03}’ if tracks are set or ‘untrack{track_idx:03}’ if untracked wheretrack_idxranges from 0 to (number of tracks) - 1. Ex:track_idx: 1 key: ‘track001’
Each
ndx_pose.PoseEstimationhas andx_pose.PoseEstimationSeriesfor everyNodein theSkeleton.The
ndx_pose.PoseEstimationSeriesfor a specificNodeis stored under the key ‘Node.name’. Ex:node name: ‘head’ key: ‘head’
- Parameters:
filename – Output path for the NWB format file.
labels – The
Labelsobject to covert to a NWB format file.overwrite – Boolean that overwrites existing NWB file if True. If False, data will be appended to existing NWB file.
session_description – Description for entire project. Stored under NWBFile “session_description” key. If appending data to a preexisting file, then the session_description will not be used.
identifier – Unique identifier for project. If no identifier is specified, then will generate a GUID. If appending data to a preexisting file, then the identifier will not be used.
session_start_time – THe datetime associated with the project. If no session_start_time is given, then the current datetime will be used. If appending data to a preexisting file, then the session_start_time will not be used.
- Returns:
A
pynwb.NWBFilewith a separatepynwb.ProcessingModulefor eachVideoin theLabelsobject.