diff --git a/extensions/chaeo/examples/batch_run_patches.py b/extensions/chaeo/examples/batch_run_patches.py index 09d2ee8b2a9eeac137936a603da281a9b91d39dd..0c220d72d99d69392771432cde06a8929d7cdfe2 100644 --- a/extensions/chaeo/examples/batch_run_patches.py +++ b/extensions/chaeo/examples/batch_run_patches.py @@ -1,4 +1,6 @@ from pathlib import Path +import re +from time import localtime, strftime import pandas as pd @@ -10,9 +12,18 @@ if __name__ == '__main__': where_czi = Path( 'z:/rhodes/projects/proj0004-marine-photoactivation/data/exp0038/AutoMic/20230906-163415/Selection' ) + + where_output_root = Path( + 'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0009' + ) + yyyymmdd = strftime('%Y%m%d', localtime()) + idx = 0 + while Path(where_output_root / f'batch-output-{yyyymmdd}-{idx:04d}').exists(): + idx += 1 where_output = Path( - 'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0009/batch_output' + where_output_root / f'batch-output-{yyyymmdd}-{idx:04d}' ) + csv_args = {'mode': 'w', 'header': True} # when creating file px_ilp = Path.home() / 'model-server' / 'ilastik' / 'AF405-bodies_boundaries.ilp' px_model = IlastikPixelClassifierModel( @@ -20,9 +31,15 @@ if __name__ == '__main__': ) for ff in where_czi.iterdir(): + pattern = 'Selection--W([\d]+)--P([\d]+)-T([\d]+)' + ma = re.match(pattern, ff.stem) + print(ff) if not ff.suffix.upper() == '.CZI': continue + if int(ma.groups()[1]) > 10: # skip second half of set + continue + result = export_patches_from_multichannel_zstack( input_zstack_path=where_czi/ff, @@ -33,8 +50,8 @@ if __name__ == '__main__': patches_channel=4, where_output=where_output, mask_type='boxes', - zmask_filters={'area': (1e3, 1e5)}, - zmask_expand_box_by=(128, 3), + zmask_filters={'area': (1e3, 1e8)}, + zmask_expand_box_by=(128, 0), ) # parse and record results @@ -49,4 +66,4 @@ if __name__ == '__main__': write_accessor_data_to_file( where_output / k / (ff.stem + '.tif'), InMemoryDataAccessor(result['interm'][k]) - ) + ) \ No newline at end of file diff --git a/extensions/chaeo/workflows.py b/extensions/chaeo/workflows.py index 3afc7d2604d435c20bfcacd0ab9b0a13d1cde26e..8130414b413876baf026535c69b570e816348dc4 100644 --- a/extensions/chaeo/workflows.py +++ b/extensions/chaeo/workflows.py @@ -66,6 +66,7 @@ def export_patches_from_multichannel_zstack( zmask_meta, prefix=fstem, draw_bounding_box=True, + rescale_clip=0.0, ) ti.click('export_patches')