Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "jabs-postprocess"
version = "0.5.0"
version = "0.5.1"
description = "A python library for JABS postprocessing utilities."
readme = "README.md"
license = "LicenseRef-PLATFORM-LICENSE-AGREEMENT-FOR-NON-COMMERCIAL-USE"
Expand Down
10 changes: 4 additions & 6 deletions src/jabs_postprocess/utils/project_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,12 +1024,10 @@ def bouts_to_bins(
# We use a weighted statistic definitions here
# Weights are the proportion of bout contained in the bin (percent_bout)
if results["bout_behavior"] > 0:
results["avg_bout_duration"] = (
np.sum(
behavior_bins["duration"].values
* behavior_bins["percent_bout"].values
)
/ results["bout_behavior"]
results["avg_bout_duration"] = np.average(
behavior_bins["duration"].values
/ behavior_bins["percent_bout"].values,
weights=behavior_bins["percent_bout"].values,
)
results["latency_to_first_prediction"] = behavior_bins["start"].min()
results["latency_to_last_prediction"] = (
Expand Down
6 changes: 3 additions & 3 deletions tests/utils/test_project_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,15 +759,15 @@ def test_bouts_to_bins_split_bout_weighted_statistics(self):
# Both bins should have:
# - bout_behavior = 0.5 (half the bout counted)
# - time_behavior = 300 (half the frames)
# - avg_bout_duration = 300 (the actual duration in each bin)
# - avg_bout_duration = 600 (duration remains same, average of 1 sample)
# - variance = NaN (only one bout, even if split)
assert len(result) == 2

for i in range(2):
assert abs(result.iloc[i]["bout_behavior"] - 0.5) < 0.01
assert result.iloc[i]["time_behavior"] == 300
# When a bout is split, the avg_bout_duration is the fractional duration
assert abs(result.iloc[i]["avg_bout_duration"] - 300) < 0.1
# When a bout is split, the avg_bout_duration is still the total duration
assert abs(result.iloc[i]["avg_bout_duration"] - 600) < 0.1
assert pd.isna(result.iloc[i]["bout_duration_var"])

def test_bouts_to_bins_multiple_split_bouts_variance(self):
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vm/jabs-postprocess.def
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ From: ghcr.io/astral-sh/uv:python3.10-bookworm-slim

%labels
Author "The Kumar Lab"
Version "0.1.0"
Version "0.5.1"
Description "JABS post-processing container with Python 3.10"