Skip to main content

NWB extension for behavioral bouts: labeled time intervals (one row per bout) from pose-estimation post-processing tools (VAME, keypoint-MoSeq, B-SOiD, DeepEthogram, SimBA), as a TimeIntervals subclass

Project description

ndx-ethogram Extension for NWB

An NWB extension for storing a curated, tool-agnostic ethogram as labeled behavioral bouts: one row per bout, where a bout is a continuous interval of a single behavior. EthogramBouts is a TimeIntervals subclass, so each row inherits start_time and stop_time and adds a single text label.

It is the downstream-oriented, lossy-by-design product of behavioral segmentation and classification tools. Named producers (DeepEthogram, SimBA, CalMS21, CRIM13) give the label a human-readable behavior name; integer-only unsupervised producers (VAME, keypoint-MoSeq, B-SOiD) give it the tool's own cluster id as text (e.g. "7"). Overlapping behaviors are simply overlapping rows. A tool's faithful native output (per-frame motif or syllable stream) lives in its own extension and is referenced through the generic source link, so this extension depends on no tool-specific extension.

Installation

pip install ndx-ethogram

Or from a clone of this repository:

pip install -e .

Usage

from datetime import datetime, timezone

from pynwb import NWBFile, NWBHDF5IO
from ndx_ethogram import EthogramBouts

nwbfile = NWBFile(
    session_description="social behavior session",
    identifier="session-001",
    session_start_time=datetime(2024, 1, 1, tzinfo=timezone.utc),
)

# One EthogramBouts table. `labeling_method` is required: "manual" (a human scored
# the video), "automated" (an algorithm), or "curated" (human-reviewed model output).
bouts = EthogramBouts(
    name="behavior_bouts",
    description="DeepEthogram behavior bouts",
    labeling_method="manual",
    source_software="DeepEthogram 0.1.4",   # optional
    annotator="lab annotator 1",            # optional
)

# One row per bout. `label` is the only added column (single required text column).
bouts.add_row(start_time=1.0, stop_time=2.5, label="grooming")
bouts.add_row(start_time=2.0, stop_time=3.0, label="rearing")   # overlap is allowed

behavior = nwbfile.create_processing_module("behavior", "behavioral bouts")
behavior.add(bouts)

with NWBHDF5IO("example.nwb", "w") as io:
    io.write(nwbfile)

Optional links

A EthogramBouts table can point at the objects it was derived from or aligns to, each optional:

  • source_pose -> the upstream ndx-pose PoseEstimation (pose-based tools).
  • source_video -> the behavioral video ImageSeries the bouts align to.
  • source -> the producing faithful object (e.g. a per-frame motif/syllable TimeSeries or a tool-specific container); a generic NWBDataInterface target so this extension stays tool-agnostic.
  • observation_intervals -> a core TimeIntervals marking the spans over which the labels were assessed, for partial-coverage inputs. Within them, absence of a bout means the behavior was absent; outside, it was unobserved. Omit when assessed throughout.
bouts.source_pose = pose_estimation     # an ndx_pose.PoseEstimation
bouts.source_video = behavior_video     # a pynwb.image.ImageSeries

Attributes and columns at a glance

Field Kind Required Meaning
start_time, stop_time column (float, s) yes (inherited) the bout span
label column (text) yes the bout's behavior / motif / cluster identity
labeling_method attribute yes manual, automated, or curated
source_software attribute no producing tool and version
annotator attribute no human or lab who produced manual/curated labels
parameters attribute no JSON-encoded key hyperparameters
source link no the faithful producing object
source_pose link no upstream PoseEstimation
source_video link no the behavioral video ImageSeries
observation_intervals link no spans over which labels were assessed

Only durative (state) behaviors belong here; instantaneous point behaviors belong in an EventsTable.


This extension was created using ndx-template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndx_ethogram-0.1.0.tar.gz (185.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ndx_ethogram-0.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file ndx_ethogram-0.1.0.tar.gz.

File metadata

  • Download URL: ndx_ethogram-0.1.0.tar.gz
  • Upload date:
  • Size: 185.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ndx_ethogram-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c31ae967cc0d2f243b2547de1f86b85551ae4daeaf6eb19e415dc1a01d4a3be8
MD5 2745db75a134cb35289361c288324fad
BLAKE2b-256 5a66ff792a13a929fbb6576c9740aa52a6ef8543c6617c732b3edf9f178ecd65

See more details on using hashes here.

Provenance

The following attestation bundles were made for ndx_ethogram-0.1.0.tar.gz:

Publisher: auto-publish.yml on catalystneuro/ndx-ethogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ndx_ethogram-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ndx_ethogram-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ndx_ethogram-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2cbf9110241347208489fa2b75e08f46bd34a98a834d05e937e94aa3a088bd2
MD5 55a1df4b51d974aa10bb6368ea2895ff
BLAKE2b-256 29d64d990aa702bd6763993c9aec867db04e3bb66faf39926f744dbe4d680588

See more details on using hashes here.

Provenance

The following attestation bundles were made for ndx_ethogram-0.1.0-py3-none-any.whl:

Publisher: auto-publish.yml on catalystneuro/ndx-ethogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page