Skip to content
Snippets Groups Projects
Commit 3eadaa65 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Exposed patch chlorophyl overlay parameters to workflow kwargs

parent d039e57b
No related branches found
No related tags found
No related merge requests found
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
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment