# HG changeset patch
# User imgteam
# Date 1744470329 0
# Node ID 73d7a4ffc03d3da5a5c409396207330cc6480739
# Parent 6b42bec75e69c333d0250fd4e7e966ff56656556
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/split_image/ commit 6152e9fafda27f76c1e96e533143f86fe605e2da
diff -r 6b42bec75e69 -r 73d7a4ffc03d split.py
--- a/split.py Fri Mar 07 08:08:05 2025 +0000
+++ b/split.py Sat Apr 12 15:05:29 2025 +0000
@@ -18,7 +18,7 @@
assert len(args.axis) == 1, 'Axis input must be a single character.'
axis = args.axis.replace('S', 'C')
-# Read input image as TZYXC
+# Read input image with normalized axes
img_in = giatools.Image.read(args.input)
# Determine the axis to split along
@@ -31,14 +31,24 @@
for img_idx, img in enumerate(arr):
img = np.moveaxis(img[None], 0, axis_pos)
+ # Construct the output image, remove axes added by normalization
+ img_out = giatools.Image(
+ data=img,
+ axes=img_in.axes,
+ ).squeeze_like(
+ img_in.original_axes,
+ )
+
# Optionally, squeeze the image
if args.squeeze:
- s = [axis_pos for axis_pos in range(len(img_in.axes)) if img.shape[axis_pos] == 1 and img_in.axes[axis_pos] not in 'YX']
- img = np.squeeze(img, axis=tuple(s))
- img_axes = giatools.util.str_without_positions(img_in.axes, s)
- else:
- img_axes = img_in.axes
+ s = [
+ axis_pos for axis_pos in range(len(img_out.axes))
+ if img_out.data.shape[axis_pos] == 1 and img_out.axes[axis_pos] not in 'YX'
+ ]
+ img_out = img_out.squeeze_like(
+ giatools.util.str_without_positions(img_out.axes, s),
+ )
# Save the result
filename = output_filename_pattern % (img_idx + 1)
- tifffile.imwrite(filename, img, metadata=dict(axes=img_axes))
+ tifffile.imwrite(filename, img_out.data, metadata=dict(axes=img_out.axes))
diff -r 6b42bec75e69 -r 73d7a4ffc03d split_image.xml
--- a/split_image.xml Fri Mar 07 08:08:05 2025 +0000
+++ b/split_image.xml Sat Apr 12 15:05:29 2025 +0000
@@ -4,7 +4,7 @@
creators.xml
tests.xml
2.2.3
- 0
+ 1
@@ -14,7 +14,7 @@
numpy
- giatools
+ giatools
tifffile
Z-axis (split the slices of a 3-D image or image sequence)
+
@@ -68,6 +69,15 @@
+
+
+
+
+
+
+
+
+
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/qyx.tiff
Binary file test-data/qyx.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/qyx_q1.tiff
Binary file test-data/qyx_q1.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/qyx_q2.tiff
Binary file test-data/qyx_q2.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/rgb1_b.tiff
Binary file test-data/rgb1_b.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/rgb1_g.tiff
Binary file test-data/rgb1_g.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/rgb1_r.tiff
Binary file test-data/rgb1_r.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/rgb1_split_z.tiff
Binary file test-data/rgb1_split_z.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/rgb1_squeezed_b.tiff
Binary file test-data/rgb1_squeezed_b.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/rgb1_squeezed_g.tiff
Binary file test-data/rgb1_squeezed_g.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/rgb1_squeezed_r.tiff
Binary file test-data/rgb1_squeezed_r.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/zcyx_slice01.tiff
Binary file test-data/zcyx_slice01.tiff has changed
diff -r 6b42bec75e69 -r 73d7a4ffc03d test-data/zcyx_slice25.tiff
Binary file test-data/zcyx_slice25.tiff has changed