From 0c3a9a03928f7c703a0ab2d419abbbe6ce314c9f Mon Sep 17 00:00:00 2001 From: Christopher Rhodes <christopher.rhodes@embl.de> Date: Thu, 19 Oct 2023 15:41:57 +0200 Subject: [PATCH] Trying to run 2d kristineberg data through z-stack pipeline --- .../actual_runs/20230805_kristineberg_PA.py | 42 +++++++++++++++++++ extensions/chaeo/actual_runs/__init__.py | 0 .../actual_runs/proj0004-exp0038-fixed.py | 41 ++++++++++++++++++ .../chaeo/examples/batch_run_patches.py | 10 +++-- extensions/chaeo/workflows.py | 2 +- 5 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 extensions/chaeo/actual_runs/20230805_kristineberg_PA.py create mode 100644 extensions/chaeo/actual_runs/__init__.py create mode 100644 extensions/chaeo/actual_runs/proj0004-exp0038-fixed.py diff --git a/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py b/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py new file mode 100644 index 00000000..f37da1a1 --- /dev/null +++ b/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py @@ -0,0 +1,42 @@ +from pathlib import Path + +from extensions.chaeo.util import autonumber_new_directory, get_matching_files, loop_workflow +from extensions.chaeo.workflows import export_patches_from_multichannel_zstack + +if __name__ == '__main__': + where_czi = 'c:/Users/rhodes/projects/proj0012-trec-handoff/owncloud-sync/TREC-HD/Images/TREC_STOP_15_Kristineberg/230805_automic_AI_PA/20230805-122525_AI_PA_successfulrun_recognitiononPLL405cilindionas/Selection' + where_output = autonumber_new_directory( + 'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0016/output', + 'batch-output' + ) + + px_ilp = Path.home() / 'model-server' / 'ilastik' / 'AF405-bodies_boundaries.ilp' + + params = { + 'ilastik_project_file': px_ilp.__str__(), + 'pxmap_threshold': 0.25, + 'pixel_class': 0, + 'zmask_channel': 0, + 'patches_channel': 4, + 'mask_type': 'boxes', + 'zmask_filters': {'area': (1e3, 1e8)}, + 'zmask_expand_box_by': (128, 3), + 'export_pixel_probabilities': True, + 'export_2d_patches_for_training': True, + 'export_2d_patches_for_annotation': True, + 'export_3d_patches': False, + 'export_annotated_zstack': True, + 'export_patch_masks': True, + } + + input_files = get_matching_files(where_czi, 'czi') + + loop_workflow( + input_files, + where_output, + export_patches_from_multichannel_zstack, + params, + catch_and_continue=False, + ) + + print('Finished') \ No newline at end of file diff --git a/extensions/chaeo/actual_runs/__init__.py b/extensions/chaeo/actual_runs/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/extensions/chaeo/actual_runs/proj0004-exp0038-fixed.py b/extensions/chaeo/actual_runs/proj0004-exp0038-fixed.py new file mode 100644 index 00000000..436c9edd --- /dev/null +++ b/extensions/chaeo/actual_runs/proj0004-exp0038-fixed.py @@ -0,0 +1,41 @@ +from pathlib import Path + +from extensions.chaeo.util import autonumber_new_directory, get_matching_files, loop_workflow +from extensions.chaeo.workflows import export_patches_from_multichannel_zstack + +if __name__ == '__main__': + where_czi = 'z:/rhodes/projects/proj0004-marine-photoactivation/data/exp0038/AutoMic/20230906-163415/Selection' + where_output = autonumber_new_directory( + 'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0009/output', + 'batch-output' + ) + + px_ilp = Path.home() / 'model-server' / 'ilastik' / 'AF405-bodies_boundaries.ilp' + + params = { + 'ilastik_project_file': px_ilp.__str__(), + 'pxmap_threshold': 0.25, + 'pixel_class': 0, + 'zmask_channel': 0, + 'patches_channel': 4, + 'mask_type': 'boxes', + 'zmask_filters': {'area': (1e3, 1e8)}, + 'zmask_expand_box_by': (128, 3), + 'export_pixel_probabilities': False, + 'export_2d_patches_for_training': True, + 'export_2d_patches_for_annotation': True, + 'export_3d_patches': False, + 'export_annotated_zstack': False, + 'export_patch_masks': True, + } + + input_files = get_matching_files(where_czi, 'czi', coord_filter={'P': (0, 10)}, ) + + loop_workflow( + input_files, + where_output, + export_patches_from_multichannel_zstack, + params, + ) + + print('Finished') \ No newline at end of file diff --git a/extensions/chaeo/examples/batch_run_patches.py b/extensions/chaeo/examples/batch_run_patches.py index 198348f3..e448b8f4 100644 --- a/extensions/chaeo/examples/batch_run_patches.py +++ b/extensions/chaeo/examples/batch_run_patches.py @@ -4,10 +4,11 @@ from extensions.chaeo.util import autonumber_new_directory, get_matching_files, from extensions.chaeo.workflows import export_patches_from_multichannel_zstack if __name__ == '__main__': - where_czi = 'z:/rhodes/projects/proj0004-marine-photoactivation/data/exp0038/AutoMic/20230906-163415/Selection' - + # where_czi = 'z:/rhodes/projects/proj0004-marine-photoactivation/data/exp0038/AutoMic/20230906-163415/Selection' + where_czi = 'c:/Users/rhodes/projects/proj0012-trec-handoff/owncloud-sync/TREC-HD/Images/TREC_STOP_15_Kristineberg/230805_automic_AI_PA/20230805-122525_AI_PA_successfulrun_recognitiononPLL405cilindionas/Selection' where_output = autonumber_new_directory( - 'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0009/output', + # 'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0009/output', + 'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0016/output', 'batch-output' ) @@ -22,7 +23,7 @@ if __name__ == '__main__': 'mask_type': 'boxes', 'zmask_filters': {'area': (1e3, 1e8)}, 'zmask_expand_box_by': (128, 3), - 'export_pixel_probabilities': False, + 'export_pixel_probabilities': True, 'export_2d_patches_for_training': True, 'export_2d_patches_for_annotation': True, 'export_3d_patches': False, @@ -30,6 +31,7 @@ if __name__ == '__main__': 'export_patch_masks': True, } + # input_files = get_matching_files(where_czi, 'czi', coord_filter={'P': (0, 10)}, ) input_files = get_matching_files(where_czi, 'czi', coord_filter={'P': (0, 10)}, ) loop_workflow( diff --git a/extensions/chaeo/workflows.py b/extensions/chaeo/workflows.py index 49c114a3..f84cf2eb 100644 --- a/extensions/chaeo/workflows.py +++ b/extensions/chaeo/workflows.py @@ -38,7 +38,7 @@ def export_patches_from_multichannel_zstack( stack = generate_file_accessor(Path(input_zstack_path)) fstem = Path(input_zstack_path).stem ti.click('file_input') - assert stack.nz > 1, 'Expecting z-stack' + # assert stack.nz > 1, 'Expecting z-stack' # MIP and classify pixels mip = InMemoryDataAccessor( -- GitLab