diff --git a/src/dynamic_foraging_processing/qc/_core/builder.py b/src/dynamic_foraging_processing/qc/_core/builder.py index d9b590f..a7ee77f 100644 --- a/src/dynamic_foraging_processing/qc/_core/builder.py +++ b/src/dynamic_foraging_processing/qc/_core/builder.py @@ -1,8 +1,8 @@ """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 @@ -10,7 +10,7 @@ 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( @@ -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 diff --git a/src/dynamic_foraging_processing/qc/processed/behavior.py b/src/dynamic_foraging_processing/qc/processed/behavior.py index ffc6e9e..b9e019e 100644 --- a/src/dynamic_foraging_processing/qc/processed/behavior.py +++ b/src/dynamic_foraging_processing/qc/processed/behavior.py @@ -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)): @@ -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"}, ) @@ -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 ] diff --git a/tests/test_qc/test_behavior.py b/tests/test_qc/test_behavior.py index 8fff460..d366034 100644 --- a/tests/test_qc/test_behavior.py +++ b/tests/test_qc/test_behavior.py @@ -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 @@ -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():