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
Labels
object.- Parameters:
file –
FileHandle
object for the NWB file to read.- Returns:
A
Labels
object.
- write(filename: str, labels: Labels, overwrite: bool = False, session_description: str = 'Processed SLEAP pose data', identifier: str | None = None, session_start_time: datetime | None = None)[source]#
Write all
PredictedInstance
objects in aLabels
object to an NWB file.Use
Labels.numpy
to create apynwb.NWBFile
with a separatepynwb.ProcessingModule
for eachVideo
in theLabels
object.To access the
pynwb.ProcessingModule
for 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.ProcessingModule
is andx_pose.PoseEstimation
for each unique track in theVideo
.The
ndx_pose.PoseEstimation
for each uniqueTrack
is stored under the key ‘track{track_idx:03}’ if tracks are set or ‘untrack{track_idx:03}’ if untracked wheretrack_idx
ranges from 0 to (number of tracks) - 1. Ex:track_idx: 1 key: ‘track001’
Each
ndx_pose.PoseEstimation
has andx_pose.PoseEstimationSeries
for everyNode
in theSkeleton
.The
ndx_pose.PoseEstimationSeries
for a specificNode
is stored under the key ‘Node.name
’. Ex:node name: ‘head’ key: ‘head’
- Parameters:
filename – Output path for the NWB format file.
labels – The
Labels
object 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.NWBFile
with a separatepynwb.ProcessingModule
for eachVideo
in theLabels
object.