def add_object(self, can_remove = True):
     '''Add an object to be measured (plus optional centers)'''
     group = cps.SettingsGroup()
     if can_remove:
         group.append("divider", cps.Divider(line=False))
     group.append("object_name", cps.ObjectNameSubscriber(
             "Select objects to measure", "None",doc="""
             What did you call the objects you want to measure?"""))
     group.append("center_choice", cps.Choice(
             "Object to use as center?", C_ALL,doc="""
             There are three ways to specify the center of the radial measurement:
             <ul>
             <li><i>These objects</i>: Use the centers of these objects for the 
             radial measurement.</li> 
             <li><i>Centers of other objects</i>: Use the centers of other objects
             for the radial measurement.</li>
             <li><i>Edges of other objects</i>: Measure distances from the
             edge of the other object to each pixel outside of the
             centering object. Do not include pixels within the centering
             object in the radial measurement calculations.</li>
             </ul>
             For example, if measuring the radial distribution in a Cell
             object, you can use the center of the Cell objects (<i>These
             objects</i>) or you can use previously identified Nuclei objects as 
             the centers (<i>Other objects</i>)."""))
     group.append("center_object_name", cps.ObjectNameSubscriber(
             "Select objects to use as centers", "None",doc="""<i>(Used only if "other objects" are selected for centers)</i><br>
             Select the object to use as the center, or select <i>None</i> to
             use the input object centers (which is the same as selecting
             <i>These objects</i> for the object centers)."""))
     if can_remove:
         group.append("remover", cps.RemoveSettingButton("", "Remove this object", self.objects, group))
     self.objects.append(group)
Exemple #2
0
    def create_settings(self):
        """Create the settings for the module
        
        Create the settings for the module during initialization.
        """
        self.secondary_objects_name = cps.ObjectNameSubscriber(
            "Select the larger identified objects",
            "None",
            doc="""
            What did you call the larger identified objects?""")

        self.primary_objects_name = cps.ObjectNameSubscriber(
            "Select the smaller identified objects",
            "None",
            doc="""
            What did you call the smaller identified objects?""")

        self.subregion_objects_name = cps.ObjectNameProvider(
            "Name the tertiary objects to be identified",
            "Cytoplasm",
            doc="""
            What do you want to call the new subregions? The new tertiary subregion 
            will consist of the smaller object subtracted from the larger object."""
        )

        self.use_outlines = cps.Binary(
            "Retain outlines of the tertiary objects?", False)

        self.outlines_name = cps.OutlineNameProvider("Name the outline image",
                                                     "CytoplasmOutlines",
                                                     doc="""\
            <i>(Used only if outlines are to be retained for later use in the pipeline)</i><br>
            <p> Enter a name that will allow the outlines to be selected later in the pipeline."""
                                                     )
Exemple #3
0
 def create_settings(self):
     self.obj_or_img = cps.Choice(
         "Compare segmented objects, or foreground/background?", O_ALL)
     self.ground_truth = cps.ImageNameSubscriber(
         "Select the image to be used as the ground truth basis for calculating the amount of overlap",
         "None",
         doc=
         '''This binary (black and white) image is known as the "ground truth" image.  It can be the product of segmentation performed by hand, or
                                                the result of another segmentation algorithm whose results you would like to compare.'''
     )
     self.test_img = cps.ImageNameSubscriber(
         "Select the image to be used to test for overlap",
         "None",
         doc=''' This 
                                             binary (black and white) image is what you will compare with the ground truth image. It is known as the "test image".'''
     )
     self.object_name_GT = cps.ObjectNameSubscriber(
         "Select the objects to be used as the ground truth basis for calculating the amount of overlap",
         "None")
     self.img_obj_found_in_GT = cps.ImageNameSubscriber(
         "Which image did you find these objects in?", "None")
     self.object_name_ID = cps.ObjectNameSubscriber(
         "Select the objects to be tested for overlap against the ground truth",
         "None")
     self.img_obj_found_in_ID = cps.ImageNameSubscriber(
         "Which image did you find these objects in?", "None")
Exemple #4
0
    def create_settings(self):
        self.obj_or_img = cps.Choice(
            "Compare segmented objects, or foreground/background?", O_ALL)

        self.ground_truth = cps.ImageNameSubscriber(
            "Select the image to be used as the ground truth basis for calculating the amount of overlap",
            cps.NONE,
            doc="""
            <i>(Used only when comparing foreground/background)</i> <br>
            This binary (black and white) image is known as the "ground truth" image.  It can be the product of segmentation performed by hand, or
            the result of another segmentation algorithm whose results you would like to compare."""
        )

        self.test_img = cps.ImageNameSubscriber(
            "Select the image to be used to test for overlap",
            cps.NONE,
            doc="""
            <i>(Used only when comparing foreground/background)</i> <br>
            This binary (black and white) image is what you will compare with the ground truth image. It is known as the "test image"."""
        )

        self.object_name_GT = cps.ObjectNameSubscriber(
            "Select the objects to be used as the ground truth basis for calculating the amount of overlap",
            cps.NONE,
            doc="""
            <i>(Used only when comparing segmented objects)</i> <br>
            Choose which set of objects will used as the "ground truth" objects. It can be the product of segmentation performed by hand, or
            the result of another segmentation algorithm whose results you would like to compare. See the <b>Load</b> modules for more details
            on loading objects.""")

        self.img_obj_found_in_GT = cps.ImageNameSubscriber(
            "Select the image used to identify the objects",
            cps.NONE,
            doc="""
            <i>(Used only when comparing segmented objects)</i> <br>
            Choose which image was used to produce these objects. If the objects were produced from other objects or loaded into CellProfiler,
            select "None." """)

        self.object_name_ID = cps.ObjectNameSubscriber(
            "Select the objects to be tested for overlap against the ground truth",
            cps.NONE,
            doc="""
            <i>(Used only when comparing segmented objects)</i> <br>
            This set of objects is what you will compare with the ground truth objects. It is known as the "test object." """
        )

        self.img_obj_found_in_ID = cps.ImageNameSubscriber(
            "Select the image used to find these objects",
            cps.NONE,
            doc="""
            <i>(Used only when comparing segmented objects)</i> <br>
            Choose which image was used to produce these objects. If the objects were produced from other objects or loaded into CellProfiler,
            select "None." """)
    def create_settings(self):
        """Create the settings for the module
        
        Create the settings for the module during initialization.
        """
        self.secondary_objects_name = cps.ObjectNameSubscriber(
            "Select the larger identified objects",
            cps.NONE,
            doc="""
            Select the larger identified objects. This will usually
            be an object previously identified by a <b>IdentifySecondaryObjects</b>
            module.""")

        self.primary_objects_name = cps.ObjectNameSubscriber(
            "Select the smaller identified objects",
            cps.NONE,
            doc="""
            Select the smaller identified objects. This will usually
            be an object previously identified by a <b>IdentifyPrimaryObjects</b>
            module.""")

        self.subregion_objects_name = cps.ObjectNameProvider(
            "Name the tertiary objects to be identified",
            "Cytoplasm",
            doc="""
            Enter a name for the new tertiary objects. The tertiary objects 
            will consist of the smaller object subtracted from the larger object."""
        )

        self.shrink_primary = cps.Binary(
            "Shrink smaller object prior to subtraction?",
            True,
            doc="""
            Select <i>%(YES)s</i> to shrink the smaller object by 1 pixel before subtracting the objects.
            this approach will ensure that there is always a tertiary object produced, even if it is
            only 1 pixel wide.
            <p>Select <i>%(NO)s</i> to subtract the objects directly, which will ensure that no pixels
            are shared between the primary/secondary/tertiary objects and hence measurements for all
            three sets of objects will not use the same pixels multiple times. However, this may result 
            in the creation of objects with no area. Measurements can still be made on such objects, but
            the results will be zero or not-a-number (NaN)</p>""" % globals())

        self.use_outlines = cps.Binary(
            "Retain outlines of the tertiary objects?",
            False,
            doc="""
            %(RETAINING_OUTLINES_HELP)s""" % globals())

        self.outlines_name = cps.OutlineNameProvider("Name the outline image",
                                                     "CytoplasmOutlines",
                                                     doc="""
            %(NAMING_OUTLINES_HELP)s""" % globals())
Exemple #6
0
 def add_image_measurement(self, can_remove = True):
     group = cps.SettingsGroup()
     if can_remove:
         group.append("divider", cps.Divider())
     
     group.append("image_name", cps.ImageNameSubscriber(
         "Select the image to measure",
         cps.NONE, doc = '''
         Choose an image name from the drop-down menu to calculate intensity for that
         image. Use the <i>Add another image</i> button below to add additional images which will be
         measured. You can add the same image multiple times if you want to measure
         the intensity within several different objects.'''))
     
     group.append("wants_objects", cps.Binary(
         "Measure the intensity only from areas enclosed by objects?",
         False, doc = """
         Select <i>%(YES)s</i> to measure only those pixels within an object of choice."""%globals()))
     
     group.append("object_name",cps.ObjectNameSubscriber(
         "Select the input objects",cps.NONE, doc = '''
         <i>(Used only when measuring intensity from area enclosed by objects)</i><br>
         Select the objects that the intensity will be aggregated within. The intensity measurement will be 
         restricted to the pixels within these objects.'''))
     
     if can_remove:
         group.append("remover", cps.RemoveSettingButton("", 
                                                         "Remove this image", self.images, group))
     self.images.append(group)
 def create_settings(self):
     self.object_name = cps.ObjectNameSubscriber(
         "Input objects",
         "None",
         doc="""Enter the name of the objects whose population context is
         to be measured.""")
     self.operation = cps.Choice(
         "Operation",
         choices=(O_POPULATION_DENSITY, O_DISTANCE_TO_EDGE, O_BOTH),
         doc="""Select the measurements you wish to perform. The choices
         are:<br><ul>
         <li><i>%(O_POPULATION_DENSITY)s</i> - calculate the population
         density within a radius from each cell.</li>
         <li><i>%(O_DISTANCE_TO_EDGE)s</i> - calculate the distance of
         each cell from the edge of a binary mask.</li>
         <li><i>%(O_BOTH)s</i> - make both measurements""" % globals())
     self.radius = cps.Integer(
         "Search radius",
         50,
         minval=1,
         doc="""Count all objects within this radius""")
     self.object_diameter = cps.Integer(
         "Object diameter",
         20,
         minval=0,
         doc="""The average diameter of objects in the image. This number
         is used to adjust the area of the image to account for objects
         that would otherwise be excluded because they were touching
         the border.""")
     self.edge_image = cps.ImageNameSubscriber(
         "Edge image",
         doc="""For measuring distance to an edge, this is the reference
         image. Cell distances will be computed to the nearest foreground / 
         background edge in the reference image.""")
    def add_additional_object(self):
        group = cps.SettingsGroup()
        group.append(
            "object_name",
            cps.ObjectNameSubscriber('Select additional object to relabel',
                                     'None'))
        group.append(
            "target_name",
            cps.ObjectNameProvider('Name the relabeled objects',
                                   'FilteredGreen'))

        group.append(
            "wants_outlines",
            cps.Binary('Retain outlines of relabeled objects?', False))

        group.append(
            "outlines_name",
            cps.OutlineNameProvider('Name the outline image',
                                    'OutlinesFilteredGreen'))

        group.append(
            "remover",
            cps.RemoveSettingButton("", "Remove this additional object",
                                    self.additional_objects, group))
        group.append("divider", cps.Divider(line=False))
        self.additional_objects.append(group)
Exemple #9
0
    def create_settings(self):
        #
        # The ImageNameSubscriber "subscribes" to all ImageNameProviders in
        # prior modules. Modules before yours will put images into CellProfiler.
        # The ImageSubscriber gives your user a list of these images
        # which can then be used as inputs in your module.
        #
        self.input_image_name = cps.ImageNameSubscriber(
            # The text to the left of the edit box
            "Input image name:",
            # HTML help that gets displayed when the user presses the
            # help button to the right of the edit box
            doc="""This is the image that the module operates on. You can
            choose any image that is made available by a prior module.
            <br>
            <b>ImageTemplate</b> will do something to this image.
            """)

        #
        # The ObjectNameSubscriber is similar - it will ask the user
        # which object to pick from the list of objects provided by
        # upstream modules.
        #
        self.input_object_name = cps.ObjectNameSubscriber(
            "Input object name",
            doc="""These are the objects that the module operates on.""")
Exemple #10
0
 def __init__(self, index, operation):
     self.__index = index
     self.__operation = operation
     self.__operand_choice = cps.Choice(
         self.operand_choice_text(), MC_ALL,doc="""
         Indicate whether the operand is an image or object measurement.""")
     
     self.__operand_objects = cps.ObjectNameSubscriber(
         self.operand_objects_text(),cps.NONE,doc="""
         Choose the objects you want to measure for this operation.""")
     
     self.__operand_measurement = cps.Measurement(
         self.operand_measurement_text(),
         self.object_fn,doc="""
         Enter the category that was used to create the measurement. You
         will be prompted to add additional information depending on 
         the type of measurement that is requested.""")
     
     self.__multiplicand = cps.Float(
         "Multiply the above operand by",1,doc="""
         Enter the number by which you would like to multiply the above operand.""")
     
     self.__exponent = cps.Float(
         "Raise the power of above operand by",1,doc="""
         Enter the power by which you would like to raise the above operand.""")
Exemple #11
0
 def add_object_cb(self, can_remove=True):
     '''Add an object to the object_groups collection
     
     can_delete - set this to False to keep from showing the "remove"
                  button for objects that must be present.
     '''
     group = cps.SettingsGroup()
     if can_remove:
         group.append("divider", cps.Divider(line=False))
     group.append(
         'object_name',
         cps.ObjectNameSubscriber("Select objects to measure",
                                  "None",
                                  doc="""
                     What did you call the objects whose texture you want to measure? 
                     If you only want to measure the texture 
                     for the image overall, you can remove all objects using the "Remove this object" button. 
                     <p>Objects specified here will have their
                     texture measured against <i>all</i> images specfied above, which
                     may lead to image-object combinations that are unneccesary. If you
                     do not want this behavior, use multiple <b>MeasureTexture</b>
                     modules to specify the particular image-object measures that you want.</p>"""
                                  ))
     if can_remove:
         group.append(
             "remover",
             cps.RemoveSettingButton("", "Remove this object",
                                     self.object_groups, group))
     self.object_groups.append(group)
Exemple #12
0
 def __init__(self):
     self.__spacer = cps.Divider(line=True)
     self.__operand_choice = cps.Choice("Measure the area occupied in a binary image, or in objects?", 
                                        [O_BINARY_IMAGE, O_OBJECTS], doc = """
                                        You can either measure the area occupied by previously-identified 
                                        objects, or the area occupied by the foreground in a binary (black 
                                        and white) image.""")
     self.__operand_objects = cps.ObjectNameSubscriber("Select objects to measure",
                                         "None", doc = """
                                         <i>(Used only if '%(O_OBJECTS)s' are to be measured)</i> <br>
                                         Select the previously identified objects you would like to measure. """%globals())
     self.__should_save_image = cps.Binary("Retain a binary image of the object regions?", 
                                         False, doc="""
                                         <i>(Used only if '%(O_OBJECTS)s' are to be measured)</i><br>
                                         This setting is helpful if you would like to use a binary image 
                                         later in the pipeline, for example in SaveImages.  The image will 
                                         display the object area that you have measured as the foreground 
                                         in white and the background in black. """%globals())
     self.__image_name = cps.ImageNameProvider("Name the output binary image", 
                                         "Stain",doc="""
                                         <i>(Used only if the binary image of the objects is to be retained for later use in the pipeline)</i> <br> 
                                         Specify a name that will allow the binary image of the objects to be selected later in the pipeline.""")
     self.__binary_name = cps.ImageNameSubscriber("Select a binary image to measure", 
                                         "None", doc="""
                                         <i>(Used only if '%(O_BINARY_IMAGE)s' is to be measured)</i><br>
                                         This is a binary image created earlier in the pipeline, 
                                         where you would like to measure the area occupied by the foreground 
                                         in the image."""%globals())
    def create_settings(self):
        """Create the settings for the module
        
        Create the settings for the module during initialization.
        """
        self.secondary_objects_name = cps.ObjectNameSubscriber(
            "Select the larger identified objects",
            "None",
            doc="""
            What did you call the larger identified objects?""")

        self.primary_objects_name = cps.ObjectNameSubscriber(
            "Select the smaller identified objects",
            "None",
            doc="""
            What did you call the smaller identified objects?""")

        self.subregion_objects_name = cps.ObjectNameProvider(
            "Name the tertiary objects to be identified",
            "Cytoplasm",
            doc="""
            What do you want to call the new subregions? The new tertiary subregion 
            will consist of the smaller object subtracted from the larger object."""
        )

        self.shrink_primary = cps.Binary(
            "Shrink smaller object prior to subtraction?",
            True,
            doc="""
            Checking this box will shrink the smaller object by 1 pixel before subtracting the objects.
            this approach will ensure that there is always a tertiary object produced, even if it is
            only 1 pixel wide.
            <p>Unchecking this box will subtract the objects directly, which will ensure that no pixels
            are shared between the primary/secondary/tertiary objects and hence measurements for all
            three sets of objects will not use the same pixels multiple times. However, this may result 
            in the creation of objects with no area. Measurements can still be made on such objects, but
            the results will be zero or not-a-number (NaN)</p>""")

        self.use_outlines = cps.Binary(
            "Retain outlines of the tertiary objects?", False)

        self.outlines_name = cps.OutlineNameProvider("Name the outline image",
                                                     "CytoplasmOutlines",
                                                     doc="""\
            <i>(Used only if outlines are to be retained for later use in the pipeline)</i><br>
            <p> Enter a name that will allow the outlines to be selected later in the pipeline."""
                                                     )
Exemple #14
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 expand or shrink?'''
                                                    )

        self.output_object_name = cps.ObjectNameProvider(
            "Name the output objects",
            "ShrunkenNuclei",
            doc='''
                                    What do you want to call the resulting objects?'''
        )

        self.operation = cps.Choice("Select the operation",
                                    O_ALL,
                                    doc='''
                                    What operation do you want to perform?
                                    <ul>
                                    <li><i>Shrink objects to a point:</i> Remove all pixels but one from filled objects. Thin objects
                                    with holes to loops unless the "fill" option is checked.</li>
                                    <li><i>Expand objects until touching:</i> Expand objects, assigning every pixel in the image to an
                                    object. Background pixels are assigned to the nearest object.</li>
                                    <li><i>Add partial dividing lines between objects:</i> Remove pixels from an object that are adjacent to another
                                    object's pixels unless doing so would change the object's Euler number
                                    (break an object in two, remove the object completely or open a hole in
                                    an object).</li>
                                    <li><i>Shrink objects by a specified number of pixels:</i> Remove pixels around the perimeter of an object unless doing
                                    so would change the object's Euler number (break the object in two, remove the object completely or open
                                    a hole in the object). You can specify the number of times 
                                    perimeter pixels should be removed. Processing stops automatically when there are no more
                                    pixels to remove.</li>
                                    <li><i>Expand objects by a specified number of pixels:</i> Expand each object by adding background pixels adjacent to the
                                    image. You can choose the number of times to expand. Processing stops
                                    automatically if there are no more background pixels.</li>
                                    <li><i>Skeletonize each object:</i> Erode each object to its skeleton.</li>
                                    <li><i>Remove spurs:</i> Remove or reduce the length of spurs in a skeletonized image.
                                    The algorithm reduces spur size by the number of pixels indicated in the
                                    setting <i>Number of pixels by which to expand or shrink</i>.</li> </ul>              
                                    ''')

        self.iterations = cps.Integer(
            "Number of pixels by which to expand or shrink", 1, minval=1)

        self.wants_fill_holes = cps.Binary(
            "Fill holes in objects so that all objects shrink to a single point?",
            False,
            doc=DOC_FILL_HOLES)

        self.wants_outlines = cps.Binary(
            "Retain the outlines of the identified objects for use later in the pipeline (for example, in SaveImages)?",
            False)

        self.outlines_name = cps.OutlineNameProvider("Name the outline image",
                                                     "ShrunkenNucleiOutlines",
                                                     doc="""
                                    <i>(Used only if outlines are to be retained for later use in the pipeline)</i><br>
                                    Choose a name for the outlines of the identified objects that will allow them to be selected as an image later in the pipeline."""
                                                     )
    def add_measurement(self, flag_settings, can_delete=True):
        measurement_settings = flag_settings.measurement_settings

        group = cps.SettingsGroup()
        group.append("divider1", cps.Divider(line=False))
        group.append(
            "source_choice",
            cps.Choice("Flag is based on",
                       S_ALL,
                       doc='''
                <ul>
                <li><i> Whole-image measurement:</i> A per-image measurement, such as intensity or granularity.</li>
                <li><i> Average measurement for all objects in each image:</i> The average of all object measurements in the image.</li>
                <li><i> Measurements for all objects in each image:</i> All the 
                object measurements in an image, without averaging. In other words, if <i>any</i> of the objects meet the criteria, the image will be flagged.</li>
                </ul>'''))
        group.append(
            "object_name",
            cps.ObjectNameSubscriber(
                "Select the object whose measurements will be used to flag",
                "None",
                doc=
                '''<i>(Used only when flag is based on an object measurement)</i><br>What did you call the objects whose measurements you want to use for flagging?'''
            ))

        def object_fn():
            if group.source_choice == S_IMAGE:
                return cpmeas.IMAGE
            return group.object_name.value

        group.append("measurement",
                     cps.Measurement("Which measurement?", object_fn))
        group.append(
            "wants_minimum",
            cps.Binary(
                "Flag images based on low values?",
                True,
                doc=
                '''Images with measurements below this cutoff will be flagged.'''
            ))
        group.append("minimum_value", cps.Float("Minimum value", 0))
        group.append(
            "wants_maximum",
            cps.Binary(
                "Flag images based on high values?",
                True,
                doc=
                '''Images with measurements above this cutoff will be flagged.'''
            ))
        group.append("maximum_value", cps.Float("Maximum value", 1))

        if can_delete:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove this measurement",
                                        measurement_settings, group))

        group.append("divider2", cps.Divider(line=True))
        measurement_settings.append(group)
Exemple #16
0
    def create_settings(self):
        """Create the settings here and set the module name (initialization)
        
        """
        self.source_choice = cps.Choice("Use objects or an image as a mask?",
                                        [IO_OBJECTS, IO_IMAGE],
                                        doc="""
            You can mask an image in two ways:
            <ul>
            <li><i>%(IO_OBJECTS)s</i>: Using objects created by another
            module (for instance <b>IdentifyPrimaryObjects</b>). The module
            will mask out all parts of the image that are not within one
            of the objects (unless you invert the mask).</li>
            <li><i>5(IO_IMAGE)s</i>: 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 <b>ApplyThreshold</b> instead to create a binary
            image and have finer control over the intensity choice.</li>
            </ul>""" % globals())

        self.object_name = cps.ObjectNameSubscriber("Select object for mask",
                                                    cps.NONE,
                                                    doc="""
            <i>(Used only if mask is to be made from objects)</i> <br> 
            Select the objects you would like to use to mask the input image."""
                                                    )

        self.masking_image_name = cps.ImageNameSubscriber(
            "Select image for mask",
            cps.NONE,
            doc="""
            <i>(Used only if mask is to be made from an image)</i> <br> 
            Select the image that you like to use to mask the input image.""")

        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE,
                                                  doc="""
            Select the image that you want to mask.""")

        self.masked_image_name = cps.ImageNameProvider("Name the output image",
                                                       "MaskBlue",
                                                       doc="""
            Enter the name for the output masked image.""")

        self.invert_mask = cps.Binary(
            "Invert the mask?",
            False,
            doc="""This option reverses the foreground/background relationship of
            the mask. 
            <ul>
            <li>If unchecked, the mask will be composed of the foregound 
            (white portion) of the masking image or the area within the masking 
            objects.</li>
            <li>If checked, the mask will instead be composed of the 
            <i>background</i> (black portions) of the masking image or the area 
            <i>outside</i> the masking objects.</li>
            </ul>""")
Exemple #17
0
 def add_object(self, can_delete = True):
     '''Add an object to the object_groups collection'''
     group = cps.SettingsGroup()
     if can_delete:
         group.append("divider", cps.Divider(line=False))
     group.append("object_name", cps.ObjectNameSubscriber('Select an object to measure','None',
                                                         doc = '''What is the name of objects to be measured?'''))
     if can_delete:
         group.append("remover", cps.RemoveSettingButton('', 'Remove this object', self.object_groups, group))
     self.object_groups.append(group)
Exemple #18
0
 def add_objects(self):
     og = cps.SettingsGroup()
     og.append("objects_name", cps.ObjectNameSubscriber(
         "Select objects to measure", "None",
         doc = """Select the objects whose granualarity
         will be measured. You can select objects from prior modules
         that identify objects, such as <b>IdentifyPrimaryObjects</b>. If you only want to measure the granularity 
         for the image overall, you can remove all objects using the "Remove this object" button."""))
     og.append("remover", cps.RemoveSettingButton(
         "", "Remove this object", self.objects, og))
     self.objects.append(og)
 def add_object(self, can_remove = True):
     """Add a slot for another object"""
     group = cps.SettingsGroup()
     if can_remove:
         group.append("divider", cps.Divider(line=False))
     
     group.append("name", cps.ObjectNameSubscriber("Select objects to measure","None",doc="""
                                             What did you call the objects you want to measure?"""))
     if can_remove:
         group.append("remove", cps.RemoveSettingButton("", "Remove this object", self.object_groups, group))
     
     self.object_groups.append(group)
    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)
Exemple #21
0
 def add_object(self, can_remove = True):
     '''Add an object to the object_groups collection
     
     can_delete - set this to False to keep from showing the "remove"
                  button for images that must be present.
     '''
     group = cps.SettingsGroup()
     if can_remove:
         group.append("divider", cps.Divider(line=False))
     group.append("name", cps.ObjectNameSubscriber("Select objects to measure","None", doc = 
                                                       """What did you call the objects whose intensities you want to measure?"""))
     if can_remove:
         group.append("remover", cps.RemoveSettingButton("", "Remove this object", self.objects, group))
     self.objects.append(group)
Exemple #22
0
 def create_settings(self):
     #
     # The ObjectNameSubscriber is aware of all objects published by
     # modules upstream of this one. You use it to let the user choose
     # the objects produced by a prior module.
     #
     self.input_objects_name = cps.ObjectNameSubscriber(
         "Input objects", "Nuclei")
     #
     # The ObjectNamePublisher lets downstream modules know that this
     # module will produce objects with the name entered by the user.
     #
     self.output_objects_name = cps.ObjectNameProvider(
         "Output objects", "Skeletons")
 def add_objects(self, can_delete=True):
     group = cps.SettingsGroup()
     self.objects_to_export.append(group)
     group.append(
         "objects_name",
         cps.ObjectNameSubscriber("Objects name",
                                  value="Nuclei",
                                  doc="""
             This setting lets you choose the objects you want to export.
             <b>ExportToCellH5</b> will write the segmentation of the objects
             to your CellH5 file so that they can be saved and used by other
             applications that support the format.
             """))
     group.append(
         "Remover",
         cps.RemoveSettingButton("Remove the objects above", "Remove",
                                 self.objects_to_export, group))
Exemple #24
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>."""
        )
Exemple #25
0
    def create_settings(self):
        #
        # The ImageNameSubscriber "subscribes" to all ImageNameProviders in
        # prior modules. Modules before yours will put images into CellProfiler.
        # The ImageSubscriber gives your user a list of these images
        # which can then be used as inputs in your module.
        #
        self.input_image_name = cps.ImageNameSubscriber(
            # The text to the left of the edit box
            "Input image name:",
            # HTML help that gets displayed when the user presses the
            # help button to the right of the edit box
            doc="""This is the image that the module operates on. You can
            choose any image that is made available by a prior module.
            <br>
            <b>ImageTemplate</b> will do something to this image.
            """)

        #
        # The ObjectNameSubscriber is similar - it will ask the user
        # which object to pick from the list of objects provided by
        # upstream modules.
        #
        self.input_object_name = cps.ObjectNameSubscriber(
            "Input object name",
            doc="""These are the objects that the module operates on.""")
        #
        # The radial degree is the "N" parameter in the Zernike - how many
        # inflection points there are, radiating out from the center. Higher
        # N means more features and a more detailed description
        #
        # The setting is an integer setting, bounded between 1 and 50.
        # N = 50 generates 1200 features!
        #
        self.radial_degree = cps.Integer(
            "Radial degree",
            10,
            minval=1,
            maxval=50,
            doc="""Calculate all Zernike features up to the given radial
            degree. The Zernike function is parameterized by a radial
            and azimuthal degree. The module will calculate all Zernike
            features for all azimuthal degrees up to and including the
            radial degree you enter here.""")
Exemple #26
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>."""
                                     )
Exemple #27
0
    def create_settings(self):
        self.input_type = cps.Choice("Select the type of input",
                                     [IF_IMAGE, IF_OBJECTS], IF_IMAGE)

        self.image_name = cps.ImageNameSubscriber("Select input images",
                                                  cps.NONE)

        self.objects_name = cps.ObjectNameSubscriber(
            "Select the input objects",
            cps.NONE,
        )

        self.output_name = cps.ImageNameProvider(
            "Input the output image stack name",
            "BinStack",
            doc="""
            Input the output name.
            """ % globals())

        self.main_object_def = cps.Choice(
            "How should the main label be determined?",
            [SEL_MID, SEL_MAXAREA, SEL_PROVIDED],
            SEL_MID,
            doc="""
            The main object can be determined by 3 ways:
            <ul>
            <li> %(SEL_PROVIDED)s: Label provided by metadata or
            manual. <\li>
            <li> %(SEL_MAXAREA)s: Label with the biggest area is assumed to be
            the main label. <\li>
            <li> %(SEL_MID)s: The label closest to the middle of the image is
            considered the main label. <\li>
            <\ul>
            """ % globals())

        self.main_object_id = cps.Text("Indicate the object id",
                                       '1',
                                       doc="""
                Indicates the id from the main object.
                Rightclick to choose a metadata value.
                """ % globals(),
                                       metadata=True)
    def add_image_measurement(self, can_remove=True):
        group = cps.SettingsGroup()
        if can_remove:
            group.append("divider", cps.Divider())

        group.append(
            "image_name",
            cps.ImageNameSubscriber(
                "Select the image to measure",
                "None",
                doc=
                '''What did you call the images whose intensity you want to measure? Choose an image name from the drop-down menu to calculate intensity for that
                                                            image. Use the <i>Add another image</i> button below to add additional images which will be
                                                            measured. You can add the same image multiple times if you want to measure
                                                            the intensity within several different objects.'''
            ))

        group.append(
            "wants_objects",
            cps.Binary(
                "Measure the intensity only from areas enclosed by objects?",
                False,
                doc=
                "Check this option to restrict the pixels being measured to those within the boundaries of an object."
            ))

        group.append(
            "object_name",
            cps.ObjectNameSubscriber(
                "Select the input objects",
                "None",
                doc=
                '''<i>(Used only when measuring intensity from area enclosed by objects)</i><br>What is the name of the objects to use? The intensity measurement will be restricted to within these objects.'''
            ))
        if can_remove:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove this image", self.images,
                                        group))
        self.images.append(group)
Exemple #29
0
    def create_settings(self):
        self.x_object = cps.ObjectNameSubscriber(
            'Select the object to display on the X-axis',
            'None',
            doc='''
                            Choose the name of objects identified by some previous 
                            module (such as <b>IdentifyPrimaryObjects</b> or 
                            <b>IdentifySecondaryObjects</b>) whose measurements are to be displayed on the X-axis.'''
        )

        self.x_axis = cps.Measurement(
            'Select the object measurement to plot on the X-axis',
            self.get_x_object,
            'None',
            doc='''
                            Choose the object measurement made by a previous 
                            module to display on the X-axis.''')

        self.y_object = cps.ObjectNameSubscriber(
            'Select the object to display on the Y-axis',
            'None',
            doc=''' 
                            Choose the name of objects identified by some previous 
                            module (such as <b>IdentifyPrimaryObjects</b> or 
                            <b>IdentifySecondaryObjects</b>) whose measurements are to be displayed on the Y-axis.'''
        )

        self.y_axis = cps.Measurement(
            'Select the object measurement to plot on the Y-axis',
            self.get_y_object,
            'None',
            doc='''
                            Choose the object measurement made by a previous 
                            module to display on the Y-axis.''')

        self.gridsize = cps.Integer('Select the grid size',
                                    100,
                                    1,
                                    1000,
                                    doc='''
                            Enter the number of grid regions you want used on each
                            axis. Increasing the number of grid regions increases the
                            resolution of the plot.''')

        self.xscale = cps.Choice('How should the X-axis be scaled?',
                                 ['linear', 'log'],
                                 None,
                                 doc='''
                            The X-axis can be scaled either with a <i>linear</i> 
                            scale or with a <i>log</i> (base 10) scaling. 
                            <p>Using a log scaling is useful when one of the 
                            measurements being plotted covers a large range of 
                            values; a log scale can bring out features in the 
                            measurements that would not easily be seen if the 
                            measurement is plotted linearly.</p>''')

        self.yscale = cps.Choice('How should the Y-axis be scaled?',
                                 ['linear', 'log'],
                                 None,
                                 doc='''
                            The Y-axis can be scaled either with a <i>linear</i> 
                            scale or with a <i>log</i> (base 10) scaling. 
                            <p>Using a log scaling is useful when one of the 
                            measurements being plotted covers a large range of 
                            values; a log scale can bring out features in the 
                            measurements that would not easily be seen if the 
                            measurement is plotted linearly.</p>''')

        self.bins = cps.Choice('How should the colorbar be scaled?',
                               ['linear', 'log'],
                               None,
                               doc='''
                            The colorbar can be scaled either with a <i>linear</i> 
                            scale or with a <i>log</i> (base 10) scaling.
                            <p>Using a log scaling is useful when one of the 
                            measurements being plotted covers a large range of 
                            values; a log scale can bring out features in the 
                            measurements that would not easily be seen if the 
                            measurement is plotted linearly.''')

        maps = [m for m in matplotlib.cm.datad.keys() if not m.endswith('_r')]
        maps.sort()

        self.colormap = cps.Choice('Select the color map',
                                   maps,
                                   'jet',
                                   doc='''
                            Select the color map for the density plot. See this 
                            <a href="http://www.astro.princeton.edu/~msshin/science/code/matplotlib_cm/">
                            page</a> for pictures of the available colormaps.'''
                                   )

        self.title = cps.Text('Enter a title for the plot, if desired',
                              '',
                              doc='''
                            Enter a title for the plot. If you leave this blank,
                            the title will default 
                            to <i>(cycle N)</i> where <i>N</i> is the current image 
                            cycle being executed.''')
 def create_settings(self):
     self.obj_or_img = cps.Choice(
         "Compare segmented objects, or foreground/background?", O_ALL)
     
     self.ground_truth = cps.ImageNameSubscriber(
         "Select the image to be used as the ground truth basis for calculating the amount of overlap", 
         cps.NONE, doc = """
         <i>(Used only when comparing foreground/background)</i> <br>
         This binary (black and white) image is known as the "ground truth" image.  It can be the product of segmentation performed by hand, or
         the result of another segmentation algorithm whose results you would like to compare.""")
     
     self.test_img = cps.ImageNameSubscriber(
         "Select the image to be used to test for overlap", 
         cps.NONE, doc = """
         <i>(Used only when comparing foreground/background)</i> <br>
         This binary (black and white) image is what you will compare with the ground truth image. It is known as the "test image".""")
     
     self.object_name_GT = cps.ObjectNameSubscriber(
         "Select the objects to be used as the ground truth basis for calculating the amount of overlap", 
         cps.NONE, doc ="""
         <i>(Used only when comparing segmented objects)</i> <br>
         Choose which set of objects will used as the "ground truth" objects. It can be the product of segmentation performed by hand, or
         the result of another segmentation algorithm whose results you would like to compare. See the <b>Load</b> modules for more details
         on loading objects.""")
     
     self.object_name_ID = cps.ObjectNameSubscriber(
         "Select the objects to be tested for overlap against the ground truth", 
         cps.NONE, doc ="""
         <i>(Used only when comparing segmented objects)</i> <br>
         This set of objects is what you will compare with the ground truth objects. It is known as the "test object." """)
     self.wants_emd = cps.Binary(
         "Calculate earth mover's distance?", False,
         doc="""The earth mover's distance computes the shortest distance 
         that would have to be travelled to move each foreground pixel in the
         test image to some foreground pixel in the reference image.
         "Earth mover's" refers to an analogy: the pixels are "earth" that
         has to be moved by some machine at the smallest possible cost.
         <br>
         It would take too much memory and processing time to compute the
         exact earth mover's distance, so <b>CalculateImageOverlap</b>
         chooses representative foreground pixels in each image and
         assigns each foreground pixel to its closest representative. The
         earth mover's distance is then computed for moving the foreground
         pixels associated with each representative in the test image to
         those in the reference image.
         """)
     self.max_points = cps.Integer(
         "Maximum # of points", value=250,
         minval = 100,
         doc = """
         <i>(Used only when computing the earth mover's distance)</i> <br>
         This is the number of representative points that will be taken
         from the foreground of the test image and from the foreground of 
         the reference image using the point selection method (see below).
         """)
     self.decimation_method = cps.Choice(
         "Point selection method",
         choices = [DM_KMEANS, DM_SKEL],
         doc = """
         <i>(Used only when computing the earth mover's distance)</i> <br>
         The point selection setting determines how the
         representative points are chosen. 
         <ul>
         <li><i>%(DM_KMEANS)s:</i> Select to pick representative points using a 
         K-Means clustering technique. The foregrounds of both images are combined 
         and representatives are picked that minimize the distance to the nearest 
         representative. The same representatives are then used for the test and 
         reference images.</li>
         <li><i>%(DM_SKEL)s:</i> Select to skeletonize the image and pick
         points eqidistant along the skeleton. </li>
         </ul>
         <dl>
         <dd><img src="memory:%(PROTIP_RECOMEND_ICON)s">&nbsp;
         <i>%(DM_KMEANS)s</i> is a
         choice that's generally applicable to all images. <i>%(DM_SKEL)s</i>
         is best suited to long, skinny objects such as worms or neurites.</dd>
         </dl>
         """ % globals())
     self.max_distance = cps.Integer(
         "Maximum distance", value=250, minval=1,
         doc = """
         <i>(Used only when computing the earth mover's distance)</i> <br>
         This setting sets an upper bound to the distance penalty
         assessed during the movement calculation. As an example, the score
         for moving 10 pixels from one location to a location that is
         100 pixels away is 10*100, but if the maximum distance were set
         to 50, the score would be 10*50 instead.
         <br>
         The maximum distance should be set to the largest reasonable
         distance that pixels could be expected to move from one image
         to the next.
         """)
     self.penalize_missing = cps.Binary(
         "Penalize missing pixels", value=False,
         doc = """
         <i>(Used only when computing the earth mover's distance)</i> <br>
         If one image has more foreground pixels than the other, the
         earth mover's distance is not well-defined because there is
         no destination for the extra source pixels or vice-versa.
         It's reasonable to assess a penalty for the discrepancy when
         comparing the accuracy of a segmentation because the discrepancy
         represents an error. It's also reasonable to assess no penalty
         if the goal is to compute the cost of movement, for example between
         two frames in a time-lapse movie, because the discrepancy is
         likely caused by noise or artifacts in segmentation.
         
         Set this setting to "Yes" to assess a penalty equal to the
         maximum distance times the absolute difference in number of
         foreground pixels in the two images. Set this setting to "No"
         to assess no penalty.
         """)