Metadata-Version: 2.3
Name: jabs-behavior
Version: 0.41.0
Summary: JABS behavior event processing and postprocessing filters
Author: Glen Beane, Alexander Berger-Liedtka, Keith Sheppard
License: Proprietary
Requires-Dist: jsonschema>=4.25.1,<5.0.0
Requires-Dist: numpy>=2.0.0,<3.0.0
Requires-Python: >=3.10, <3.15
Project-URL: Repository, https://github.com/KumarLabJax/JABS-behavior-classifier
Project-URL: Issues, https://github.com/KumarLabJax/JABS-behavior-classifier/issues
Description-Content-Type: text/markdown

# JABS Behavior (`jabs-behavior`)


## Prediction Postprocessing

The `jabs.behavior.postprocessing` module provides tools for refining behavior predictions generated by the JABS framework. It includes classes and functions to manipulate and enhance the quality of behavior event predictions through various postprocessing techniques.

- **BehaviorEvents**: Run-length encoding of JABS predictions for efficient behavior event manipulation
- **Postprocessing Stages**: Configurable pipeline stages for refining behavior predictions:
  - `BoutDurationFilterStage`: Remove short behavior bouts below a minimum duration
  - `BoutStitchingStage`: Combine behavior bouts separated by short gaps
  - `GapInterpolationStage`: Fill gaps in predictions (NONE labels)
- **PostprocessingPipeline**: Sequential application of multiple Stages

### Usage

```python
import numpy as np
from jabs.behavior.events import BehaviorEvents, ClassLabels
from jabs.behavior.postprocessing import BoutDurationFilterStage, BoutStitchingStage, PostprocessingPipeline 

# Create behavior events from a prediction vector
predictions = np.array([0, 0, 1, 1, 0, 1, 1, 1, 0])
events = BehaviorEvents.from_vector(predictions)

# Apply postprocessing pipeline
config = {
    BoutStitchingStage.name: {"max_stitch_gap": 2},
    BoutDurationFilterStage.name: {"min_duration": 3},
}
pipeline = PostprocessingPipeline(config)
refined_predictions = pipeline.run(predictions)
```
