diff --git a/extensions/chaeo/batch_jobs/20231023_Porto_Live.py b/extensions/chaeo/batch_jobs/20231023_Porto_Live.py new file mode 100644 index 0000000000000000000000000000000000000000..8a8c8b641586c5e6097a312f95e45d07dc92dd79 --- /dev/null +++ b/extensions/chaeo/batch_jobs/20231023_Porto_Live.py @@ -0,0 +1,56 @@ +from pathlib import Path + +from model_server.util import autonumber_new_directory, get_matching_files, loop_workflow +from extensions.chaeo.ecotaxa import write_ecotaxa_tsv +from extensions.chaeo.workflows import export_patches_from_multichannel_zstack +from extensions.ilastik.models import IlastikPixelClassifierModel + + +if __name__ == '__main__': + sample_id = '20231023-porto-live' + root = Path('c:/Users/rhodes/projects/proj0012-trec-handoff/owncloud-sync/TREC-HD/Images/') + where_czi = (root / 'TREC_STOP_26_Porto/231023_automic/20231023-182725_Live/LowZoom').__str__() + where_output = autonumber_new_directory( + 'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0021/output', + 'batch-output' + ) + + px_ilp = Path('c:/Users/rhodes/projects/proj0011-plankton-seg/exp0017/pxAF405_dim8bit.ilp').__str__() + + params = { + 'pxmap_threshold': 0.25, + 'pxmap_foreground_channel': 0, + 'segmentation_channel': 0, + 'zmask_zindex': None, + 'patches_channel': 2, + 'zmask_type': 'boxes', + 'zmask_filters': {'area': (1e3, 1e8)}, + 'zmask_expand_box_by': (128, 3), + 'export_pixel_probabilities': True, + 'export_2d_patches_for_training': True, + 'draw_bounding_box_on_2d_patch': True, + 'export_2d_patches_for_annotation': True, + 'export_3d_patches': False, + 'export_annotated_zstack': True, + 'export_patch_masks': True, + 'zmask_clip': 0.01, + 'rgb_overlay_channels': (1, None, None), + 'rgb_overlay_weights': (0.2, 1.0, 1.0), + 'draw_label_on_zstack': True, + } + + input_files = get_matching_files(where_czi, 'czi', coord_filter={}) + + loop_workflow( + input_files, + where_output, + export_patches_from_multichannel_zstack, + [IlastikPixelClassifierModel(params={'project_file': Path(px_ilp)})], + params, + catch_and_continue=False, + ) + + csv_path = (Path(where_output) / 'workflow_data.csv').__str__() + write_ecotaxa_tsv(csv_path, where_output, sample_id=sample_id, scope_id='EMBL-MS-Zeiss-LSM900') + + print('Finished') \ No newline at end of file diff --git a/extensions/chaeo/batch_jobs/20231026_Porto.py b/extensions/chaeo/batch_jobs/20231026_Porto.py new file mode 100644 index 0000000000000000000000000000000000000000..3e31a859be55825a4b59f1b4be47741ab8f67413 --- /dev/null +++ b/extensions/chaeo/batch_jobs/20231026_Porto.py @@ -0,0 +1,56 @@ +from pathlib import Path + +from model_server.util import autonumber_new_directory, get_matching_files, loop_workflow +from extensions.chaeo.ecotaxa import write_ecotaxa_tsv +from extensions.chaeo.workflows import export_patches_from_multichannel_zstack +from extensions.ilastik.models import IlastikPixelClassifierModel + + +if __name__ == '__main__': + sample_id = '20231026-porto' + root = Path('c:/Users/rhodes/projects/proj0012-trec-handoff/owncloud-sync/TREC-HD/Images/') + where_czi = (root / 'TREC_STOP_26_Porto/231026_automic/20231026-152512_lowzoom_data/LowZoom').__str__() + where_output = autonumber_new_directory( + 'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0022/output', + 'batch-output' + ) + + px_ilp = Path('c:/Users/rhodes/projects/proj0011-plankton-seg/exp0017/pxAF405_dim8bit.ilp').__str__() + + params = { + 'pxmap_threshold': 0.25, + 'pxmap_foreground_channel': 0, + 'segmentation_channel': 0, + 'zmask_zindex': None, + 'patches_channel': 2, + 'zmask_type': 'boxes', + 'zmask_filters': {'area': (1e3, 1e8)}, + 'zmask_expand_box_by': (128, 3), + 'export_pixel_probabilities': True, + 'export_2d_patches_for_training': True, + 'draw_bounding_box_on_2d_patch': True, + 'export_2d_patches_for_annotation': True, + 'export_3d_patches': False, + 'export_annotated_zstack': True, + 'export_patch_masks': True, + 'zmask_clip': 0.01, + 'rgb_overlay_channels': (1, None, None), + 'rgb_overlay_weights': (0.2, 1.0, 1.0), + 'draw_label_on_zstack': True, + } + + input_files = get_matching_files(where_czi, 'czi', coord_filter={}) + + loop_workflow( + input_files, + where_output, + export_patches_from_multichannel_zstack, + [IlastikPixelClassifierModel(params={'project_file': Path(px_ilp)})], + params, + catch_and_continue=False, + ) + + csv_path = (Path(where_output) / 'workflow_data.csv').__str__() + write_ecotaxa_tsv(csv_path, where_output, sample_id=sample_id, scope_id='EMBL-MS-Zeiss-LSM900') + + print('Finished') \ No newline at end of file