Skip to content

Commit 23df15c

Browse files
Fix more issues in tif writer
1 parent 84742d9 commit 23df15c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

bioimageio/core/build_spec/build_model.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,20 +414,20 @@ def _write_sample_data(input_paths, output_paths, input_axes, output_axes, pixel
414414
def write_im(path, im, axes, pixel_size=None):
415415
assert tifffile is not None, "need tifffile for writing deepimagej config"
416416
assert len(axes) == im.ndim, f"{len(axes), {im.ndim}}"
417-
assert im.ndim in (4, 5)
417+
assert im.ndim in (4, 5), f"{im.ndim}"
418418

419419
# convert the image to expects (Z)CYX axis order
420-
if im.ndim == 3:
421-
assert set(axes) == {"b", "x", "y", "c"}
420+
if im.ndim == 4:
421+
assert set(axes) == {"b", "x", "y", "c"}, f"{axes}"
422422
axes_ij = "cyxb"
423423
else:
424-
assert set(axes) == {"b", "x", "y", "z", "c"}
424+
assert set(axes) == {"b", "x", "y", "z", "c"}, f"{axes}"
425425
axes_ij = "zcyxb"
426426

427427
axis_permutation = tuple(axes.index(ax) for ax in axes_ij)
428428
im = im.transpose(axis_permutation)
429429
# expand to TZCYXS
430-
if len(axes_ij) == 2: # add singleton t and z axis
430+
if len(axes_ij) == 4: # add singleton t and z axis
431431
im = im[None, None]
432432
else: # add singeton z axis
433433
im = im[None]
@@ -823,10 +823,8 @@ def build_model(
823823
# add the deepimagej config if specified
824824
if add_deepimagej_config:
825825
if sample_inputs is None:
826-
input_axes_ij = [inp.axes[1:] for inp in inputs]
827-
output_axes_ij = [out.axes[1:] for out in outputs]
828826
sample_inputs, sample_outputs = _write_sample_data(
829-
test_inputs, test_outputs, input_axes_ij, output_axes_ij, pixel_sizes, root
827+
test_inputs, test_outputs, input_axes, output_axes, pixel_sizes, root
830828
)
831829
# deepimagej expect tifs as sample data
832830
assert all(os.path.splitext(path)[1] in (".tif", ".tiff") for path in sample_inputs)

0 commit comments

Comments
 (0)