# HG changeset patch # User imgteam # Date 1699194077 0 # Node ID bdee06a1bcfa74294f013bcd6461127ed1ba8aa4 # Parent 3272e0439968de7a1214b97c3e915e2cd8e03f08 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 57a0433defa3cbc37ab34fbb0ebcfaeb680db8d5 diff -r 3272e0439968 -r bdee06a1bcfa imagej2_adjust_threshold_binary_jython_script.py --- a/imagej2_adjust_threshold_binary_jython_script.py Mon Sep 28 16:52:29 2020 +0000 +++ b/imagej2_adjust_threshold_binary_jython_script.py Sun Nov 05 14:21:17 2023 +0000 @@ -26,7 +26,11 @@ # Convert image to binary if necessary. if not image_processor_copy.isBinary(): # Convert the image to binary grayscale. - IJ.run(input_image_plus_copy, "Make Binary", "iterations=1 count=1 edm=Overwrite do=Nothing") + IJ.run( + input_image_plus_copy, + "Make Binary", + "iterations=1 count=1 edm=Overwrite do=Nothing", + ) # Set the options. if black_background: method_str = "%s dark" % method diff -r 3272e0439968 -r bdee06a1bcfa imagej2_analyze_particles_binary_jython_script.py --- a/imagej2_analyze_particles_binary_jython_script.py Mon Sep 28 16:52:29 2020 +0000 +++ b/imagej2_analyze_particles_binary_jython_script.py Sun Nov 05 14:21:17 2023 +0000 @@ -3,8 +3,7 @@ from ij import IJ from ij.plugin.filter import Analyzer - -OPTIONS = ['edm=Overwrite', 'iterations=1', 'count=1'] +OPTIONS = ["edm=Overwrite", "iterations=1", "count=1"] # Fiji Jython interpreter implements Python 2.5 which does not # provide support for argparse. @@ -43,24 +42,24 @@ IJ.run(input_image_plus_copy, "Make Binary", "") # Set the options. -options = ['size=%s' % size] -circularity_str = '%.3f-%.3f' % (circularity_min, circularity_max) -options.append('circularity=%s' % circularity_str) -if show.find('_') >= 0: - show_str = '[%s]' % show.replace('_', ' ') +options = ["size=%s" % size] +circularity_str = "%.3f-%.3f" % (circularity_min, circularity_max) +options.append("circularity=%s" % circularity_str) +if show.find("_") >= 0: + show_str = "[%s]" % show.replace("_", " ") else: show_str = show -options.append('show=%s' % show_str) +options.append("show=%s" % show_str) if display_results: - options.append('display') + options.append("display") if not all_results: - options.append('summarize') + options.append("summarize") if exclude_edges: - options.append('exclude') + options.append("exclude") if include_holes: - options.append('include') + options.append("include") # Always run "in_situ". -options.append('in_situ') +options.append("in_situ") # Run the command. IJ.run(input_image_plus_copy, "Analyze Particles...", " ".join(options)) diff -r 3272e0439968 -r bdee06a1bcfa imagej2_analyze_skeleton.xml --- a/imagej2_analyze_skeleton.xml Mon Sep 28 16:52:29 2020 +0000 +++ b/imagej2_analyze_skeleton.xml Sun Nov 05 14:21:17 2023 +0000 @@ -1,8 +1,15 @@ - - + + with ImageJ2 imagej2_macros.xml + + operation_3443 + + + imagej + imagej2 + 0: - output_type_str = 'output=[%s]' % output_type.replace('_', ' ') + options = ["noise=%d" % noise_tolerance] + if output_type.find("_") > 0: + output_type_str = "output=[%s]" % output_type.replace("_", " ") else: - output_type_str = 'output=%s' % output_type + output_type_str = "output=%s" % output_type options.append(output_type_str) if exclude_edge_maxima: - options.append('exclude') + options.append("exclude") if light_background: - options.append('light') + options.append("light") # Run the command. IJ.run(input_image_plus_copy, "Find Maxima...", "%s" % " ".join(options)) results_table = analyzer.getResultsTable() @@ -60,30 +60,32 @@ # may be improperly placed if local maxima are suppressed # by the tolerance. mf = MaximumFinder() - if output_type == 'Single_Points': + if output_type == "Single_Points": output_type_param = mf.SINGLE_POINTS - elif output_type == 'Maxima_Within_Tolerance': + elif output_type == "Maxima_Within_Tolerance": output_type_param = mf.IN_TOLERANCE - elif output_type == 'Segmented_Particles': + elif output_type == "Segmented_Particles": output_type_param = mf.SEGMENTED - elif output_type == 'List': + elif output_type == "List": output_type_param = mf.LIST - elif output_type == 'Count': + elif output_type == "Count": output_type_param = mf.COUNT # Get a new byteProcessor with a normal (uninverted) LUT where # the marked points are set to 255 (Background 0). Pixels outside # of the roi of the input image_processor_copy are not set. No # output image is created for output types POINT_SELECTION, LIST # and COUNT. In these cases findMaxima returns null. - byte_processor = mf.findMaxima(image_processor_copy, - noise_tolerance, - ImageProcessor.NO_THRESHOLD, - output_type_param, - exclude_edge_maxima, - False) + byte_processor = mf.findMaxima( + image_processor_copy, + noise_tolerance, + ImageProcessor.NO_THRESHOLD, + output_type_param, + exclude_edge_maxima, + False, + ) # Invert the image or ROI. byte_processor.invert() - if output_type == 'Segmented_Particles' and not light_background: + if output_type == "Segmented_Particles" and not light_background: # Invert the values in this image's LUT (indexed color model). byte_processor.invertLut() image_plus = ImagePlus("output", byte_processor) diff -r 3272e0439968 -r bdee06a1bcfa imagej2_make_binary_jython_script.py --- a/imagej2_make_binary_jython_script.py Mon Sep 28 16:52:29 2020 +0000 +++ b/imagej2_make_binary_jython_script.py Sun Nov 05 14:21:17 2023 +0000 @@ -8,8 +8,8 @@ input = sys.argv[-7] iterations = int(sys.argv[-6]) count = int(sys.argv[-5]) -black_background = sys.argv[-4] == 'yes' -pad_edges_when_eroding = sys.argv[-3] == 'yes' +black_background = sys.argv[-4] == "yes" +pad_edges_when_eroding = sys.argv[-3] == "yes" tmp_output_path = sys.argv[-2] output_datatype = sys.argv[-1] @@ -21,12 +21,12 @@ image_processor_copy = input_image_plus_copy.getProcessor() # Set binary options. -options = ['edm=Overwrite', 'iterations=%d' % iterations, 'count=%d' % count] +options = ["edm=Overwrite", "iterations=%d" % iterations, "count=%d" % count] if pad_edges_when_eroding: - options.append('pad') + options.append("pad") if black_background: - options.append('black') -options = ' '.join(options) + options.append("black") +options = " ".join(options) IJ.run(input_image_plus_copy, "Options...", options) # Run the command. diff -r 3272e0439968 -r bdee06a1bcfa imagej2_math_jython_script.py --- a/imagej2_math_jython_script.py Mon Sep 28 16:52:29 2020 +0000 +++ b/imagej2_math_jython_script.py Sun Nov 05 14:21:17 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) diff -r 3272e0439968 -r bdee06a1bcfa imagej2_noise_jython_script.py --- a/imagej2_noise_jython_script.py Mon Sep 28 16:52:29 2020 +0000 +++ b/imagej2_noise_jython_script.py Sun Nov 05 14:21:17 2023 +0000 @@ -35,33 +35,51 @@ image_processor_copy = image_plus_copy.getProcessor() # Perform the analysis on the ImagePlus object. -if noise == 'add_noise': +if noise == "add_noise": IJ.run(image_plus_copy, "Add Noise", "") -elif noise == 'add_specified_noise': +elif noise == "add_specified_noise": IJ.run(image_plus_copy, "Add Specified Noise", "standard=&standard_deviation") -elif noise == 'salt_and_pepper': +elif noise == "salt_and_pepper": IJ.run(image_plus_copy, "Salt and Pepper", "") -elif noise == 'despeckle': +elif noise == "despeckle": IJ.run(image_plus_copy, "Despeckle", "") -elif noise == 'remove_outliers': - IJ.run(image_plus_copy, "Remove Outliers", "radius=&radius threshold=&threshold which=&which_outliers") -elif noise == 'remove_nans': +elif noise == "remove_outliers": + IJ.run( + image_plus_copy, + "Remove Outliers", + "radius=&radius threshold=&threshold which=&which_outliers", + ) +elif noise == "remove_nans": IJ.run(image_plus_copy, "Remove NaNs", "") -elif noise == 'rof_denoise': +elif noise == "rof_denoise": IJ.run(image_plus_copy, "ROF Denoise", "") -elif noise == 'randomj': - if randomj == 'randomj_binomial': - IJ.run(image_plus_copy, "RandomJ Binomial", "trials=&trials probability=&probability insertion=&insertion") - elif randomj == 'randomj_exponential': - IJ.run(image_plus_copy, "RandomJ Exponential", "lambda=&lammbda insertion=&insertion") - elif randomj == 'randomj_gamma': +elif noise == "randomj": + if randomj == "randomj_binomial": + IJ.run( + image_plus_copy, + "RandomJ Binomial", + "trials=&trials probability=&probability insertion=&insertion", + ) + elif randomj == "randomj_exponential": + IJ.run( + image_plus_copy, + "RandomJ Exponential", + "lambda=&lammbda insertion=&insertion", + ) + elif randomj == "randomj_gamma": IJ.run(image_plus_copy, "RandomJ Gamma", "order=&order insertion=&insertion") - elif randomj == 'randomj_gaussian': - IJ.run(image_plus_copy, "RandomJ Gaussian", "mean=&mean sigma=&sigma insertion=&insertion") - elif randomj == 'randomj_poisson': + elif randomj == "randomj_gaussian": + IJ.run( + image_plus_copy, + "RandomJ Gaussian", + "mean=&mean sigma=&sigma insertion=&insertion", + ) + elif randomj == "randomj_poisson": IJ.run(image_plus_copy, "RandomJ Poisson", "mean=&mean insertion=&insertion") - elif randomj == 'randomj_uniform': - IJ.run(image_plus_copy, "RandomJ Uniform", "min=&min max=&max insertion=&insertion") + elif randomj == "randomj_uniform": + IJ.run( + image_plus_copy, "RandomJ Uniform", "min=&min max=&max insertion=&insertion" + ) # Save the ImagePlus object as a new image. IJ.saveAs(image_plus_copy, image_datatype, tmp_output_path) diff -r 3272e0439968 -r bdee06a1bcfa imagej2_skeletonize3d_jython_script.py --- a/imagej2_skeletonize3d_jython_script.py Mon Sep 28 16:52:29 2020 +0000 +++ b/imagej2_skeletonize3d_jython_script.py Sun Nov 05 14:21:17 2023 +0000 @@ -6,7 +6,7 @@ # provide support for argparse. error_log = sys.argv[-5] input_file = sys.argv[-4] -black_background = sys.argv[-3] == 'yes' +black_background = sys.argv[-3] == "yes" tmp_output_path = sys.argv[-2] output_datatype = sys.argv[-1] @@ -18,9 +18,9 @@ image_processor_copy = input_image_plus_copy.getProcessor() # Set binary options. -options = ['edm=Overwrite', 'iterations=1', 'count=1'] -if (black_background): - options.append('black') +options = ["edm=Overwrite", "iterations=1", "count=1"] +if black_background: + options.append("black") options = " ".join(options) IJ.run(input_image_plus_copy, "Options...", options) diff -r 3272e0439968 -r bdee06a1bcfa imagej2_watershed_binary_jython_script.py --- a/imagej2_watershed_binary_jython_script.py Mon Sep 28 16:52:29 2020 +0000 +++ b/imagej2_watershed_binary_jython_script.py Sun Nov 05 14:21:17 2023 +0000 @@ -6,7 +6,7 @@ # provide support for argparse. error_log = sys.argv[-5] input = sys.argv[-4] -black_background = sys.argv[-3] == 'yes' +black_background = sys.argv[-3] == "yes" tmp_output_path = sys.argv[-2] output_datatype = sys.argv[-1] @@ -18,9 +18,9 @@ image_processor_copy = input_image_plus_copy.getProcessor() # Set binary options. -options = ['edm=Overwrite', 'iterations=1', 'count=1'] -if (black_background): - options.append('black') +options = ["edm=Overwrite", "iterations=1", "count=1"] +if black_background: + options.append("black") options = " ".join(options) IJ.run(input_image_plus_copy, "Options...", options)