diff --git a/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py b/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py index f37da1a1e5dc6eac24bd76901e75f98e95c31c30..09cd9b877da546694e7673c6dc954cc2174ed4d5 100644 --- a/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py +++ b/extensions/chaeo/actual_runs/20230805_kristineberg_PA.py @@ -3,6 +3,19 @@ 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 + +def export_single_channel_tif_from_multichannel_czi(files, where_output, channel): + + for czif in files: + in_acc = CziImageFileAccessor(czif) + outf = Path(where_output) / (Path(czif).stem + '.tif') + write_accessor_data_to_file( + outf, + in_acc.get_one_channel_data(channel), + ) + print(f'Wrote file: {outf}') + 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( @@ -17,7 +30,7 @@ if __name__ == '__main__': 'pxmap_threshold': 0.25, 'pixel_class': 0, 'zmask_channel': 0, - 'patches_channel': 4, + 'patches_channel': 2, 'mask_type': 'boxes', 'zmask_filters': {'area': (1e3, 1e8)}, 'zmask_expand_box_by': (128, 3), @@ -31,12 +44,18 @@ if __name__ == '__main__': input_files = get_matching_files(where_czi, 'czi') - loop_workflow( - input_files, - where_output, - export_patches_from_multichannel_zstack, - params, - catch_and_continue=False, - ) + tif_export_params = { + 'channel': 0 + } + + export_single_channel_tif_from_multichannel_czi(input_files, where_output, 0) + + # loop_workflow( + # input_files, + # where_output, + # export_single_channel_tif_from_multichannel_czi, + # tif_export_params, + # catch_and_continue=False, + # ) print('Finished') \ No newline at end of file diff --git a/extensions/chaeo/util.py b/extensions/chaeo/util.py index a713180159bdf7a6b863dabcc5fef4ede4b8caee..88f522f263f869244ecf74278fdd999eef43e076 100644 --- a/extensions/chaeo/util.py +++ b/extensions/chaeo/util.py @@ -26,7 +26,7 @@ def autonumber_new_file(where: str, prefix: str, ext: str) -> str: idx = max(idx, int(ma.groups()[0]) + 1) return f'{prefix}-{idx:04d}.{ext}' -def get_matching_files(where: str, ext: str, coord_filter: dict={}) -> str: +def get_matching_files(where: str, ext: str, coord_filter: dict={}) -> list: files = [] def is_filtered_out(ff): @@ -54,7 +54,7 @@ def loop_workflow(files, where_output, workflow_func, params, failures = [] for ii, ff in enumerate(files): export_kwargs = { - 'input_zstack_path': ff, + 'input_zstack_path': ff, # TODO: use a more generic name for implied args 'where_output': where_output, **params, }