Mercurial > repos > imgteam > imagej2_analyze_particles_binary
diff imagej2_math_jython_script.py @ 2:ae4ae9c5c56c draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 57a0433defa3cbc37ab34fbb0ebcfaeb680db8d5
author | imgteam |
---|---|
date | Sun, 05 Nov 2023 14:25:37 +0000 |
parents | 1dd5396c734a |
children | 862af85a50ec |
line wrap: on
line diff
--- a/imagej2_math_jython_script.py Mon Sep 28 16:59:30 2020 +0000 +++ b/imagej2_math_jython_script.py Sun Nov 05 14:25:37 2023 +0000 @@ -8,11 +8,11 @@ input_file = sys.argv[-7] operation = sys.argv[-6] expression = sys.argv[-5] -if sys.argv[-4] in [None, 'None']: +if sys.argv[-4] in [None, "None"]: bin_constant = None else: bin_constant = int(sys.argv[-4]) -if sys.argv[-3] in [None, 'None']: +if sys.argv[-3] in [None, "None"]: float_constant = None else: float_constant = float(sys.argv[-3]) @@ -36,49 +36,49 @@ image_processor_copy = input_image_plus_copy.getProcessor() bit_depth = image_processor_copy.getBitDepth() -if operation.find('_') > 0: +if operation.find("_") > 0: # Square_Root. - new_operation = operation.replace('_', ' ') -elif operation in ['Square', 'Log', 'Exp', 'Abs', 'Reciprocal']: + new_operation = operation.replace("_", " ") +elif operation in ["Square", "Log", "Exp", "Abs", "Reciprocal"]: # Unfortunately some ImageJ commands require a "..." ending # while others do not. There seems to be no pattern. - new_operation = '%s' % operation + new_operation = "%s" % operation else: - new_operation = '%s...' % operation + new_operation = "%s..." % operation -if operation == 'Macro': +if operation == "Macro": # Apply the macro code to the image via a call to it's # ImageProcessor since this option does not work using # the IJ.run() method. new_expression = expression.lstrip('"').rstrip('"') - options = 'code=%s' % new_expression + options = "code=%s" % new_expression image_processor_copy.applyMacro(new_expression) -elif operation == 'Min': +elif operation == "Min": # Min does not work without using the ImageProcessor. image_processor_copy.min(float_constant) -elif operation == 'Max': +elif operation == "Max": # Max does not work without using the ImageProcessor. image_processor_copy.max(float_constant) -elif operation == 'Abs': +elif operation == "Abs": if bit_depth not in [16, 32]: # Convert the image to 32-bit. IJ.run(input_image_plus_copy, "32-bit", "") IJ.run(input_image_plus_copy, new_operation, "") -elif operation == 'Reciprocal': +elif operation == "Reciprocal": if bit_depth != 32: # Convert the image to 32 bit. IJ.run(input_image_plus_copy, "32-bit", "") IJ.run(input_image_plus_copy, new_operation, "") else: - if operation in ['AND', 'OR', 'XOR']: + if operation in ["AND", "OR", "XOR"]: # Value is a binary number. - options = 'value=%d' % bin_constant - elif operation in ['Log', 'Exp', 'Square', 'Square_Root']: + options = "value=%d" % bin_constant + elif operation in ["Log", "Exp", "Square", "Square_Root"]: # No constant value. - options = '' + options = "" else: # Value is a floating point number. - options = 'value=%.3f' % float_constant + options = "value=%.3f" % float_constant IJ.run(input_image_plus_copy, "%s" % new_operation, "%s" % options) # Save the ImagePlus object as a new image. IJ.saveAs(input_image_plus_copy, output_datatype, tmp_output_path)