From baa450a38ebe373a34b8cb9b27aada5e29620f22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Al=C3=A1n=20Mu=C3=B1oz?= <alan.munoz@ed.ac.uk>
Date: Fri, 17 Feb 2023 20:05:27 +0000
Subject: [PATCH] fix(tiler): Set default size_c metadata

---
 src/aliby/tile/tiler.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/aliby/tile/tiler.py b/src/aliby/tile/tiler.py
index 34aa89d1..aaaa5474 100644
--- a/src/aliby/tile/tiler.py
+++ b/src/aliby/tile/tiler.py
@@ -232,8 +232,9 @@ class Tiler(StepABC):
         self.image = image
         self._metadata = metadata
         self.channels = metadata.get(
-            "channels", list(range(metadata["size_c"]))
+            "channels", list(range(metadata.get("size_c", 0)))
         )
+
         self.ref_channel = self.get_channel_index(parameters.ref_channel)
 
         self.trap_locs = trap_locs
@@ -352,7 +353,10 @@ class Tiler(StepABC):
         -------
         full: an array of images
         """
-        full = self.image[t, c].compute(scheduler="synchronous")
+        full = self.image[t, c]
+        if hasattr(full, "compute"):  # If using dask fetch images here
+            full = full.compute(scheduler="synchronous")
+
         return full
 
     @property
-- 
GitLab