Postprocessing
jabs.behavior.postprocessing package.
PostprocessingPipeline
Pipeline for applying a series of post-processing stages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config list[dict[str, str | dict | None]]
|
Configuration listing the pipeline stages to execute and their parameters. |
required |
stages
property
Return the active (enabled) pipeline stages in execution order.
run(classes, probabilities)
Run the post-processing pipeline on the predicted classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classes
|
ndarray
|
The predicted classes. |
required |
probabilities
|
ndarray
|
The predicted probabilities. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Classes after applying all filters in the pipeline. |
pipeline
PostprocessingPipeline
Pipeline for applying a series of post-processing stages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config list[dict[str, str | dict | None]]
|
Configuration listing the pipeline stages to execute and their parameters. |
required |
stages
property
Return the active (enabled) pipeline stages in execution order.
run(classes, probabilities)
Run the post-processing pipeline on the predicted classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classes
|
ndarray
|
The predicted classes. |
required |
probabilities
|
ndarray
|
The predicted probabilities. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Classes after applying all filters in the pipeline. |
stages
Postprocessing stages.
BoutDurationFilterStage
Bases: PostprocessingStage
Filter that removes predictions shorter than a specified duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_duration
|
int
|
Minimum duration (in frames) for a prediction to be kept. |
required |
config
property
Get the filter configuration.
apply(classes, probabilities)
Apply the duration filter to the predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classes
|
ndarray
|
The predicted classes. |
required |
probabilities
|
ndarray
|
The predicted probabilities. (Not used in this stage.) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: classes after applying the filter. |
help()
classmethod
Get help information about the stage.
Returns:
| Name | Type | Description |
|---|---|---|
FilterHelp |
StageHelp
|
Dataclass with a general description and kwarg descriptions. |
BoutStitchingStage
Bases: PostprocessingStage
Postprocessing stage that combines predictions that are separated by short gaps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_stitch_gap
|
int
|
Maximum gap duration (in frames) allowed between bouts to be stitched together. |
required |
config
property
Get the filter configuration.
apply(classes, probabilities)
Apply stitching to the predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classes
|
ndarray
|
The predicted classes. |
required |
probabilities
|
ndarray
|
The predicted probabilities. (Not used in this stage.) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Classes after applying the stitching. |
help()
classmethod
Get help information about the stage.
Returns:
| Name | Type | Description |
|---|---|---|
FilterHelp |
StageHelp
|
Dataclass with a general description and kwarg descriptions. |
GapInterpolationStage
Bases: PostprocessingStage
Stage that interpolates gaps in predictions.
config
property
Get the filter configuration.
apply(classes, probabilities)
Apply gap interpolation to the predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classes
|
ndarray
|
The predicted classes. |
required |
probabilities
|
ndarray
|
The predicted probabilities. (Not used in this stage.) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Classes after interpolation. |
help()
classmethod
Get help information about the stage.
Returns:
| Name | Type | Description |
|---|---|---|
FilterHelp |
StageHelp
|
Dataclass with a general description and kwarg descriptions. |
PostprocessingStage
Bases: ABC
Base class for post-processing stages.
config
property
Get the filter configuration.
apply(classes, probabilities)
abstractmethod
Apply the stage to the predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classes
|
ndarray
|
The predicted classes. |
required |
probabilities
|
ndarray
|
The predicted probabilities. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Classes after applying the stage transformation. |
help()
abstractmethod
classmethod
Get help information about the stage.
Returns:
| Name | Type | Description |
|---|---|---|
StageHelp |
StageHelp
|
Dataclass with a general description and kwarg descriptions. |
Example
return StageHelp( description="Removes short bouts below a minimum duration.", kwargs={ "min_duration": KwargHelp( description="Minimum duration (in frames) for a bout to be kept.", type="int" ), } )
stage_registry()
Get the stage registry.
Returns:
| Type | Description |
|---|---|
dict[str, type[PostprocessingStage]]
|
Dictionary mapping stage names to stage classes. |
duration_stage
BoutDurationFilterStage
Bases: PostprocessingStage
Filter that removes predictions shorter than a specified duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_duration
|
int
|
Minimum duration (in frames) for a prediction to be kept. |
required |
config
property
Get the filter configuration.
apply(classes, probabilities)
Apply the duration filter to the predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classes
|
ndarray
|
The predicted classes. |
required |
probabilities
|
ndarray
|
The predicted probabilities. (Not used in this stage.) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: classes after applying the filter. |
help()
classmethod
Get help information about the stage.
Returns:
| Name | Type | Description |
|---|---|---|
FilterHelp |
StageHelp
|
Dataclass with a general description and kwarg descriptions. |
interpolation_stage
GapInterpolationStage
Bases: PostprocessingStage
Stage that interpolates gaps in predictions.
config
property
Get the filter configuration.
apply(classes, probabilities)
Apply gap interpolation to the predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classes
|
ndarray
|
The predicted classes. |
required |
probabilities
|
ndarray
|
The predicted probabilities. (Not used in this stage.) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Classes after interpolation. |
help()
classmethod
Get help information about the stage.
Returns:
| Name | Type | Description |
|---|---|---|
FilterHelp |
StageHelp
|
Dataclass with a general description and kwarg descriptions. |
postprocessing_stage
KwargHelp
dataclass
PostprocessingStage
Bases: ABC
Base class for post-processing stages.
config
property
Get the filter configuration.
apply(classes, probabilities)
abstractmethod
Apply the stage to the predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classes
|
ndarray
|
The predicted classes. |
required |
probabilities
|
ndarray
|
The predicted probabilities. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Classes after applying the stage transformation. |
help()
abstractmethod
classmethod
Get help information about the stage.
Returns:
| Name | Type | Description |
|---|---|---|
StageHelp |
StageHelp
|
Dataclass with a general description and kwarg descriptions. |
Example
return StageHelp( description="Removes short bouts below a minimum duration.", kwargs={ "min_duration": KwargHelp( description="Minimum duration (in frames) for a bout to be kept.", type="int" ), } )
StageHelp
dataclass
Dataclass for stage help information.
stitching_stage
BoutStitchingStage
Bases: PostprocessingStage
Postprocessing stage that combines predictions that are separated by short gaps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_stitch_gap
|
int
|
Maximum gap duration (in frames) allowed between bouts to be stitched together. |
required |
config
property
Get the filter configuration.
apply(classes, probabilities)
Apply stitching to the predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classes
|
ndarray
|
The predicted classes. |
required |
probabilities
|
ndarray
|
The predicted probabilities. (Not used in this stage.) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Classes after applying the stitching. |
help()
classmethod
Get help information about the stage.
Returns:
| Name | Type | Description |
|---|---|---|
FilterHelp |
StageHelp
|
Dataclass with a general description and kwarg descriptions. |