def add_heatmap(self):
     group = cps.SettingsGroup()
     if len(self.heatmaps) > 0:
         group.append("divider", cps.Divider(line=False))
     group.append("image_name", MORDImageNameSubscriber(
         "Image", doc="""
         The heatmap will be displayed with measurements taken using this image.
         The setting will let you choose from among the images you have
         specified in "Select image to measure".
         """))
     group.image_name.set_module(self)
     group.append("object_name", MORDObjectNameSubscriber(
         "Objects to display", doc = """
         The objects to display in the heatmap. You can select any of the
         objects chosen in "Select objects to measure".
         """))
     group.object_name.set_module(self)
     group.append("bin_count", cps.Choice(
         "Number of bins", self.get_bin_count_choices(), 
         choices_fn = self.get_bin_count_choices))
     def get_number_of_bins(module = self, group=group):
         if len(module.bin_counts) == 1:
             return module.bin_counts[0].bin_count.value
         else:
             return int(group.bin_count.value)
     group.get_number_of_bins = get_number_of_bins
     
     group.append("measurement", cps.Choice(
         "Measurement", MEASUREMENT_CHOICES,
         doc="""The measurement to display."""))
     group.append("colormap", cps.Colormap(
         "Color map", 
         doc="""
         The color map setting chooses the color palette that will be
         used to render the different values for your measurement. If you
         choose "gray", the image will label each of the bins with the
         actual image measurement.
         """))
     group.append("wants_to_save_display", cps.Binary(
         "Save display as image?", False,
         doc = """This setting allows you to save the heatmap display as
         an image that can be output using the <b>SaveImages</b> module.
         Choose <i>%(YES)s</i> to save the display or <i>%(NO)s</i> if the
         display is not needed."""%globals()))
     group.append("display_name", cps.ImageNameProvider(
         "Output image name", "Heatmap",
         doc = """
         <i>(Only used if "Save display as image?" is "%(YES)s")</i><br>
         This setting names the heatmap image so that the name you enter
         here can be selected in a later <b>SaveImages</b> or other module.
         """%globals()))
     group.append("remover", cps.RemoveSettingButton(
         "", "Remove this heatmap display", self.heatmaps, group))
     self.heatmaps.append(group)
예제 #2
0
    def create_settings(self):
        self.object_name = cps.ObjectNameSubscriber("Select the input objects",
                                                    "None",
                                                    doc="""
                                What did you call the objects you want to convert to an image?"""
                                                    )

        self.image_name = cps.ImageNameProvider("Name the output image",
                                                "CellImage",
                                                doc="""
                                What do you want to call the resulting image?"""
                                                )

        self.image_mode = cps.Choice("Select the color type",
                                     IM_ALL,
                                     doc="""
                                What colors should the resulting image use? Choose how you would like
                                the objects to appear:
                                <ul>
                                <li><i>Color:</i> Allows you to choose a colormap that will
                                produce jumbled colors for your objects. </li>
                                <li><i>Binary:</i> All object pixels will be assigned 1 and all
                                background pixels will be assigned 0, creating a binary image.</li>
                                <li><i>Grayscale:</i> Gives each object
                                a graylevel pixel intensity value corresponding to its number (also
                                called label), so it usually results in objects on the left side of the
                                image being very dark, progressing toward white on the right side of
                                the image. </li>
                                <li><i>uint16:</i> Assigns each object a different number,
                                from 1 to 65535 (the numbers that you can put in
                                a 16-bit integer) and numbers all pixels in each
                                object with the object's number. This format can
                                be written out as a .mat or .tiff file if you
                                want to process the label matrix image using
                                another program.</li>
                                </ul>
                                You can choose <i>Color</i> with a <i>Gray</i> colormap to produce
                                jumbled gray objects.""")

        self.colormap = cps.Colormap(
            "Select the colormap",
            doc="""<i>(Used only if Color output image selected)</i><br>
                                What do you want the colormap to be? This setting affects how the objects are colored. 
                                You can look up your default colormap under <i>File > Preferences</i>."""
        )
예제 #3
0
    def create_settings(self):
        self.object_name = cps.ObjectNameSubscriber("Select the input objects",
                                                    cps.NONE,
                                                    doc="""
            Choose the name of the objects you want to convert to an image.""")

        self.image_name = cps.ImageNameProvider("Name the output image",
                                                "CellImage",
                                                doc="""
            Enter the name of the resulting image.""")

        self.image_mode = cps.Choice("Select the color format",
                                     IM_ALL,
                                     doc="""
            Select which colors the resulting image should use. You have the following
            options:
            <ul>
            <li><i>%(IM_COLOR)s:</i> Allows you to choose a colormap that will
            produce jumbled colors for your objects. </li>
            <li><i>%(IM_BINARY)s:</i> All object pixels will be assigned 1 and all
            background pixels will be assigned 0, creating a binary image.</li>
            <li><i>%(IM_GRAYSCALE)s:</i> Gives each object
            a graylevel pixel intensity value corresponding to its number (also
            called label), so it usually results in objects on the left side of the
            image being very dark, progressing toward white on the right side of
            the image. </li>
            <li><i>%(IM_UINT16)s:</i> Assigns each object a different number,
            from 1 to 65535 (the numbers that you can put in
            a 16-bit integer) and numbers all pixels in each
            object with the object's number. This format can
            be written out as a .mat or .tiff file if you
            want to process the label matrix image using
            another program.</li>
            </ul>
            You can choose <i>Color</i> with a <i>Gray</i> colormap to produce
            jumbled gray objects.""" % globals())

        self.colormap = cps.Colormap("Select the colormap",
                                     doc="""
            <i>(Used only if Color output image selected)</i><br>
            Choose the colormap to be used, which affects how the objects are colored. 
            You can look up your default colormap under <i>File > Preferences</i>."""
                                     )
    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="""
            <ul>
            <li><i>%(OI_OBJECTS)s</i> displays measurements made on
            objects.</li>
            <li><i>%(OI_IMAGE)s</i> displays a single measurement made
            on an image.</li> 
            </ul>""" % globals())

        self.objects_name = cps.ObjectNameSubscriber(
            "Select the input objects",
            cps.NONE,
            doc="""
            <i>(Used only when displaying object measurements)</i><br>
            Choose the name of objects identified by some previous
            module (such as <b>IdentifyPrimaryObjects</b> or
            <b>IdentifySecondaryObjects</b>).""")

        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.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.""")

        self.color_or_text = cps.Choice(
            "Display mode", [CT_TEXT, CT_COLOR],
            doc="""<i>(Used only when displaying object measurements)</i><br>
            Choose how to display the measurement information. If you choose
            %(CT_TEXT)s, <b>DisplayDataOnImage</b> will display the numeric
            value on top of each object. If you choose %(CT_COLOR)s,
            <b>DisplayDataOnImage</b> 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="""<i>(Used only when displaying object measurements)</i><br>
            This is the color map used as the color gradient for coloring the
            objects by their measurement values.
            """)
        self.text_color = cps.Text("Text color",
                                   "red",
                                   doc="""
            This is the color that will be used when displaying the text.
            There are several different ways by which you can specify the color:<br>
            <ul>
            <li><i>Single letter:</i> "b"=blue, "g"=green, "r"=red, "c"=cyan, "m"=magenta,
            "y"=yellow, "k"=black, "w"=white</li>
            <li><i>Name:</i> You can use any name supported by HTML; a list of colors is shown on
            <a href="http://www.w3schools.com/html/html_colors.asp">this page</a>.
            </li>
            <li><i>RGB code:</i> You can specify the color as a combination of
            the red, green, and blue intensities, for instance, "#FFFF00"
            for yellow; yellow = red("FF") + green("FF") + blue("00"), where <i>FF</i> is
            hexadecimal for 255, the highest intensity. See  
            <a href="http://www.w3schools.com/html/html_colors.asp">this page</a> for a more detailed
            explanation.</li>
            </ul>""")

        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 <b>SaveImages</b>).""")

        self.font_size = cps.Integer("Font size (points)", 10, minval=1)

        self.decimals = cps.Integer("Number of decimals", 2, minval=0)

        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:
            <ul>
            <li><i>%(E_IMAGE)s:</i> Saves the image with the overlaid measurement annotations.</li>
            <li><i>%(E_AXES)s:</i> Adds axes with tick marks and image coordinates.</li>
            <li><i>%(E_FIGURE)s:</i> Adds a title and other decorations.</li></ul>"""
                                               % 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.""")
 def create_settings(self):
     self.object_name = cps.ObjectNameSubscriber(
         'Select objects to measure',cps.NONE, doc = """
         Select the objects whose neighbors you want to measure.""")
     
     self.neighbors_name = cps.ObjectNameSubscriber(
         'Select neighboring objects to measure', cps.NONE,doc = """
         This is the name of the objects that are potential
         neighbors of the above objects. You can find the neighbors
         within the same set of objects by selecting the same objects
         as above.""")
     
     self.distance_method = cps.Choice(
         'Method to determine neighbors',
         D_ALL, D_EXPAND,doc="""
         There are several methods by which to determine whether objects are neighbors:
         <ul>
         <li><i>%(D_ADJACENT)s:</i> In this mode, two objects must have adjacent 
         boundary pixels to be neighbors. </li>
         <li><i>%(D_EXPAND)s:</i> The objects are expanded until all
         pixels on the object boundaries are touching another. Two objects are 
         neighbors if their any of their boundary pixels are adjacent after 
         expansion.</li>
         <li><i>%(D_WITHIN)s:</i> Each object is expanded by 
         the number of pixels you specify. Two objects are  
         neighbors if they have adjacent pixels after expansion. </li>
         </ul>
         
         <p>For <i>%(D_ADJACENT)s</i> and <i>%(D_EXPAND)s</i>, the
         <i>%(M_PERCENT_TOUCHING)s</i> measurement is the percentage of pixels on the boundary 
         of an object that touch adjacent objects. For <i>%(D_WITHIN)s</i>, 
         two objects are touching if their any of their boundary 
         pixels are adjacent after expansion and <i>%(M_PERCENT_TOUCHING)s</i> measures the 
         percentage of boundary pixels of an <i>expanded</i> object that 
         touch adjacent objects.</p>"""%globals())
     
     self.distance = cps.Integer(
         'Neighbor distance', 5,1,doc="""
         <i>(Used only when "%(D_WITHIN)s" is selected)</i> <br>
         The Neighbor distance is the number of pixels that each object is 
         expanded for the neighbor calculation. Expanded objects that touch 
         are considered neighbors."""%globals())
     
     self.wants_count_image = cps.Binary(
         'Retain the image of objects colored by numbers of neighbors?',
         False, doc="""
         An output image showing the input objects 
         colored by numbers of neighbors may be retained. A colormap of your choice shows 
         how many neighbors each object has. The background is set 
         to -1. Objects are colored with an increasing color value 
         corresponding to the number of neighbors, such that objects with no 
         neighbors are given a color corresponding to 0. Use the <b>SaveImages</b>
         module to save this image to a file.""")
     
     self.count_image_name = cps.ImageNameProvider(
         'Name the output image',
         'ObjectNeighborCount', doc = """
         <i>(Used only if the image of objects colored by numbers of neighbors 
         is to be retained for later use in the pipeline)</i> <br> 
         Specify a name 
         that will allow the the image of objects colored by numbers of neighbors 
         to be selected later in the pipeline.""")
     
     self.count_colormap = cps.Colormap(
         'Select colormap', doc = """
         <i>(Used only if the image of objects colored by numbers of neighbors 
         is to be retained for later use in the pipeline)</i> <br>
         Select the colormap to use to color the neighbor number image. All available colormaps can be seen 
         <a href="http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps">here</a>.""")
     
     self.wants_percent_touching_image = cps.Binary(
         'Retain the image of objects colored by percent of touching pixels?',
         False,doc="""
         Select <i>%(YES)s</i> to keep an image of the input objects 
         colored by the percentage of the boundary touching their neighbors.
         A colormap of your choice is used to show the touching percentage of 
         each object. Use the <b>SaveImages</b> module to save this image to a file."""%globals())
     
     self.touching_image_name = cps.ImageNameProvider(
         'Name the output image',
         'PercentTouching', doc = """
         <i>(Used only if the image of objects colored by percent touching 
         is to be retained for later use in the pipeline)</i> <br> 
         Specify a name that will allow the the image of objects colored by percent of touching 
         pixels to be selected later in the pipeline.""")
     
     self.touching_colormap = cps.Colormap(
         'Select a colormap', doc ="""
         <i>(Used only if the image of objects colored by percent touching 
         is to be retained for later use in the pipeline)</i> <br>
         Select the colormap to use to color the percent touching image. All available colormaps can be seen 
         <a href="http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps">here</a>.""")
예제 #6
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 = """
         <ul>
         <li><i>%(OI_OBJECTS)s</i> displays measurements made on
         objects.</li>
         <li><i>%(OI_IMAGE)s</i> displays a single measurement made
         on an image.</li> 
         </ul>"""%globals())
     
     self.objects_name = cps.ObjectNameSubscriber(
         "Select the input objects", cps.NONE, doc = """
         <i>(Used only when displaying object measurements)</i><br>
         Choose the name of objects identified by some previous
         module (such as <b>IdentifyPrimaryObjects</b> or
         <b>IdentifySecondaryObjects</b>).""")
     
     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 = """<i>(Used only when displaying object measurements)</i><br>
         Choose how to display the measurement information. If you choose
         %(CT_TEXT)s, <b>DisplayDataOnImage</b> will display the numeric
         value on top of each object. If you choose %(CT_COLOR)s,
         <b>DisplayDataOnImage</b> 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 = """<i>(Used only when displaying object measurements)</i><br>
         This is the color map used as the color gradient for coloring the
         objects by their measurement values.
         """)        
     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 <b>SaveImages</b>).""")
     
     self.font_size = cps.Integer(
         "Font size (points)", 10, minval=1)
     
     self.decimals = cps.Integer(
         "Number of decimals", 2, minval=0)
     
     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:
         <ul>
         <li><i>%(E_IMAGE)s:</i> Saves the image with the overlaid measurement annotations.</li>
         <li><i>%(E_AXES)s:</i> Adds axes with tick marks and image coordinates.</li>
         <li><i>%(E_FIGURE)s:</i> Adds a title and other decorations.</li></ul>"""%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 = """<i>(Used only when displaying object measurements as a 
         colormap)</i><br>
         <b>DisplayDataOnImage</b> 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. Choose <i>%(CMS_USE_MEASUREMENT_RANGE)s</i> to use
         the full range of colors to get the maximum contrast within the
         image. Choose <i>%(CMS_MANUAL)s</i> to 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 = """<i>(Used only when setting a manual colormap range)</i><br>
         This setting determines the lower and upper bounds of the values
         for the color map.
         """)
예제 #7
0
 def create_settings(self):
     self.object_name = cps.ObjectNameSubscriber('Select objects to measure','None')
     
     self.neighbors_name = cps.ObjectNameSubscriber(
         'Select neighboring objects to measure', 'None',
         doc = """This is the name of the objects that are potential
         neighbors of the above objects. You can find the neighbors
         within the same set of objects by selecting the same objects
         as above.""")
     
     self.distance_method = cps.Choice('Method to determine neighbors',
                                       D_ALL, D_EXPAND,doc="""
         How do you want to determine whether objects are neighbors?
         <ul>
         <li><i>Adjacent</i>: In this mode, two objects must have adjacent 
         boundary pixels to be neighbors. </li>
         <li><i>Expand until adjacent</i>: The objects are expanded until all
         pixels on the object boundaries are touching another. Two objects are 
         neighbors if their any of their boundary pixels are adjacent after 
         expansion.</li>
         <li><i>Within a specified distance</i>: Each object is expanded by 
         the number of pixels you specify. Two objects are  
         neighbors if they have adjacent pixels after expansion. </li>
         </ul>
         
         <p>For <i>Adjacent</i> and <i>Expand until adjacent</i>, the
         PercentTouching measurement is the percentage of pixels on the boundary 
         of an object that touch adjacent objects. For <i>Within a specified 
         distance</i>, two objects are touching if their any of their boundary 
         pixels are adjacent after expansion and PercentTouching measures the 
         percentage of boundary pixels of an <i>expanded</i> object that 
         touch adjacent objects.
         
         <p></p>""")
     
     self.distance = cps.Integer('Neighbor distance',
                                 5,1,doc="""
         <i>(Used only when "Within a specified distance" is selected)</i> <br>
         Within what distance are objects considered neighbors (in pixels)?
         The Neighbor Distance is the number of pixels that each object is 
         expanded for the neighbor calculation. Expanded objects that touch 
         are considered neighbors.""")
     
     self.wants_count_image = cps.Binary('Retain the image of objects colored by numbers of neighbors for use later in the pipeline (for example, in SaveImages)?',
                                         False, doc="""
          An output image showing the input objects 
          colored by numbers of neighbors may be saved. A colormap of your choice shows 
          how many neighbors each object has. The background is set 
          to -1. Objects are colored with an increasing color value 
          corresponding to the number of neighbors, such that objects with no 
          neighbors are given a color corresponding to 0.""")
     
     self.count_image_name = cps.ImageNameProvider('Name the output image',
                                                   'ObjectNeighborCount', 
                                                   doc = """
         <i>(Used only if the image of objects colored by numbers of neighbors 
         is to be retained for later use in the pipeline)</i> <br> Specify a name 
         that will allow the the image of objects colored by numbers of neighbors 
         to be selected later in the pipeline.""")
     
     self.count_colormap = cps.Colormap('Select colormap', doc = """
         <i>(Used only if the image of objects colored by numbers of neighbors 
         is to be retained for later use in the pipeline)</i> <br>
         What colormap do you want to use to color the above image? All available colormaps can be seen 
         <a href="http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps">here</a>.""")
     
     self.wants_percent_touching_image = cps.Binary('Retain the image of objects colored by percent of touching pixels for use later in the pipeline (for example, in SaveImages)?',
                                                    False,doc="""
         An output image may be saved of the image of the input objects 
         colored by the percentage of the boundary touching their neighbors.
         A colormap of your choice is used to show the touching percentage of 
         each object.""")
     
     self.touching_image_name = cps.ImageNameProvider('Name the output image',
                                                      'PercentTouching', 
                                                      doc = """
         <i>(Used only if the image of objects colored by percent touching 
         is to be retained for later use in the pipeline)</i> <br> 
         Specify a name that will allow the the image of objects colored by percent of touching 
         pixels to be selected later in the pipeline.""")
     
     self.touching_colormap = cps.Colormap('Select a colormap', doc ="""
         <i>(Used only if the image of objects colored by percent touching 
         is to be retained for later use in the pipeline)</i> <br>
         What colormap do you want to use to color the above image? All available colormaps can be seen 
         <a href="http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps">here</a>.""")