# HG changeset patch
# User imgteam
# Date 1772818318 0
# Node ID 8229f7f69d08d658b4553d323406b51005ef7397
# Parent 48fa3ac55df23e48114c244c887c020a298b7db2
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/image_math commit cddd14dcfe71bb7a7e77aaf09bd2c5535e1dd643
diff -r 48fa3ac55df2 -r 8229f7f69d08 creators.xml
--- a/creators.xml Wed Apr 24 08:12:29 2024 +0000
+++ b/creators.xml Fri Mar 06 17:31:58 2026 +0000
@@ -5,6 +5,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -19,5 +29,15 @@
-
+
+
+
+
+
+
+
+
+
+
+
diff -r 48fa3ac55df2 -r 8229f7f69d08 image_math.py
--- a/image_math.py Wed Apr 24 08:12:29 2024 +0000
+++ b/image_math.py Fri Mar 06 17:31:58 2026 +0000
@@ -2,9 +2,8 @@
import ast
import operator
-import giatools.io
+import giatools
import numpy as np
-import skimage.io
supported_operators = {
@@ -70,6 +69,7 @@
parser = argparse.ArgumentParser()
parser.add_argument('--expression', type=str, required=True)
+ parser.add_argument('--dtype', type=str, default=None)
parser.add_argument('--output', type=str, required=True)
parser.add_argument('--input', default=list(), action='append', required=True)
args = parser.parse_args()
@@ -78,9 +78,9 @@
im_shape = None
for input in args.input:
name, filepath = input.split(':')
- im = giatools.io.imread(filepath)
+ im = giatools.Image.read(filepath)
assert name not in inputs, 'Input name "{name}" is ambiguous.'
- inputs[name] = im
+ inputs[name] = im.data
if im_shape is None:
im_shape = im.shape
else:
@@ -88,4 +88,16 @@
result = eval_expression(args.expression, inputs)
- skimage.io.imsave(args.output, result)
+ # Perform explicit `dtype` conversion
+ if args.dtype:
+ if args.dtype.startswith('uint'):
+ result = result.clip(0, np.inf)
+ result = result.astype(args.dtype)
+
+ # Write result image (preserve metadata from last input image)
+ im.data = result
+ im.normalize_axes_like(
+ im.original_axes,
+ ).write(
+ args.output,
+ )
diff -r 48fa3ac55df2 -r 8229f7f69d08 image_math.xml
--- a/image_math.xml Wed Apr 24 08:12:29 2024 +0000
+++ b/image_math.xml Fri Mar 06 17:31:58 2026 +0000
@@ -3,26 +3,32 @@
creators.xml
tests.xml
- 1.26.4
- 2
+ 2.3.5
+ 0
+
operation_3443
numpy
- scikit-image
- giatools
+ giatools
+
+
+
- ^[a-zA-Z0-9-_\*\+ \(\)/]+$
+ ^[a-zA-Z0-9-_\*\+ \(\)/\.]+$
+
+
+
+
+
+
+
+
+
+
+
+
@@ -50,6 +68,14 @@
+
@@ -59,6 +85,14 @@
+
@@ -68,6 +102,15 @@
+
@@ -81,6 +124,15 @@
+
@@ -94,6 +146,14 @@
+
@@ -101,6 +161,24 @@
+
+
+
+
+
+
+
+
+
+
+
diff -r 48fa3ac55df2 -r 8229f7f69d08 test-data/input1_times_2_uint8.tiff
Binary file test-data/input1_times_2_uint8.tiff has changed