From 8a5486aa33b7595384fcdae6bff6c4e6aa46928e Mon Sep 17 00:00:00 2001
From: Christopher Rhodes <christopher.rhodes@embl.de>
Date: Thu, 5 Oct 2023 16:13:46 +0200
Subject: [PATCH] Finished implementing point-based projection

---
 .../chaeo/examples/batch_run_patches.py       |  6 +++---
 extensions/chaeo/tests/test_zstack.py         |  2 +-
 extensions/chaeo/workflows.py                 | 20 +++++++++----------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/extensions/chaeo/examples/batch_run_patches.py b/extensions/chaeo/examples/batch_run_patches.py
index fb96be1a..2900f060 100644
--- a/extensions/chaeo/examples/batch_run_patches.py
+++ b/extensions/chaeo/examples/batch_run_patches.py
@@ -14,7 +14,7 @@ if __name__ == '__main__':
     )
 
     where_output_root = Path(
-        'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0009'
+        'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0009/output'
     )
     yyyymmdd = strftime('%Y%m%d', localtime())
     idx = 0
@@ -51,7 +51,7 @@ if __name__ == '__main__':
         }
 
         result = export_patches_from_multichannel_zstack(**export_kwargs)
-        break
+
         # parse and record results
         df = result['dataframe']
         df['filename'] = ff.name
@@ -65,4 +65,4 @@ if __name__ == '__main__':
             write_accessor_data_to_file(
                 where_output / k / (ff.stem + '.tif'),
                 InMemoryDataAccessor(result['interm'][k])
-                )
\ No newline at end of file
+            )
\ No newline at end of file
diff --git a/extensions/chaeo/tests/test_zstack.py b/extensions/chaeo/tests/test_zstack.py
index 2257b90b..c2d0b113 100644
--- a/extensions/chaeo/tests/test_zstack.py
+++ b/extensions/chaeo/tests/test_zstack.py
@@ -100,7 +100,7 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
 
         from extensions.chaeo.zmask import project_stack_from_focal_points
 
-        dff = df[df['keeper'] == True]
+        dff = df[df['keeper']]
 
         img = project_stack_from_focal_points(
             dff['centroid-0'].to_numpy(),
diff --git a/extensions/chaeo/workflows.py b/extensions/chaeo/workflows.py
index 14e3fd2d..23eab18f 100644
--- a/extensions/chaeo/workflows.py
+++ b/extensions/chaeo/workflows.py
@@ -4,7 +4,7 @@ from typing import Dict
 from extensions.ilastik.models import IlastikPixelClassifierModel
 from extensions.chaeo.annotators import draw_boxes_on_3d_image
 from extensions.chaeo.products import export_patches_from_zstack
-from extensions.chaeo.zmask import build_zmask_from_object_mask
+from extensions.chaeo.zmask import build_zmask_from_object_mask, project_stack_from_focal_points
 from model_server.accessors import generate_file_accessor, InMemoryDataAccessor, write_accessor_data_to_file
 from model_server.workflows import Timer
 
@@ -83,15 +83,15 @@ def export_patches_from_multichannel_zstack(
     )
     ti.click('export_annotated_zstack')
 
-    # from extensions.chaeo.zmask import build_image_flattening_zmask_from_points
-    #
-    # dff = df[df['keeper'] == True]
-    # build_image_flattening_zmask_from_points(
-    #     dff['centroid-0'],
-    #     dff['centroid-1'],
-    #     dff['zi'],
-    #     stack.get_one_channel_data(patches_channel).data,
-    # )
+    # generate multichannel projection from label centroids
+    dff = df[df['keeper']]
+    interm['projected'] = project_stack_from_focal_points(
+        dff['centroid-0'].to_numpy(),
+        dff['centroid-1'].to_numpy(),
+        dff['zi'].to_numpy(),
+        stack,
+        degree=4,
+    )
 
     return {
         'pixel_model_id': px_model.model_id,
-- 
GitLab