Skip to content
Draft
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
12 changes: 6 additions & 6 deletions src/dynamic_foraging_processing/qc/_core/builder.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""Assemble the dynamic foraging ``QualityControl`` object.

Collects a flat list of metrics (behavior + contract QA) into a single
``QualityControl``, wiring up ``default_grouping`` so the QC portal lays out
``behavior`` and ``test_suite`` as sibling top-level groups.
Collects a flat list of metrics (behavior + contract QC) into a single
``QualityControl``, wiring up ``default_grouping`` so the QC portal groups
metrics by their ``type`` and ``test_suite`` tags.
"""

import typing as t

from aind_data_schema.core.quality_control import QCMetric, QualityControl

#: Tag keys laid out as siblings at the top level of the QC portal.
DEFAULT_GROUPING = ["behavior", "test_suite"]
DEFAULT_GROUPING = [("type", "test_suite")]


def build_quality_control(
Expand All @@ -26,9 +26,9 @@ def build_quality_control(
Parameters
----------
metrics : list of QCMetric
All metrics (behavior + contract QA).
All metrics (behavior + contract QC).
default_grouping : list of str, optional
Tag keys the portal groups by. Defaults to ``["behavior", "test_suite"]``.
Tag keys the portal groups by. Defaults to ``[("type", "test_suite")]``.
allow_tag_failures : list of str, optional
Tag values whose metric failures should not fail the overall QC.
key_experimenters : list of str, optional
Expand Down
10 changes: 5 additions & 5 deletions src/dynamic_foraging_processing/qc/processed/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def side_bias_result(side_bias: np.ndarray, results_folder: t.Optional[str] = No
-------
QCResult
Passes when ``abs(mean_bias) < 0.5``. Fails when the column is empty or
all ``nan`` (``mean_bias`` is ``nan``). Tagged ``{"behavior": ...}`` and
referencing the side-bias plot.
all ``nan`` (``mean_bias`` is ``nan``). Tagged
``{"type": "Average_Side_Bias"}`` and referencing the side-bias plot.
"""
values = np.asarray(side_bias, dtype=float)
if values.size == 0 or np.all(np.isnan(values)):
Expand All @@ -159,9 +159,9 @@ def side_bias_result(side_bias: np.ndarray, results_folder: t.Optional[str] = No
name=name,
value=mean_bias,
passed=bool(abs(mean_bias) < 0.5), # nan comparisons are False -> fails
description="Average side bias across the session (right is positive).",
description="Average side bias should be less than 0.5",
reference=_plot_reference(SIDE_BIAS_PLOT, results_folder),
tags={"behavior": name},
tags={"type": "Average_Side_Bias"},
)


Expand Down Expand Up @@ -203,7 +203,7 @@ def lick_interval_results(
passed=value < limit,
description=f"{name} of inter-lick intervals; passes when < {limit}.",
reference=_plot_reference(LICK_INTERVALS_PLOT, results_folder),
tags={"behavior": name},
tags={"metric": name, "type": "Lick_Interval"},
)
for name, value, limit in specs
]
4 changes: 2 additions & 2 deletions tests/test_qc/test_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_side_bias_result_pass_and_fail():
assert passing.passed is True
assert passing.value == pytest.approx(0.0)
assert passing.reference == _behavior.SIDE_BIAS_PLOT
assert passing.tags == {"behavior": "average side bias"}
assert passing.tags == {"type": "Average_Side_Bias"}

failing = _behavior.side_bias_result(np.array([0.8, 0.9, 1.0]))
assert failing.passed is False
Expand All @@ -75,7 +75,7 @@ def test_lick_interval_results_names_and_count():
"Artifact Percent (%)",
]
assert all(r.reference == _behavior.LICK_INTERVALS_PLOT for r in results)
assert all(r.tags == {"behavior": r.name} for r in results)
assert all(r.tags == {"metric": r.name, "type": "Lick_Interval"} for r in results)


def test_reference_includes_results_folder_name():
Expand Down
Loading