From 0c660d2b993c1df38355e72aa470c773073b611d Mon Sep 17 00:00:00 2001
From: Christopher Rhodes <christopher.rhodes@embl.de>
Date: Thu, 5 Oct 2023 15:55:13 +0200
Subject: [PATCH] Corrected upper clipping range in focus-adaptive projection

---
 extensions/chaeo/tests/test_zstack.py | 3 ++-
 extensions/chaeo/zmask.py             | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/extensions/chaeo/tests/test_zstack.py b/extensions/chaeo/tests/test_zstack.py
index 1ac0321c..2257b90b 100644
--- a/extensions/chaeo/tests/test_zstack.py
+++ b/extensions/chaeo/tests/test_zstack.py
@@ -106,7 +106,8 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
             dff['centroid-0'].to_numpy(),
             dff['centroid-1'].to_numpy(),
             dff['zi'].to_numpy(),
-            self.stack
+            self.stack,
+            degree=4,
         )
 
         self.assertEqual(img.shape[0:2], self.stack.shape[0:2])
diff --git a/extensions/chaeo/zmask.py b/extensions/chaeo/zmask.py
index 3ef3cd97..f624beec 100644
--- a/extensions/chaeo/zmask.py
+++ b/extensions/chaeo/zmask.py
@@ -181,7 +181,7 @@ def project_stack_from_focal_points(
     zi_image = xy_features.reshape(
         stack.hw
     ).round().clip(
-        0, stack.nz
+        0, (stack.nz - 1)
     ).astype('uint16')
 
     return np.take_along_axis(
-- 
GitLab