Skip to content
Snippets Groups Projects
proj0004-exp0038-fixed.py 1.49 KiB
from pathlib import Path

from model_server.util import autonumber_new_directory, get_matching_files, loop_workflow
from extensions.chaeo.workflows import export_patches_from_multichannel_zstack
from extensions.ilastik.models import IlastikPixelClassifierModel

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 = {
        'pxmap_threshold': 0.25,
        'pxmap_foreground_channel': 0,
        'segmentation_channel': 0,
        'patches_channel': 4,
        'zmask_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,
        [IlastikPixelClassifierModel(params={'project_file': Path(px_ilp)})],
        params,
        catch_and_continue=False,
    )

    print('Finished')