Quantify user-defined behaviors.
Project description
LabGym: quantifying user-defined behaviors
Identifies social behaviors in multi-individual interactions
Distinguishing different social roles of multiple similar-looking interacting individuals
Distinguishing different interactive behaviors among multiple animal-object interactions
Distinguishing different social roles of animals in the field with unstable recording environments
Identifies non-social behaviors
Identifying behaviors in diverse species in various recording environments
Identifying behaviors with no posture changes such as cells 'changing color' and neurons 'firing'
Quantifies each user-defined behavior
Computes a range of motion and kinematics parameters for each behavior. The parameters include count, duration, and latency of behavioral incidents, as well as speed, acceleration, distance traveled, and the intensity and vigor of motions during the behaviors. These parameters are output in spreadsheets.
Also provides visualization of analysis results, including annotated videos/images that visually mark each behavior event, temporal raster plots that show every behavior event of every individual overtime.
A tutorial video for a high-level understanding of what LabGym can do and how it works:
Cite LabGym: LabGym 1.x & LabGym 2.x
How to use LabGym?
Overview
You can use LabGym via its user interface (no coding knowledge needed), or via command prompt. See Extended User Guide for details.
If the extended user guide is difficult to follow, see this Practical "How To" Guide with layman language and examples.
Put your mouse cursor above each button in the user interface to see a detailed description for it.
LabGym comprises three modules, each tailored to streamline the analysis process. Together, these modules create a cohesive workflow, enabling users to prepare, train, and analyze their behavioral data with accuracy and ease.
-
'Preprocessing Module': This module is for optimizing video footage for analysis. It can trim videos to focus solely on the necessary time windows, crop frames to remove irrelevant regions, enhance video contrast to make the relevant details more discernible, reduce video fps to increase processing speed, or draw colored markers in videos to mark specific locations.
-
'Training Module': Here, you can customize LabGym according to your specific research needs. You can train a Detector in this module to detect animals or objects of your interest in videos/images. You can also train a Categorizer to recognize specific behaviors that are defined by you.
-
'Analysis Module': After customizing LabGym to your need, you can use this module for automated behavioral analysis in videos/images. It not only outputs comprehensive analysis results but also delves into these results to mine significant findings.
Usage Step 1: detect animals/objects
LabGym employs two distinct methods for detecting animals or objects in different scenarios.
1. Subtract background
This method is fast and accurate but requires stable illumination and static background in videos to analysis. It does not require training neural networks, but you need to define a time window during which the animals are in motion for effective background extraction. A shorter time window leads to quicker processing. Typically, a duration of 10 to 30 seconds is adequate.
How to select an appropriate time window for background extraction?
To determine the optimal time window for background extraction, consider the animal's movement throughout the video. In the example below, in a 60-second video, selecting a 20-second window where the mouse moves frequently and covers different areas is ideal. The following three images are backgrounds extracted using the time windows of the first, second, and last 20 seconds, respectively. In the first and last 20 seconds, the mouse mostly stays either in left or right side and moves little and the extracted backgrounds contain animal trace, which is not ideal. In the second 20 seconds, the mouse frequently moves around and the extracted background is perfect:
2. Use trained Detectors
This method incorporates Detectron2, offering more versatility but at a slower processing speed compared to the ‘Subtract Background’ method. It excels in differentiating individual animals or objects, even during collisions, which is particularly beneficial for the 'Interactive advanced' mode. To enhance processing speed, use a GPU or reduce the frame size during analysis. To train a Detector in ‘Training Module’:
- Click the ‘Generate Image Examples’ button to extract image frames from videos.
- Use free online annotation tools like Roboflow to annotate the outlines of animals or objects in these images. For annotation type, choose 'Instance Segmentation', and export the annotations in 'COCO instance segmentation' format, which generates a ‘*.json’ file. Importantly, when you generate a version of dataset, do NOT perform any preprocessing steps such as ‘auto orient’ and ‘resize (stretch)’. Instead, perform some augmentation based on which manipulations may occur in real scenarios.
- Use the ‘Train Detectors’ button to input these annotated images and commence training your Detectors.
Usage Step 2: identify and quantify behaviors
LabGym is equipped with four distinct modes of behavior identification to suit different scenarios.
1. Interactive advanced
This mode is for analyzing the behavior of every individual in a group of animals or objects, such as a finger 'holding' or 'offering' a peanut, a chipmunk 'taking' or 'loading' a peanut, and a peanut 'being held', 'being taken', or 'being loaded'.
To train a Categorizer of this mode, you can sort the behavior examples (Animation and Pattern Image) according to the behaviors/social roles of the 'main character' highlighted in a magenta-color-coded 'spotlight'. In the four pairs of behavior examples below, behaviors are 'taking the offer', 'being taken', 'being held', and 'offering peanut', respectively.
2. Interactive basic
Optimized for speed, this mode considers the entire interactive group (2 or more individuals) as an entity, streamlining the processing time compared to the 'Interactive advanced' mode. It is ideal for scenarios where individual behaviors within the group are uniform or when the specific actions of each member are not the primary focus of the study, such as 'licking' and 'attempted copulation' (where we only need to identify behaviors of the male fly).
To train a Categorizer of this mode, you can sort the behavior examples (Animation and Pattern Image) according to the behaviors of the entire interacting group or the individual of primary focus of the study. In the 3 pairs of behavior examples below, behaviors are behaviors like 'orientating', 'singing while licking', and 'attempted copulation', respectively.
3. Non-interactive
This mode is for identifying solitary behaviors of individuals that are not engaging in interactive activities.
To train a Categorizer of this mode, you can sort the behavior examples (Animation and Pattern Image) according to the behaviors of individuals.
4. Static image
This mode is for identifying solitary behaviors of individuals in static images.
Installation
LabGym Zoo (trained models and training examples)
Reporting Issues
Changelog
Contributing
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
Built Distribution
File details
Details for the file labgym-2.7.0.tar.gz
.
File metadata
- Download URL: labgym-2.7.0.tar.gz
- Upload date:
- Size: 102.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9912a1777cbf512bca75bd60de5f6d69c3b7c5566d8a2f08aacfa5d9ba4607ee |
|
MD5 | 052aadf81da7874bef11d61b7f1eb07f |
|
BLAKE2b-256 | d867c1b98ef1f99f94bcb6c074b2865fce34b9f6c1da00d75f8b1bd8eddd65a1 |
Provenance
The following attestation bundles were made for labgym-2.7.0.tar.gz
:
Publisher:
python-publish.yml
on umyelab/LabGym
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
labgym-2.7.0.tar.gz
- Subject digest:
9912a1777cbf512bca75bd60de5f6d69c3b7c5566d8a2f08aacfa5d9ba4607ee
- Sigstore transparency entry: 149168729
- Sigstore integration time:
- Predicate type:
File details
Details for the file labgym-2.7.0-py3-none-any.whl
.
File metadata
- Download URL: labgym-2.7.0-py3-none-any.whl
- Upload date:
- Size: 114.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 856a0ef22ed7b686ea352383fb617f6f9b571e29499f5bf00dce3e960994a602 |
|
MD5 | 908bb6fda05aeaceaaa77336ce057023 |
|
BLAKE2b-256 | 9a1ac0727aa5fc2e64eda34739d3e346400963f92db514cc6f7b080748785e62 |
Provenance
The following attestation bundles were made for labgym-2.7.0-py3-none-any.whl
:
Publisher:
python-publish.yml
on umyelab/LabGym
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
labgym-2.7.0-py3-none-any.whl
- Subject digest:
856a0ef22ed7b686ea352383fb617f6f9b571e29499f5bf00dce3e960994a602
- Sigstore transparency entry: 149168730
- Sigstore integration time:
- Predicate type: