diff --git a/extensions/chaeo/tests/test_zstack.py b/extensions/chaeo/tests/test_zstack.py
index 1ac0321cd999cc692c6b9ea4dd94e58c459fb389..2257b90b360e7bc744b70cff0e28c634c152b195 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 3ef3cd97aa422f03bd9673f1a83aaff0a3de8fa8..f624beec7bf6f201ea164a9bd165e54fa7d2bd9a 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(