Mercurial > repos > bgruening > cp_mask_image
view mask_image.xml @ 6:667a513e67e4 draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 57a0433defa3cbc37ab34fbb0ebcfaeb680db8d5
author | bgruening |
---|---|
date | Sun, 05 Nov 2023 09:24:38 +0000 |
parents | b178453ea8d1 |
children |
line wrap: on
line source
<tool id="cp_mask_image" name="MaskImage" version="@CP_VERSION@+galaxy@VERSION_SUFFIX@"> <description>with CellProfiler</description> <macros> <import>macros.xml</import> <token name="@VERSION_SUFFIX@">1</token> </macros> <edam_operations> <edam_operation>operation_3443</edam_operation> </edam_operations> <xrefs> <xref type="bio.tools">CellProfiler</xref> <xref type="biii">cellprofiler</xref> </xrefs> <expand macro="py_requirements"/> <expand macro="cmd_modules" /> <configfiles> <inputs name="inputs"/> <configfile name="script_file"> import json import sys import os FOURSPACES=@SPACES@ input_json_path = sys.argv[1] input_pipeline= sys.argv[2] params = json.load(open(input_json_path, "r")) def writemi(): _str = "\nMaskImage:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:3|show_window:False|notes:\\x5B\'Keep only nucleoli inside the nuclei\\'\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count _str += FOURSPACES + "Select the input image:%s\n" % params['input_image'] _str += FOURSPACES + "Name the output image:%s\n" % params['name_output_image'] img_obj = params['con_img_obj']['img_obj'] _str += FOURSPACES + "Use objects or an image as a mask?:%s\n" % params['con_img_obj']['img_obj'] if img_obj == "Objects": _str += FOURSPACES + "Select object for mask:%s\n" % params['con_img_obj']['select_obj'] _str += FOURSPACES + "Select image for mask:None\n" else: _str += FOURSPACES + "Select object for mask:None\n" _str += FOURSPACES + "Select image for mask:%s\n" % params['con_img_obj']['select_img'] _str += FOURSPACES + "Invert the mask?:%s\n" % params['invert_mask'] return _str with open(input_pipeline) as fin: lines = fin.readlines() k, v = lines[4].strip().split(':') module_count = int(v) new_count = module_count + 1 lines[4] = k + ":%d\n" % new_count with open("output.cppipe", "w") as f: f.writelines(lines) f.write(writemi()) f.close() </configfile> </configfiles> <inputs> <expand macro="input_pipeline_param" /> <param name="input_image" label="Enter the name of the input image" type="text"> <expand macro="text_validator" /> </param> <param name="name_output_image" type="text" label="Enter the name of the resulting image"> <expand macro="text_validator" /> </param> <conditional name="con_img_obj"> <param name="img_obj" label="Use objects or an image as a mask?" type="select"> <help> <![CDATA[ You can mask an image in two ways: <br> - Objects: Using objects created by another module (for instance IdentifyPrimaryObjects). The module will mask out all parts of the image that are not within one of the objects (unless you invert the mask). <br> - Image: Using a binary image as the mask, where black portions of the image (false or zero-value pixels) will be masked out. If the image is not binary, the module will use all pixels whose intensity is greater than 0.5 as the mask’s foreground (white area). You can use Threshold instead to create a binary image with finer control over the intensity choice. ]]> </help> <option value="Objects">Objects</option> <option value="Image">Image</option> </param> <when value="Objects"> <param name="select_obj" label="Enter the name objects to mask the input image" type="text"/> </when> <when value="Image"> <param name="select_img" label="Select image for mask" type="text"/> </when> </conditional> <param name="invert_mask" label="Invert the mask?" type="select" display="radio"> <help> <![CDATA[ This option reverses the foreground/background relationship of the mask. <br> - Select "No" to produce the mask from the foreground (white portion) of the masking image or the area within the masking objects. <br> - Select "Yes" to instead produce the mask from the background (black portions) of the masking image or the area outside the masking objects. ]]> </help> <option value="Yes">Yes</option> <option value="No">No</option> </param> </inputs> <outputs> <expand macro="output_pipeline_param" /> </outputs> <tests> <test> <expand macro="test_input_pipeline_param"/> <param name="input_image" value="DNAdarkholes" /> <param name="name_output_image" value="MaskDNAdarkholes" /> <conditional name="con_img_obj"> <param name="img_obj" value="Objects" /> <param name="select_obj" value="Nuclei" /> </conditional> <param name="invert_mask" value="No" /> <expand macro="test_out_file" file="mask_image.cppipe" /> </test> </tests> <help> <![CDATA[ .. class:: infomark **What it does** This tool masks an image so you can use the mask downstream in the pipeline. The masked image is based on the original image and the masking object or image that is selected. If using a masking image, the mask is composed of the foreground (white portions); if using a masking object, the mask is composed of the area within the object. Note that the image created by this tool for further processing downstream is grayscale. If a binary mask is desired in subsequent tools, use the Threshold tool instead of MaskImage. @COMMON_HELP@ ]]> </help> <expand macro="citations" /> </tool>