From 252915c649dddc91dae3a36b8428f3940baf094c Mon Sep 17 00:00:00 2001
From: Arin Wongprommoon <arin.wongprommoon@ed.ac.uk>
Date: Tue, 11 Oct 2022 18:31:55 +0100
Subject: [PATCH] fix(extraction): define candidate channels

WHY IS THIS CHANGE NEEDED?:
- invoked grouper (which used chainer, which in turn is based on
  Signal), encountered AttributeError: 'Chainer' object has no
  attributes 'candidate_channels'

HOW DOES THE CHANGE SOLVE THE PROBLEM?:
- chainer used to rely on av_channels in
  extraction/core/functions/defaults.py, so renamed that to
  candidate_channels
- added a candidate_channels attribute to Signal object to fulfil references
---
 src/agora/io/signal.py                    | 11 +++++++++++
 src/extraction/core/functions/defaults.py |  8 ++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/agora/io/signal.py b/src/agora/io/signal.py
index 489a5256..4f90df92 100644
--- a/src/agora/io/signal.py
+++ b/src/agora/io/signal.py
@@ -33,6 +33,17 @@ class Signal(BridgeH5):
             "mother_label",
         )
 
+        self.candidate_channels = (
+            "GFP",
+            "GFPFast",
+            "mCherry",
+            "Flavin",
+            "Citrine",
+            "mKO2",
+            "Cy5",
+            "pHluorin405",
+        )
+
         equivalences = {
             "m5m": ("extraction/GFP/max/max5px", "extraction/GFP/max/median")
         }
diff --git a/src/extraction/core/functions/defaults.py b/src/extraction/core/functions/defaults.py
index 2d715c80..c5b520f1 100644
--- a/src/extraction/core/functions/defaults.py
+++ b/src/extraction/core/functions/defaults.py
@@ -17,7 +17,7 @@ def exparams_from_meta(
         "multichannel_ops": {},
     }
 
-    av_channels = {
+    candidate_channels = {
         "Citrine",
         "GFP",
         "GFPFast",
@@ -41,9 +41,9 @@ def exparams_from_meta(
     default_rm = {r: default_metrics for r in default_reductions}
     # default_rm["None"] = ["nuc_conv_3d"] # Uncomment this to add nuc_conv_3d (slow)
 
-    av_flch = av_channels.intersection(meta["channels/channel"]).difference(
-        {"Brightfield", "DIC", "BrightfieldGFP"}
-    )
+    av_flch = candidate_channels.intersection(
+        meta["channels/channel"]
+    ).difference({"Brightfield", "DIC", "BrightfieldGFP"})
 
     for ch in av_flch:
         base["tree"][ch] = default_rm
-- 
GitLab