diff --git a/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py b/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py index da73dcbcfb0eb25360a052079e5bfd31328af8eb..bca4017fa0e80daf7b68b52041d615356e62afd2 100644 --- a/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py +++ b/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py @@ -1,6 +1,7 @@ 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 from model_server.accessors import CziImageFileAccessor, write_accessor_data_to_file, InMemoryDataAccessor from model_server.process import rescale @@ -25,7 +26,7 @@ if __name__ == '__main__': 'batch-output' ) - px_ilp = Path.home() / 'model-server' / 'ilastik' / 'AF405-bodies_boundaries.ilp' + px_ilp = Path('c:/Users/rhodes/projects/proj0011-plankton-seg/exp0016/pxAF405_dim8bit.ilp') params = { 'ilastik_project_file': px_ilp.__str__(), @@ -42,23 +43,36 @@ if __name__ == '__main__': 'export_3d_patches': False, 'export_annotated_zstack': True, 'export_patch_masks': True, + 'rescale_zmask_clip': 0.01, + 'rgb_overlay_channels': (3, None, None), + 'rgb_overlay_weights': (0.5, 1.0, 1.0) } - input_files = get_matching_files(where_czi, 'czi') + # input_files = get_matching_files(where_czi, 'czi', coord_filter={'P': (5, 10)},) + input_files = get_matching_files(where_czi, 'czi', coord_filter={}) + tif_export_params = { 'channel': 0, 'rescale_zmask_clip': 0.01, } + # loop_workflow( + # input_files, + # where_output, + # export_single_channel_tif_from_multichannel_czi, + # tif_export_params, + # catch_and_continue=False, + # export_batch_csvs=False, + # write_intermediate_products=False, + # ) + loop_workflow( input_files, where_output, - export_single_channel_tif_from_multichannel_czi, - tif_export_params, + export_patches_from_multichannel_zstack, + params, catch_and_continue=False, - export_batch_csvs=False, - write_intermediate_products=False, ) print('Finished') \ No newline at end of file diff --git a/extensions/chaeo/workflows.py b/extensions/chaeo/workflows.py index a5cf3f6a4cf0bb2924bd1236e0106bd102497af2..0df8f2a8c5705c9bcb2110bc9a3760e4418b8392 100644 --- a/extensions/chaeo/workflows.py +++ b/extensions/chaeo/workflows.py @@ -35,6 +35,8 @@ def export_patches_from_multichannel_zstack( export_3d_patches=True, export_annotated_zstack=True, export_patch_masks=True, + rgb_overlay_channels=(None, None, None), + rgb_overlay_weights=(1.0, 1.0, 1.0), ) -> Dict: ti = Timer() stack = generate_file_accessor(Path(input_file_path)) @@ -99,13 +101,13 @@ def export_patches_from_multichannel_zstack( make_3d=False, focus_metric='max_sobel', ch_white=patches_channel, - ch_rgb_overlay=(3, None, None), + ch_rgb_overlay=rgb_overlay_channels, draw_bounding_box=False, bounding_box_channel=1, bounding_box_linewidth=2, # draw_contour=True, draw_mask=True, - overlay_gain=(0.1, 1.0, 1.0) + overlay_gain=rgb_overlay_weights, ) df_patches = pd.DataFrame(files) ti.click('export_2d_patches') @@ -117,7 +119,7 @@ def export_patches_from_multichannel_zstack( if export_2d_patches_for_training: files = export_multichannel_patches_from_zstack( Path(output_folder_path) / '2d_patches_training', - stack.get_one_channel_data(4), + stack.get_one_channel_data(patches_channel), zmask_meta, prefix=fstem, rescale_clip=0.001, @@ -127,10 +129,9 @@ def export_patches_from_multichannel_zstack( df_patches = pd.DataFrame(files) ti.click('export_2d_patches') # associate 2d patches, dropping labeled objects that were not exported as patches - df = pd.merge(df, df_patches, left_index=True, right_on='df_index').drop(columns='df_index') + # df = pd.merge(df, df_patches, left_index=True, right_on='df_index').drop(columns='df_index') # prepopulate patch UUID - df['patch_id'] = df.apply(lambda _: uuid4(), axis=1) - + # df['patch_id'] = df.apply(lambda _: uuid4(), axis=1) if export_patch_masks: files = export_patch_masks_from_zstack(