From 16f910a791da4f3bb987ac855262edc958ec2612 Mon Sep 17 00:00:00 2001 From: balbasty Date: Fri, 22 Nov 2024 20:29:10 +0000 Subject: [PATCH 1/2] FIX: now works with multi-channel psoct data --- linc_convert/modalities/psoct/_utils.py | 3 ++- linc_convert/modalities/psoct/multi_slice.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/linc_convert/modalities/psoct/_utils.py b/linc_convert/modalities/psoct/_utils.py index ee0d749..8fb391f 100644 --- a/linc_convert/modalities/psoct/_utils.py +++ b/linc_convert/modalities/psoct/_utils.py @@ -156,6 +156,7 @@ def generate_pyramid( "dtype": omz["0"]._dtype, "fill_value": omz["0"]._fill_value, "compressor": omz["0"]._compressor, + "chunks": omz["0"].chunks, } # Select windowing function @@ -190,7 +191,7 @@ def generate_pyramid( print("Compute level", level, "with shape", shape) allshapes.append(shape) - omz.create_dataset(str(level), shape=shape, **opt) + omz.create_dataset(str(level), shape=batch + shape, **opt) # Iterate across `max_load` chunks # (note that these are unrelared to underlying zarr chunks) diff --git a/linc_convert/modalities/psoct/multi_slice.py b/linc_convert/modalities/psoct/multi_slice.py index 745d5b4..484fd46 100644 --- a/linc_convert/modalities/psoct/multi_slice.py +++ b/linc_convert/modalities/psoct/multi_slice.py @@ -262,7 +262,7 @@ def convert( ni = len(inp) nblevels = min( - [int(math.ceil(math.log2(x))) for i, x in enumerate(inp_shape) if i != no_pool] + [int(math.ceil(math.log2(x))) for i, x in enumerate(inp_shape[-3:]) if i != no_pool] ) nblevels = min(nblevels, int(math.ceil(math.log2(max_load)))) nblevels = min(nblevels, max_levels) @@ -291,8 +291,8 @@ def convert( # save current chunk omz["0"][ ..., - k * inp_chunk[0] : k * inp_chunk[0] + loaded_chunk.shape[0], - j * inp_chunk[1] : j * inp_chunk[1] + loaded_chunk.shape[1], + k * inp_chunk[-3] : k * inp_chunk[-3] + loaded_chunk.shape[-2], + j * inp_chunk[-2] : j * inp_chunk[-2] + loaded_chunk.shape[-1], i, ] = loaded_chunk @@ -308,7 +308,7 @@ def convert( ome_unit = to_ome_unit(unit) write_ome_metadata( omz, - axes=["z", "y", "x"], + axes=(["c"] if len(inp_shape) == 4 else []) + ["z", "y", "x"], no_pool=no_pool, space_unit=ome_unit, space_scale=vx, From 1b127f2997b8bc4ce0b0db254e0e36488b642e07 Mon Sep 17 00:00:00 2001 From: balbasty Date: Fri, 22 Nov 2024 20:30:50 +0000 Subject: [PATCH 2/2] style fixes by ruff --- linc_convert/modalities/psoct/multi_slice.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linc_convert/modalities/psoct/multi_slice.py b/linc_convert/modalities/psoct/multi_slice.py index 484fd46..ca787cd 100644 --- a/linc_convert/modalities/psoct/multi_slice.py +++ b/linc_convert/modalities/psoct/multi_slice.py @@ -262,7 +262,11 @@ def convert( ni = len(inp) nblevels = min( - [int(math.ceil(math.log2(x))) for i, x in enumerate(inp_shape[-3:]) if i != no_pool] + [ + int(math.ceil(math.log2(x))) + for i, x in enumerate(inp_shape[-3:]) + if i != no_pool + ] ) nblevels = min(nblevels, int(math.ceil(math.log2(max_load)))) nblevels = min(nblevels, max_levels)