NWB extension to store pose estimation data
Project description
ndx-pose Extension for NWB
This is a work in progress and not yet ready for public usage.
Installation
TBD
Usage
import datetime
import numpy as np
from pynwb import NWBFile, NWBHDF5IO
from ndx_pose import PoseEstimationSeries, PoseEstimation
nwbfile = NWBFile(
session_description='session_description',
identifier='identifier',
session_start_time=datetime.datetime.now(datetime.timezone.utc)
)
camera1 = nwbfile.create_device(
name='camera1',
description='left camera',
manufacturer='my manufacturer'
)
camera2 = nwbfile.create_device(
name='camera2',
description='right camera',
manufacturer='my manufacturer'
)
data = np.random.rand(100, 3) # num_frames x (x, y, z)
timestamps = np.linspace(0, 10, num=100) # a timestamp for every frame
confidence = np.random.rand(100) # a confidence value for every frame
front_left_paw = PoseEstimationSeries(
name='front_left_paw',
description='Marker placed around fingers of front left paw.',
data=data,
unit='pixels',
reference_frame='(0,0,0) corresponds to ...',
timestamps=timestamps,
confidence=confidence,
confidence_definition='Softmax output of the deep neural network.',
)
data = np.random.rand(100, 2) # num_frames x (x, y)
timestamps = np.linspace(0, 10, num=100) # a timestamp for every frame
confidence = np.random.rand(100) # a confidence value for every frame
front_right_paw = PoseEstimationSeries(
name='front_right_paw',
description='Marker placed around fingers of front right paw.',
data=data,
unit='pixels',
reference_frame='(0,0,0) corresponds to ...',
timestamps=front_left_paw, # link to timestamps of front_left_paw
confidence=confidence,
confidence_definition='Softmax output of the deep neural network.',
)
pose_estimation_series = [front_left_paw, front_right_paw]
pe = PoseEstimation(
pose_estimation_series=pose_estimation_series,
description='Estimated positions of front paws using DeepLabCut.',
original_videos=['camera1.mp4', 'camera2.mp4'],
labeled_videos=['camera1_labeled.mp4', 'camera2_labeled.mp4'],
dimensions=np.array([[640, 480], [1024, 768]], dtype='uint8'),
scorer='DLC_resnet50_openfieldOct30shuffle1_1600',
source_software='DeepLabCut',
source_software_version='2.2b8',
nodes=['front_left_paw', 'front_right_paw'],
edges=np.array([[0, 1]], dtype='uint8'),
# devices=[camera1, camera2], # this is not yet supported
)
behavior_pm = nwbfile.create_processing_module(
name='behavior',
description='processed behavioral data'
)
behavior_pm.add(pe)
path = 'test_pose.nwb'
with NWBHDF5IO(path, mode='w') as io:
io.write(nwbfile)
with NWBHDF5IO(path, mode='r', load_namespaces=True) as io:
read_nwbfile = io.read()
read_pe = read_nwbfile.processing['behavior']['PoseEstimation']
print(read_pe)
Contributors
- @rly
- @bendichter
- @AlexEMG
This extension was created using ndx-template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ndx-pose-0.1.1.tar.gz
(16.5 kB
view details)
Built Distribution
File details
Details for the file ndx-pose-0.1.1.tar.gz
.
File metadata
- Download URL: ndx-pose-0.1.1.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 167dc25f13ba1abc924543cbe44123703303b3f61e5baf6108334a3fe6def11c |
|
MD5 | c14c71de51eca72cc99b4aa5f4edb6e0 |
|
BLAKE2b-256 | 1924c9791f28d2cef4198a3bfb714e0c98421361894e5c3fd7b00d401a0270d4 |
File details
Details for the file ndx_pose-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: ndx_pose-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 229718b494bf34f2e7f73d6e185b074a46169420b57e8573944a14b280b0a472 |
|
MD5 | 56128dcc1831a5c4ca20b98d89765bdf |
|
BLAKE2b-256 | 2c201645f8636563338ca948e5a9281644c257f113f8ca1bd12ddd86c008c3f5 |