From d039e57b9bb62e7a17e9804b88bc6c0316e9fd07 Mon Sep 17 00:00:00 2001
From: Christopher Rhodes <christopher.rhodes@embl.de>
Date: Fri, 20 Oct 2023 17:41:42 +0200
Subject: [PATCH] Confirm patch datatype before autoscaling

---
 extensions/chaeo/products.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/extensions/chaeo/products.py b/extensions/chaeo/products.py
index 58596492..e665d878 100644
--- a/extensions/chaeo/products.py
+++ b/extensions/chaeo/products.py
@@ -179,7 +179,11 @@ def export_patches_from_zstack(
 
         ext = 'tif' if make_3d else 'png'
         fname = f'{prefix}-la{obj.label:04d}-zi{obj.zi:04d}.{ext}'
-        _write_patch_to_file(where, fname, resample_to_8bit(patch))
+
+        if patch.dtype is np.dtype('uint16'):
+            _write_patch_to_file(where, fname, resample_to_8bit(patch))
+        else:
+            _write_patch_to_file(where, fname, patch)
 
         exported.append({
             'df_index': idx,
-- 
GitLab