コード例 #1
0
    def add_outline(self, can_remove=True):
        group = cps.SettingsGroup()
        if can_remove:
            group.append("divider", cps.Divider(line=False))

        group.append(
            "outline_choice",
            cps.Choice("Load outlines from an image or objects?",
                       [FROM_OBJECTS, FROM_IMAGES],
                       doc="""
            This setting selects what source the outlines come from:
            <ul>
            <li><i>%(FROM_OBJECTS)s:</i> Create the image directly from the
            objects. This option will improve the functionality of the
            contrast options for this module's interactive display and will
            save memory.</li>
            <li><i>%(FROM_IMAGES)s:</i> Prior versions of <b>OverlayOutlines</b> would only
            display outline images which were optional outputs of the identify
            modules. For legacy pipelines or to continue using the outline
            images instead of objects, choose this option.</li>
            </ul>
            """ % globals()))

        group.append(
            "objects_name",
            cps.ObjectNameSubscriber(
                "Select objects to display",
                cps.NONE,
                doc="""Choose the objects whose outlines you would like
        to display."""))
        group.append(
            "outline_name",
            cps.OutlineNameSubscriber("Select outlines to display",
                                      cps.NONE,
                                      doc="""
            Choose outlines to display, from a previous <b>Identify</b>
            module. Each of the <b>Identify</b> modules has a checkbox that
            determines whether the outlines are saved. If you have checked this,
            you were asked to supply a name for the outline; you
            can then select that name here.
            """))

        default_color = (COLOR_ORDER[len(self.outlines)]
                         if len(self.outlines) < len(COLOR_ORDER) else
                         COLOR_ORDER[0])
        group.append("color", cps.Color("Select outline color", default_color))
        if can_remove:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove this outline",
                                        self.outlines, group))

        self.outlines.append(group)
コード例 #2
0
    def create_settings(self) -> None:
        self.input_mask_name = cps.ObjectNameSubscriber(
            text="Select the input mask", value=cps.NONE, doc="")

        self.padding = cps.Integer(text="Enter padding size (px)",
                                   value=20,
                                   doc="")

        self.output_mask_name = cps.ObjectNameProvider(
            text="Name the output mask",
            value="PaddedMask",
            doc="Enter the name of the output mask",
        )

        self.custom = cps.Binary(text="Use custom settings?",
                                 value="No",
                                 doc="Use custom settings")

        self.divider = cps.Divider(line=True)

        self.image_name = cps.ImageNameSubscriber(
            text="Select image to overlay on",
            value=cps.LEAVE_BLANK,
            doc="""\
Choose the image_name upon which a padded mask constructed from the input_mask is laid.
""",
            can_be_blank=True,
        )

        self.input_mask_color = cps.Color(
            text="Select the input mask color",
            value="red",
            doc="Select the input mask color",
        )

        self.output_mask_color = cps.Color(
            text="Select the output mask color",
            value="blue",
            doc="Select the output mask color",
        )
コード例 #3
0
    def create_settings(self) -> None:
        module_explanation = "Creates a binary mask of the wedge."
        self.set_notes([module_explanation])

        self.wedge_mask_name = cps.ObjectNameProvider(
            text="Name the wedge mask",
            value="WedgeMask",
            doc="Enter the name of the wedge mask.",
        )

        self.image_name = cps.ImageNameProvider(
            text="Select image to overlay on",
            value="None",
            doc="""\
Choose the image_name upon which a wedge mask constructed from the given 
parameters is laid. Can be either RGB or grayscale.
""",
        )

        self.divider = cps.Divider(line=True)

        self.thickness = cps.Float(text="Enter thickness of wedge (um)",
                                   value=400.0,
                                   doc="")

        self.span = cps.Float(text="Enter span of wedge (deg)",
                              value=90.0,
                              doc="")

        self.radial_offset = cps.Float(
            text="Enter radial offset",
            value=0.0,
            doc=
            "Enter offset of the inner edge of wedge from well, in microns.",
        )

        self.angular_offset = cps.Float(
            text="Enter angular offset",
            value=0.0,
            doc="""\
Enter offset of the wedge midline from well midline, in degrees, clockwise positive.
""",
        )

        self.mask_color = cps.Color(
            text="Select wedge fill color",
            value=DEFAULT_MASK_COLOR,
            doc="""\
The wedge is outlined in this color. Only applies when the result of this 
module is visualized.""",
        )
コード例 #4
0
ファイル: graytocolor.py プロジェクト: yage99/CellProfiler
    def add_stack_channel_cb(self, can_remove=True):
        group = cps.SettingsGroup()
        default_color = DEFAULT_COLORS[len(self.stack_channels) %
                                       len(DEFAULT_COLORS)]
        group.append(
            "image_name",
            cps.ImageNameSubscriber(
                "Image name",
                cps.NONE,
                doc="""\
*(Used only if "%(SCHEME_STACK)s" or "%(SCHEME_COMPOSITE)s" is chosen)*

Select the input image to add to the stacked image.
""" % globals(),
            ),
        )
        group.append(
            "color",
            cps.Color(
                "Color",
                default_color,
                doc="""\
*(Used only if "%(SCHEME_COMPOSITE)s" is chosen)*

The color to be assigned to the above image.
""" % globals(),
            ),
        )
        group.append(
            "weight",
            cps.Float(
                "Weight",
                1.0,
                minval=0.5 / 255,
                doc="""\
*(Used only if "%(SCHEME_COMPOSITE)s" is chosen)*

The weighting of the above image relative to the others. The image’s
pixel values are multiplied by this weight before assigning the color.
""" % globals(),
            ),
        )

        if can_remove:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove this image",
                                        self.stack_channels, group),
            )
        self.stack_channels.append(group)
コード例 #5
0
    def create_settings(self):
        """Create your settings by subclassing this function

        create_settings is called at the end of initialization.

        You should create the setting variables for your module here:
            # Ask the user for the input image
            self.image_name = cellprofiler.settings.ImageNameSubscriber(...)
            # Ask the user for the name of the output image
            self.output_image = cellprofiler.settings.ImageNameProvider(...)
            # Ask the user for a parameter
            self.smoothing_size = cellprofiler.settings.Float(...)
        """
        self.objects_or_image = cps.Choice(
            "Display object or image measurements?", [OI_OBJECTS, OI_IMAGE],
            doc="""\
-  *%(OI_OBJECTS)s* displays measurements made on objects.
-  *%(OI_IMAGE)s* displays a single measurement made on an image.
""" % globals())

        self.objects_name = cps.ObjectNameSubscriber(
            "Select the input objects",
            cps.NONE,
            doc="""\
*(Used only when displaying object measurements)*

Choose the name of objects identified by some previous module (such as
**IdentifyPrimaryObjects** or **IdentifySecondaryObjects**).
""")

        def object_fn():
            if self.objects_or_image == OI_OBJECTS:
                return self.objects_name.value
            else:
                return cpmeas.IMAGE

        self.measurement = cps.Measurement("Measurement to display",
                                           object_fn,
                                           doc="""\
Choose the measurement to display. This will be a measurement made by
some previous module on either the whole image (if displaying a single
image measurement) or on the objects you selected.
""")

        self.wants_image = cps.Binary("Display background image?",
                                      True,
                                      doc="""\
Choose whether or not to display the measurements on
a background image. Usually, you will want to see the image
context for the measurements, but it may be useful to save
just the overlay of the text measurements and composite the
overlay image and the original image later. Choose "Yes" to
display the measurements on top of a background image or "No"
to display the measurements on a black background.""")

        self.image_name = cps.ImageNameSubscriber(
            "Select the image on which to display the measurements",
            cps.NONE,
            doc="""\
Choose the image to be displayed behind the measurements.
This can be any image created or loaded by a previous module.
If you have chosen not to display the background image, the image
will only be used to determine the dimensions of the displayed image.""")

        self.color_or_text = cps.Choice("Display mode", [CT_TEXT, CT_COLOR],
                                        doc="""\
*(Used only when displaying object measurements)*

Choose how to display the measurement information. If you choose
%(CT_TEXT)s, **DisplayDataOnImage** will display the numeric value on
top of each object. If you choose %(CT_COLOR)s, **DisplayDataOnImage**
will convert the image to grayscale, if necessary, and display the
portion of the image within each object using a hue that indicates the
measurement value relative to the other objects in the set using the
default color map.
""" % globals())

        self.colormap = cps.Colormap("Color map",
                                     doc="""\
*(Used only when displaying object measurements)*

This is the color map used as the color gradient for coloring the
objects by their measurement values. See `this page`_ for pictures
of the available colormaps.

.. _this page: http://matplotlib.org/users/colormaps.html
            """)
        self.text_color = cps.Color(
            "Text color",
            "red",
            doc=
            """This is the color that will be used when displaying the text."""
        )

        self.display_image = cps.ImageNameProvider(
            "Name the output image that has the measurements displayed",
            "DisplayImage",
            doc="""\
The name that will be given to the image with the measurements
superimposed. You can use this name to refer to the image in subsequent
modules (such as **SaveImages**).
""")

        self.font_size = cps.Integer(
            "Font size (points)",
            10,
            minval=1,
            doc="""Set the font size of the letters to be displayed.""")

        self.decimals = cps.Integer(
            "Number of decimals",
            2,
            minval=0,
            doc=
            """Set how many decimals to be displayed, for example 2 decimals for 0.01; 3 decimals for 0.001."""
        )

        self.saved_image_contents = cps.Choice("Image elements to save",
                                               [E_IMAGE, E_FIGURE, E_AXES],
                                               doc="""\
This setting controls the level of annotation on the image:

-  *%(E_IMAGE)s:* Saves the image with the overlaid measurement
   annotations.
-  *%(E_AXES)s:* Adds axes with tick marks and image coordinates.
-  *%(E_FIGURE)s:* Adds a title and other decorations.
""" % globals())

        self.offset = cps.Integer("Annotation offset (in pixels)",
                                  0,
                                  doc="""\
Add a pixel offset to the measurement. Normally, the text is
placed at the object (or image) center, which can obscure relevant features of
the object. This setting adds a specified offset to the text, in a random
direction.""")

        self.color_map_scale_choice = cps.Choice(
            "Color map scale", [CMS_USE_MEASUREMENT_RANGE, CMS_MANUAL],
            doc="""\
*(Used only when displaying object measurements as a colormap)*

**DisplayDataOnImage** assigns a color to each object’s measurement
value from a colormap when in colormap-mode, mapping the value to a
color along the colormap’s continuum. This mapping has implicit upper
and lower bounds to its range which are the extremes of the colormap.
This setting determines whether the extremes are the minimum and
maximum values of the measurement from among the objects in the
current image or manually-entered extremes.

-  *%(CMS_USE_MEASUREMENT_RANGE)s:* Use the full range of colors to
   get the maximum contrast within the image.
-  *%(CMS_MANUAL)s:* Manually set the upper and lower bounds so that
   images with different maxima and minima can be compared by a uniform
   color mapping.
""" % globals())
        self.color_map_scale = cps.FloatRange("Color map range",
                                              value=(0.0, 1.0),
                                              doc="""\
*(Used only when setting a manual colormap range)*

This setting determines the lower and upper bounds of the values for the
color map.
""")
コード例 #6
0
    def create_settings(self):
        self.orig_image_name = cps.ImageNameSubscriber(
                "Select the input images", cps.NONE, doc="""
            Select the images to display on the web page.""")

        self.wants_thumbnails = cps.Binary(
                "Use thumbnail images?", False, doc="""
            Select <i>%(YES)s</i> to display thumbnail images (small versions of the
            images) on the web page that link to the full images. <br>
            Select <i>%(NO)s</i> to display the full image directly on the web page.
            <p>If you are going to use thumbnails, you will need to load
            them using the <b>Input</b> modules; you can also run a separate
            pipeline prior to this one to create thumbnails from your originals
            using the <b>Resize</b> and <b>SaveImages</b> modules. For some high-content
            screening systems, thumbnail files are automatically created and have
            the text "thumb" in the name.</p>""" % globals())

        self.thumbnail_image_name = cps.ImageNameSubscriber(
                "Select the thumbnail images", cps.NONE, doc="""
            <i>(Used only if using thumbnails)</i><br>
            Select the name of the images to use for thumbnails.""")

        self.web_page_file_name = cps.Text(
                "Webpage file name", "images1",
                metadata=True, doc="""
            Enter the desired file name for the web page. <b>CreateWebPage</b>
            will add the .html extension if no extension is specified.
            If you have metadata associated with your images, you can name the
            file using metadata tags. %(USING_METADATA_TAGS_REF)s<br>
            For instance, if you have metadata tags named "Plate" and
            "Well", you can create separate per-plate, per-well web pages based on
            your metadata by inserting the tags "Plate_Well" to specify the
            name. %(USING_METADATA_HELP_REF)s.""" % globals())

        self.directory_choice = CWPDirectoryPath(
                "Select the folder for the .html file",
                dir_choices=[
                    DIR_SAME, DIR_ABOVE, ABSOLUTE_FOLDER_NAME,
                    DEFAULT_INPUT_FOLDER_NAME, DEFAULT_OUTPUT_FOLDER_NAME,
                    DEFAULT_INPUT_SUBFOLDER_NAME, DEFAULT_OUTPUT_SUBFOLDER_NAME],
                doc="""
            This setting determines how <b>CreateWebPage</b> selects the
            folder for the .html file(s) it creates.
            <ul>
            <li><i>%(DIR_SAME)s</i>: Place the .html file(s) in the same folder as
            the files.</li>
            <li><i>%(DIR_ABOVE)s</i>: Place the .html file(s) in the
            image files' parent folder.</li>
            <li><i>%(ABSOLUTE_FOLDER_NAME)s</i>: Places the .html file(s) in
            a folder of your choosing. <b>CreateWebPage</b> will use absolute
            references for your image URLs if you choose this option.</li>
            <li><i>%(DEFAULT_INPUT_FOLDER_NAME)s</i>: Places the .html file(s)
            in the default input folder.</li>
            <li><i>%(DEFAULT_OUTPUT_FOLDER_NAME)s</i>: Places the .html file(s)
            in the default output folder.</li>
            <li><i>%(DEFAULT_INPUT_SUBFOLDER_NAME)s</i>: Places the .html file(s)
            in a subfolder of the default input folder. You will be prompted
            for the subfolder name after making this choice</li>
            <li><i>%(DEFAULT_OUTPUT_SUBFOLDER_NAME)s</i>: Places the .html file(s)
            in a subfolder of the default input folder. You will be prompted
            for the subfolder name after making this choice</li>
            </ul>""" % globals())

        self.title = cps.Text(
                "Webpage title", "Image", metadata=True, doc="""
            This is the title that appears at the top of the browser
            window. If you have metadata associated with your images, you can name the
            file using metadata tags. %(USING_METADATA_TAGS_REF)sFor instance, if you
            have a metadata tag named "Plate", you can type "Plate: " and then insert
            the metadata tag "Plate" to display the plate metadata item. %(USING_METADATA_HELP_REF)s."""
                                                             % globals())

        self.background_color = cps.Color(
                "Webpage background color", "White", doc="""
            This setting controls the background color for the web page.""")

        self.columns = cps.Integer(
                "Number of columns", 1, minval=1, doc="""
            This setting determines how many images are displayed
            in each row.""")

        self.table_border_width = cps.Integer(
                "Table border width", 1, minval=0, doc="""
            The table border width determines the width of the border
            around the entire grid of displayed images (i.e., the "table" of images)
            and is measured in pixels. This value can be
            set to zero, in which case you will not see the table border.""")

        self.table_border_color = cps.Color(
                "Table border color", "White")

        self.image_spacing = cps.Integer(
                "Image spacing", 1, minval=0, doc="""
            The spacing between images ("table cells"), in pixels.""")

        self.image_border_width = cps.Integer(
                "Image border width", 1, minval=0, doc="""
            The image border width determines the width of
            the border around each image and is measured in pixels.
            This value can be set to zero, in which case you will not see the
            image border.""")

        self.create_new_window = cps.Choice(
                "Open new window when viewing full image?",
                [OPEN_ONCE, OPEN_EACH, OPEN_NO], doc="""
            This controls the behavior of the thumbnail links.
            <ul>
            <li><i>%(OPEN_ONCE)s:</i> Your browser will open a new window
            when you click on the first thumbnail and will display subsequent
            images in the newly opened window. </li>
            <li><i>%(OPEN_EACH)s:</i> The browser will open a new window each time
            you click on a link.</li>
            <li><i>%(OPEN_NO)s:</i> The browser will reuse the current window
            to display the image</li>
            </ul>""" % globals())

        self.wants_zip_file = cps.Binary(
                "Make a ZIP file containing the full-size images?", False, doc="""
            ZIP files are a common archive and data compression file format, making
            it convenient to download all of the images represented on the web page with a single click.
            Select <i>%(YES)s</i> to create a ZIP file that contains all your images,
            compressed to reduce file size.""" % globals())

        self.zipfile_name = cps.Text(
                "Enter the ZIP file name", "Images.zip",
                metadata=True, doc="""
            <i>(Used only if creating a ZIP file)</i><br>
            Specify the name for the ZIP file.""")