diff --git a/extensions/chaeo/examples/batch_run_patches.py b/extensions/chaeo/examples/batch_run_patches.py index 2900f060758d7fca2de5723e27ad628394ebd384..52b0149017e454def89354d7737358aac8407512 100644 --- a/extensions/chaeo/examples/batch_run_patches.py +++ b/extensions/chaeo/examples/batch_run_patches.py @@ -47,7 +47,7 @@ if __name__ == '__main__': 'where_output': where_output.__str__(), 'mask_type': 'boxes', 'zmask_filters': {'area': (1e3, 1e8)}, - 'zmask_expand_box_by': (128, 0), + 'zmask_expand_box_by': (128, 3), } result = export_patches_from_multichannel_zstack(**export_kwargs) @@ -65,4 +65,5 @@ if __name__ == '__main__': write_accessor_data_to_file( where_output / k / (ff.stem + '.tif'), InMemoryDataAccessor(result['interm'][k]) - ) \ No newline at end of file + ) + break \ No newline at end of file diff --git a/extensions/chaeo/workflows.py b/extensions/chaeo/workflows.py index 23eab18fc40ff4f2e9898525dde4f543d595764a..85b16d8b811124fd41ac1b0e52e9d77f47785a5d 100644 --- a/extensions/chaeo/workflows.py +++ b/extensions/chaeo/workflows.py @@ -60,6 +60,15 @@ def export_patches_from_multichannel_zstack( ti.click('generate_zmasks') # export patches + import numpy as np + from skimage.filters import gaussian, sobel + + def zs_projector(zs): + sigma = 1.5 + blur = gaussian(sobel(zs), sigma) + argmax = np.argmax(blur, axis=3, keepdims=True) + return np.take_along_axis(zs, argmax, axis=3) + files = export_patches_from_zstack( Path(where_output) / '2d_patches', stack.get_one_channel_data(patches_channel), @@ -67,6 +76,7 @@ def export_patches_from_multichannel_zstack( prefix=fstem, draw_bounding_box=True, rescale_clip=0.0, + projector=zs_projector, ) ti.click('export_patches')