Esempio n. 1
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",
            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())
Esempio n. 2
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber(
                "Select the input image", cps.NONE, doc="""
            Choose the name of the image to display in the object
            selection user interface.""")

        self.objects_name = cps.ObjectNameProvider(
                "Name the objects to be identified", "Cells", doc="""
            What do you want to call the objects
            that you identify using this module? You can use this name to
            refer to your objects in subsequent modules.""")

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

        self.outlines_name = cps.OutlineNameProvider(
                "Name the outlines", "CellOutlines", doc="""
            %(NAMING_OUTLINES_HELP)s""" % globals())
Esempio n. 3
0
    def add_file(self, can_remove=True):
        """Add settings for another file to the list"""
        group = cps.SettingsGroup()
        if can_remove:
            group.append("divider", cps.Divider(line=False))

        def get_directory_fn():
            return self.directory.get_absolute_path()

        group.append(
            "file_name",
            cps.FilenameText(
                FILE_TEXT,
                cps.NONE,
                metadata=True,
                get_directory_fn=get_directory_fn,
                exts=[("TIF - Tagged Image File format (*.tif,*.tiff)",
                       "*.tif;*.tiff"),
                      ("PNG - Portable Network Graphics (*.png)", "*.png"),
                      ("JPG/JPEG file (*.jpg,*.jpeg)", "*.jpg,*.jpeg"),
                      ("BMP - Windows Bitmap (*.bmp)", "*.bmp"),
                      ("Compuserve GIF file (*.gif)", "*.gif"),
                      ("MATLAB image (*.mat)", "*.mat"),
                      ("NumPy array (*.npy)", "*.npy"),
                      ("All files (*.*)", "*.*")],
                doc="""\
The filename can be constructed in one of two ways:

-  As a fixed filename (e.g., *Exp1\_D03f00d0.tif*).
-  Using the metadata associated with an image set in **LoadImages** or
   **LoadData**. This is especially useful if you want your output given
   a unique label according to the metadata corresponding to an image
   group. The name of the metadata to substitute is included in a
   special tag format embedded in your file specification.

{USING_METADATA_TAGS_REF}

{USING_METADATA_HELP_REF}

Keep in mind that in either case, the image file extension, if any, must
be included.
""".format(
                    **{
                        "USING_METADATA_TAGS_REF": USING_METADATA_TAGS_REF,
                        "USING_METADATA_HELP_REF": USING_METADATA_HELP_REF
                    })))

        group.append(
            "image_objects_choice",
            cps.Choice('Load as images or objects?',
                       IO_ALL,
                       doc="""\
This setting determines whether you load an image as image data or as
segmentation results (i.e., objects):

-  *{IO_IMAGES}:* The input image will be given the name you specify, by
   which it will be referred downstream. This is the most common usage
   for this module.
-  *{IO_OBJECTS}:* Use this option if the input image is a label matrix
   and you want to obtain the objects that it defines. A *label matrix*
   is a grayscale or color image in which the connected regions share
   the same label, and defines how objects are represented in
   CellProfiler. The labels are integer values greater than or equal to
   0. The elements equal to 0 are the background, whereas the elements
   equal to 1 make up one object, the elements equal to 2 make up a
   second object, and so on. This option allows you to use the objects
   without needing to insert an **Identify** module to extract them
   first. See **IdentifyPrimaryObjects** for more details.
""".format(**{
                           "IO_IMAGES": IO_IMAGES,
                           "IO_OBJECTS": IO_OBJECTS
                       })))

        group.append(
            "image_name",
            cps.FileImageNameProvider("Name the image that will be loaded",
                                      "OrigBlue",
                                      doc="""\
*(Used only if an image is output)*

Enter the name of the image that will be loaded. You can use this name
to select the image in downstream modules.
"""))

        group.append(
            "rescale",
            cps.Binary("Rescale intensities?",
                       True,
                       doc="""\
*(Used only if an image is output)*

This option determines whether image metadata should be used to
rescale the image’s intensities. Some image formats save the maximum
possible intensity value along with the pixel data. For instance, a
microscope might acquire images using a 12-bit A/D converter which
outputs intensity values between zero and 4095, but stores the values
in a field that can take values up to 65535.

Select *{YES}* to rescale the image intensity so that saturated values
are rescaled to 1.0 by dividing all pixels in the image by the maximum
possible intensity value.

Select *{NO}* to ignore the image metadata and rescale the image to 0 –
1.0 by dividing by 255 or 65535, depending on the number of bits used to
store the image.
""".format(**{
                           "NO": NO,
                           "YES": YES
                       })))

        group.append(
            "objects_name",
            cps.ObjectNameProvider('Name this loaded object',
                                   "Nuclei",
                                   doc="""\
*(Used only if objects are output)*

This is the name for the objects loaded from your image
"""))

        group.append(
            "wants_outlines",
            cps.Binary("Retain outlines of loaded objects?",
                       False,
                       doc="""\
*(Used only if objects are output)*

Select *{YES}* if you want to save an image of the outlines of the
loaded objects.
""".format(**{"YES": YES})))

        group.append(
            "outlines_name",
            cps.OutlineNameProvider('Name the outlines',
                                    'NucleiOutlines',
                                    doc="""\
*(Used only if objects are output)*

Enter a name that will allow the outlines to be selected later in the
pipeline.
"""))

        if can_remove:
            group.append(
                "remove",
                cps.RemoveSettingButton("", "Remove this image",
                                        self.file_settings, group))
        self.file_settings.append(group)
Esempio n. 4
0
    def create_settings(self):
        '''Create the settings that control this module'''
        self.object_name = cps.ObjectNameSubscriber(
            "Select objects to be masked",
            cps.NONE,
            doc="""\
Select the objects that will be masked (that is, excluded in whole or in
part based on the other settings in the module). You can choose from any
objects created by a previous object processing module, such as
**IdentifyPrimaryObjects**, **IdentifySecondaryObjects** or
**IdentifyTertiaryObjects**.
""")

        self.remaining_objects = cps.ObjectNameProvider(
            "Name the masked objects",
            "MaskedNuclei",
            doc="""\
Enter a name for the objects that remain after
the masking operation. You can refer to the masked objects in
subsequent modules by this name.
""")

        self.mask_choice = cps.Choice(
            "Mask using a region defined by other objects or by binary image?",
            [MC_OBJECTS, MC_IMAGE],
            doc="""\
You can mask your objects by defining a region using objects you
previously identified in your pipeline (*%(MC_OBJECTS)s*) or by
defining a region based on the white regions in a binary image
(*%(MC_IMAGE)s*).
""" % globals())

        self.masking_objects = cps.ObjectNameSubscriber(
            "Select the masking object",
            cps.NONE,
            doc="""\
Select the objects that will be used to define the masking region. You
can choose from any objects created by a previous object processing
module, such as **IdentifyPrimaryObjects**,
**IdentifySecondaryObjects**, or **IdentifyTertiaryObjects**.
""")

        self.masking_image = cps.ImageNameSubscriber(
            "Select the masking image",
            cps.NONE,
            doc="""\
Select an image that was either loaded or created by a previous module.
The image should be a binary image where the white portion of the image
is the region(s) you will use for masking. Binary images can be loaded
from disk using the **NamesAndTypes** module by selecting “Binary mask”
for the image type. You can also create a binary image from a grayscale
image using **ApplyThreshold**.
""")

        self.wants_inverted_mask = cps.Binary("Invert the mask?",
                                              False,
                                              doc="""\
This option reverses the foreground/background relationship of the mask.

-  Select *%(NO)s* for the mask to be composed of the foregound (white
   portion) of the masking image or the area within the masking objects.
-  Select *%(YES)s* for the mask to instead be composed of the
   *background* (black portions) of the masking image or the area
   *outside* the masking objects.
   """ % globals())

        self.overlap_choice = cps.Choice(
            "Handling of objects that are partially masked",
            [P_MASK, P_KEEP, P_REMOVE, P_REMOVE_PERCENTAGE],
            doc="""
An object might partially overlap the mask region, with pixels both
inside and outside the region. **MaskObjects** can handle this in one
of three ways:

-  *%(P_MASK)s:* Choosing this option will reduce the size of partially
   overlapping objects. The part of the object that overlaps the region
   will be retained. The part of the object that is outside of the
   region will be removed.
-  *%(P_KEEP)s:* If you choose this option, **MaskObjects** will keep
   the whole object if any part of it overlaps the masking region.
-  *%(P_REMOVE)s:* Objects that are partially outside of the masking
   region will be completely removed if you choose this option.
-  *%(P_REMOVE_PERCENTAGE)s:* Determine whether to remove or keep an
   object depending on how much of the object overlaps the masking
   region. **MaskObjects** will keep an object if at least a certain
   fraction (which you enter below) of the object falls within the
   masking region. **MaskObjects** completely removes the object if too
   little of it overlaps the masking region.""" % globals())

        self.overlap_fraction = cps.Float(
            "Fraction of object that must overlap",
            .5,
            minval=0,
            maxval=1,
            doc="""\
*(Used only if removing based on a overlap)*

Specify the minimum fraction of an object that must overlap the masking
region for that object to be retained. For instance, if the fraction is
0.75, then 3/4 of an object must be within the masking region for that
object to be retained.
""")

        self.retain_or_renumber = cps.Choice("Numbering of resulting objects",
                                             [R_RENUMBER, R_RETAIN],
                                             doc="""\
Choose how to number the objects that remain after masking, which
controls how remaining objects are associated with their predecessors:

-  *%(R_RENUMBER)s:* The objects that remain will be renumbered using
   consecutive numbers. This is a good choice if you do not plan to use
   measurements from the original objects; your object measurements for
   the masked objects will not have gaps (where removed objects are
   missing).
-  *%(R_RETAIN)s:*: The original labels for the objects will be
   retained. This allows any measurements you make from the masked
   objects to be directly aligned with measurements you might have made
   of the original, unmasked objects (or objects directly associated
   with them).
""" % globals())

        self.wants_outlines = cps.Binary(
            "Retain outlines of the resulting objects?",
            False,
            doc=RETAINING_OUTLINES_HELP)

        self.outlines_name = cps.OutlineNameProvider("Name the outline image",
                                                     "MaskedOutlines",
                                                     doc=NAMING_OUTLINES_HELP)
Esempio n. 5
0
    def create_settings(self):
        self.objects_name = cps.ObjectNameSubscriber(
            "Select the input objects",
            cps.NONE,
            doc="""
            Select the objects whose object numbers you want to reassign.
            You can use any objects that were created in previous modules, such as
            <b>IdentifyPrimaryObjects</b> or <b>IdentifySecondaryObjects</b>."""
        )

        self.output_objects_name = cps.ObjectNameProvider(
            "Name the new objects",
            "RelabeledNuclei",
            doc="""
            Enter a name for the objects whose numbers have been reassigned.
            You can use this name in subsequent modules that take objects as inputs."""
        )

        self.relabel_option = cps.Choice("Operation",
                                         [OPTION_UNIFY, OPTION_SPLIT],
                                         doc="""
            You can choose one of the following options:
            <ul>
            <li><i>%(OPTION_UNIFY)s:</i> Assign adjacent or nearby objects the same
            label based on certain criteria. It can be useful, for example,
            to merge together touching objects that were incorrectly split into two pieces
            by an <b>Identify</b> module.</li>
            <li><i>%(OPTION_SPLIT)s:</i> Assign a unique number to separate objects
            that currently share the same label. This can occur if you applied certain
            operations with the <b>Morph</b> module to objects.</li>
            </ul>""" % globals())

        self.unify_option = cps.Choice("Unification method",
                                       [UNIFY_DISTANCE, UNIFY_PARENT],
                                       doc="""
            <i>(Used only with the %(OPTION_UNIFY)s option)</i><br>
            You can unify objects in one of two ways:
            <ul>
            <li><i>%(UNIFY_DISTANCE)s: </i> All objects within a certain pixel radius
            from each other will be unified</li>
            <li><i>%(UNIFY_PARENT)s: </i>All objects which share the same parent
            relationship to another object will be unified. This is not be confused
            with using the <b>RelateObjects</b> module, in which the related objects
            remain as individual objects. See <b>RelateObjects</b> for more details.</li>
            </ul>
            """ % globals())

        self.unification_method = cps.Choice("Output object type",
                                             [UM_DISCONNECTED, UM_CONVEX_HULL],
                                             doc="""
            <i>(Used only with the %(UNIFY_PARENT)s unification method)</i>
            <br>
            <b>ReassignObjectNumbers</b> can either unify the child objects
            and keep them disconnected or it can find the smallest convex
            polygon (the convex hull) that encloses all of a parent's child
            objects. The convex hull will be truncated to include only those
            pixels in the parent - in that case it may not truly be convex.
            Choose %(UM_DISCONNECTED)s to leave the children as
            disconnected pieces. Choose %(UM_CONVEX_HULL)s to create an
            output object that is the convex hull around them all.
            """ % globals())

        self.parent_object = cps.Choice("Select the parent object", [cps.NONE],
                                        choices_fn=self.get_parent_choices,
                                        doc="""
            Select the parent object that will be used to
            unify the child objects. Please note the following:
            <ul>
            <li>You must have established a parent-child relationship
            between the objects using a prior <b>RelateObjects</b> module.</li>
            <li>Primary objects and their associated secondary objects are
            already in a one-to-one parent-child relationship, so it makes no
            sense to unify them here.</li>
            </ul>""")

        self.distance_threshold = cps.Integer(
            "Maximum distance within which to unify objects",
            0,
            minval=0,
            doc="""
            <i>(Used only with the %(OPTION_UNIFY)s option and the %(UNIFY_DISTANCE)s method)</i><br>
            Objects that are less than or equal to the distance
            you enter here, in pixels, will be unified. If you choose zero
            (the default), only objects that are touching will be unified.
            Note that <i>%(OPTION_UNIFY)s </i> will not actually connect or bridge
            the two objects by adding any new pixels; it simply assigns the same object number
            to the portions of the object. The new, unified object
            may therefore consist of two or more unconnected components.""" %
            globals())

        self.wants_image = cps.Binary("Unify using a grayscale image?",
                                      False,
                                      doc="""
            <i>(Used only with the %(OPTION_UNIFY)s option)</i><br>
            Select <i>%(YES)s</i> to use the objects' intensity features to determine whether two
            objects should be unified. If you choose to use a grayscale image,
            <i>%(OPTION_UNIFY)s</i> will unify two objects only if they
            are within the distance you have specified <i>and</i> certain criteria about the objects
            within the grayscale image are met.""" % globals())

        self.image_name = cps.ImageNameSubscriber(
            "Select the grayscale image to guide unification",
            cps.NONE,
            doc="""
            <i>(Used only if a grayscale image is to be used as a guide for unification)</i><br>
            Select the name of an image loaded or created by a previous module."""
        )

        self.minimum_intensity_fraction = cps.Float(
            "Minimum intensity fraction",
            .9,
            minval=0,
            maxval=1,
            doc="""
            <i>(Used only if a grayscale image is to be used as a guide for unification)</i><br>
            Select the minimum acceptable intensity fraction. This will be used
            as described for the method you choose in the next setting.""")

        self.where_algorithm = cps.Choice("Method to find object intensity",
                                          [CA_CLOSEST_POINT, CA_CENTROIDS],
                                          doc="""
            <i>(Used only if a grayscale image is to be used as a guide for unification)</i><br>
            You can use one of two methods to determine whether two
            objects should unified, assuming they meet the distance criteria (as specified above):
            <ul>
            <li><i>%(CA_CENTROIDS)s:</i> When the module considers merging two objects,
            this method identifies the centroid of each object,
            records the intensity value of the dimmer of the two centroids,
            multiplies this value by the <i>minimum intensity fraction</i> to generate a threshold,
            and draws a line between the centroids. The method will unify the
            two objects only if the intensity of every point along the line is above
            the threshold. For instance, if the intensity
            of one centroid is 0.75 and the other is 0.50 and the <i>minimum intensity fraction</i>
            has been chosen to be 0.9, all points along the line would need to have an intensity
            of min(0.75, 0.50) * 0.9 = 0.50 * 0.9 = 0.45.<br>
            This method works well for round cells whose maximum intensity
            is in the center of the cell: a single cell that was incorrectly segmented
            into two objects will typically not have a dim line between the centroids
            of the two halves and will be correctly unified.</li>

            <li><i>%(CA_CLOSEST_POINT)s:</i> This method is useful for unifying irregularly shaped cells
            which are connected. It starts by assigning background pixels in the vicinity of the objects to the nearest
            object. Objects are then unified if each object has background pixels that are:
            <ul>
            <li>Within a distance threshold from each object;</li>
            <li>Above the minimum intensity fraction of the nearest object pixel;</li>
            <li>Adjacent to background pixels assigned to a neighboring object.</li>
            </ul>
            An example of a feature that satisfies the above constraints is a line of
            pixels that connect two neighboring objects and is roughly the same intensity
            as the boundary pixels of both (such as an axon connecting two neurons).</li>
            </ul>""" % globals())

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

        self.outlines_name = cps.OutlineNameProvider('Name the outlines',
                                                     'RelabeledNucleiOutlines',
                                                     doc="""
            %(NAMING_OUTLINES_HELP)s""" % globals())
    def create_settings(self):
        self.primary_objects = cps.ObjectNameSubscriber(
            "Select the input objects",
            "Nuclei",
            doc="""
            What did you call the objects you want to use as "seeds" to identify a secondary
            object around each one? By definition, each primary object must be associated with exactly one
            secondary object and completely contained within it.""")

        self.objects_name = cps.ObjectNameProvider(
            "Name the objects to be identified",
            "Cells",
            doc="""
            Enter the name that you want to call the objects identified by this module."""
        )

        self.method = cps.Choice(
            "Select the method to identify the secondary objects", [
                M_PROPAGATION, M_WATERSHED_G, M_WATERSHED_I, M_DISTANCE_N,
                M_DISTANCE_B
            ],
            M_PROPAGATION,
            doc="""
            <p>There are several methods available to find the dividing lines
            between secondary objects which touch each other:
            <ul>
            <li><i>%(M_PROPAGATION)s:</i> This method will find dividing lines
            between clumped objects where the image stained for secondary objects
            shows a change in staining (i.e., either a dimmer or a brighter line).
            Smoother lines work better, but unlike the Watershed method, small gaps
            are tolerated. This method is considered an improvement on the
            traditional <i>Watershed</i> method. The dividing lines between objects are
            determined by a combination of the distance to the nearest primary object
            and intensity gradients. This algorithm uses local image similarity to
            guide the location of boundaries between cells. Boundaries are
            preferentially placed where the image's local appearance changes
            perpendicularly to the boundary (<i>Jones et al, 2005</i>).</li>

            <li><i>%(M_WATERSHED_G)s:</i> This method uses the watershed algorithm
            (<i>Vincent and Soille, 1991</i>) to assign
            pixels to the primary objects which act as seeds for the watershed.
            In this variant, the watershed algorithm operates on the Sobel
            transformed image which computes an intensity gradient. This method
            works best when the image intensity drops off or increases rapidly
            near the boundary between cells.
            </li>
            <li><i>%(M_WATERSHED_I)s:</i> This method is similar to the above,
            but it uses the inverted intensity of the image for the watershed.
            The areas of lowest intensity will form the boundaries between
            cells. This method works best when there is a saddle of relatively
            low intensity at the cell-cell boundary.
            </li>
            <li><i>Distance:</i> In this method, the edges of the primary
            objects are expanded a specified distance to create the secondary
            objects. For example, if nuclei are labeled but there is no stain to help
            locate cell edges, the nuclei can simply be expanded in order to estimate
            the cell's location. This is often called the "doughnut" or "annulus" or
            "ring" approach for identifying the cytoplasm.
            There are two methods that can be used:
            <ul>
            <li><i>%(M_DISTANCE_N)s</i>: In this method, the image of the secondary
            staining is not used at all; the expanded objects are the
            final secondary objects.</li>
            <li><i>%(M_DISTANCE_B)s</i>: Thresholding of the secondary staining image is used to eliminate background
            regions from the secondary objects. This allows the extent of the
            secondary objects to be limited to a certain distance away from the edge
            of the primary objects without including regions of background.</li></ul></li>
            </ul>
            <b>References</b>
            <ul>
            <li>Jones TR, Carpenter AE, Golland P (2005) "Voronoi-Based Segmentation of Cells on Image Manifolds",
            <i>ICCV Workshop on Computer Vision for Biomedical Image Applications</i>, 535-543.
            (<a href="http://www.cellprofiler.org/linked_files/Papers/JonesCVBIA2005.pdf">link</a>)</li>
            <li>(Vincent L, Soille P (1991) "Watersheds in Digital Spaces: An Efficient Algorithm Based on Immersion
            Simulations", <i>IEEE Transactions of Pattern Analysis and Machine
            Intelligence</i>, 13(6): 583-598
            (<a href="http://dx.doi.org/10.1109/34.87344">link</a>)</li>
            </ul>""" % globals())

        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE,
                                                  doc="""
            The selected image will be used to find the edges of the secondary objects.
            For <i>%(M_DISTANCE_N)s</i> this will not affect object identification,
            only the final display.""" % globals())

        self.create_threshold_settings()
        # default smoothing choice is different for idprimary and idsecondary
        self.threshold_smoothing_choice.value = cpmi.TSM_NONE

        self.distance_to_dilate = cps.Integer(
            "Number of pixels by which to expand the primary objects",
            10,
            minval=1)

        self.regularization_factor = cps.Float("Regularization factor",
                                               0.05,
                                               minval=0,
                                               doc="""
            <i>(Used only if %(M_PROPAGATION)s method is selected)</i> <br>
            The regularization factor &lambda; can be anywhere in the range 0 to infinity.
            This method takes two factors into account when deciding where to draw
            the dividing line between two touching secondary objects: the distance to
            the nearest primary object, and the intensity of the secondary object
            image. The regularization factor controls the balance between these two
            considerations:
            <ul>
            <li>A &lambda; value of 0 means that the distance to the nearest
            primary object is ignored and the decision is made entirely on the
            intensity gradient between the two competing primary objects. </li>
            <li>Larger values of &lambda; put more and more weight on the distance between the two objects.
            This relationship is such that small changes in &lambda; will have fairly different
            results (e.,g 0.01 vs 0.001). However, the intensity image is almost completely
            ignored at &lambda; much greater than 1.</li>
            <li>At infinity, the result will look like %(M_DISTANCE_B)s, masked to the
            secondary staining image.</li>
            </ul>""" % globals())

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

        self.outlines_name = cps.OutlineNameProvider('Name the outline image',
                                                     "SecondaryOutlines",
                                                     doc="""
            %(NAMING_OUTLINES_HELP)s""" % globals())

        self.wants_discard_edge = cps.Binary(
            "Discard secondary objects touching the border of the image?",
            False,
            doc="""
            Select <i>%(YES)s</i> to discard secondary objects which touch
            the image border. Select <i>%(NO)s</i> to retain objects regardless
            of whether they touch the image edge or not.
            <p>The objects are discarded
            with respect to downstream measurement modules, but they are retained in memory
            as "unedited objects"; this allows them to be considered in downstream modules that modify the
            segmentation.</p>""" % globals())

        self.fill_holes = cps.Binary("Fill holes in identified objects?",
                                     True,
                                     doc="""
            Select <i>%(YES)s</i> to fill any holes inside objects.""" %
                                     globals())

        self.wants_discard_primary = cps.Binary(
            "Discard the associated primary objects?",
            False,
            doc="""
            <i>(Used only if discarding secondary objects touching the image border)</i> <br>
            It might be appropriate to discard the primary object
            for any secondary object that touches the edge of the image.
            <p>Select <i>%(YES)s</i> to create a new set of objects that are identical
            to the original primary objects set, minus the objects for which the associated
            secondary object touches the image edge.</p>""" % globals())

        self.new_primary_objects_name = cps.ObjectNameProvider(
            "Name the new primary objects",
            "FilteredNuclei",
            doc="""
            <i>(Used only if associated primary objects are discarded)</i> <br>
            You can name the primary objects that remain after the discarding step.
            These objects will all have secondary objects
            that do not touch the edge of the image. Note that any primary object
            whose secondary object touches the edge will be retained in memory as an
            "unedited object"; this allows them to be considered in downstream modules that modify the
            segmentation.""")

        self.wants_primary_outlines = cps.Binary(
            "Retain outlines of the new primary objects?",
            False,
            doc="""
            <i>(Used only if associated primary objects are discarded)</i><br>
            %(RETAINING_OUTLINES_HELP)s""" % globals())

        self.new_primary_outlines_name = cps.OutlineNameProvider(
            "Name the new primary object outlines",
            "FilteredNucleiOutlines",
            doc="""
            <i>(Used only if associated primary objects are discarded and saving outlines of new primary objects)</i><br>
            Enter a name for the outlines of the identified
            objects. The outlined image can be selected in downstream modules by selecting
            them from any drop-down image list.""")
Esempio n. 7
0
    def create_settings(self):
        """Create your settings by subclassing this function

        create_settings is called at the end of initialization.
        """
        self.grid_name = cps.GridNameSubscriber("Select the defined grid",
                                                cps.NONE,
                                                doc="""
            Select the name of a grid created by a previous <b>DefineGrid</b>
            module.""")

        self.output_objects_name = cps.ObjectNameProvider(
            "Name the objects to be identified",
            "Wells",
            doc="""
            Enter the name of the grid objects identified by this module. These objects
            will be available for further measurement and processing in subsequent modules."""
        )

        self.shape_choice = cps.Choice("Select object shapes and locations", [
            SHAPE_RECTANGLE, SHAPE_CIRCLE_FORCED, SHAPE_CIRCLE_NATURAL,
            SHAPE_NATURAL
        ],
                                       doc="""
            Use this setting to choose the method to be used to determine the
            grid objects' shapes and locations:
            <ul>
            <li><i>%(SHAPE_RECTANGLE)s:</i> Each object will be created as a rectangle,
            completely occupying the entire grid compartment (rectangle). This option creates
            the rectangular objects based solely on the grid's specifications,
            not on any previously identified guiding objects.</li>
            <li><i>%(SHAPE_CIRCLE_FORCED)s:</i> Each object will be created as a circle, centered
            in the middle of each grid compartment. This option places
            the circular objects' locations based solely on the grid's specifications,
            not on any previously identified guiding objects. The radius of all circles in a grid
            will be constant for the entire grid in each image cycle, and can
            be determined automatically for each image cycle based on the average radius of previously
            identified guiding objects for that image cycle, or instead it can be specified
            as a single radius for all circles in all grids in the entire analysis run.</li>
            <li><i>%(SHAPE_CIRCLE_NATURAL)s:</i> Each object will be created as a circle,
            and each circle's location within its grid compartment will be determined
            based on the location of any previously identified guiding objects within
            that grid compartment. Thus, if a guiding object lies within a particular grid compartment,
            that object's center will be the center of the created circular object.
            If no guiding objects lie within a particular grid compartment, the circular object
            is placed within the center of that grid compartment.  If more than one
            guiding object lies within the grid compartment, they will be combined and the centroid of
            this combined object will be the location of the created circular object.
            Note that guiding objects whose centers are close to the grid edge are ignored.</li>
            <li><i>%(SHAPE_NATURAL)s:</i> Within each grid compartment, the object
            will be identified based on combining all of the parts of guiding objects, if any,
            that fall within the grid compartment.
            Note that guiding objects whose centers are close to the grid edge are ignored.
            If a guiding object does not exist within a grid compartment, an object consisting
            of one single pixel in the middle of the grid compartment will be created.</li>
            </ul>""" % globals())

        self.diameter_choice = cps.Choice(
            "Specify the circle diameter automatically?",
            [AM_AUTOMATIC, AM_MANUAL],
            doc="""
            <i>(Used only if Circle is selected as object shape)</i><br>
            There are two methods for selecting the circle diameter:
            <ul>
            <li><i>%(AM_AUTOMATIC)s:</i> Uses the average diameter of previously identified guiding
            objects as the diameter.</li>
            <li><i>%(AM_MANUAL)s:</i> Lets you specify the diameter directly, as a number.</li>
            </ul>""" % globals())

        self.diameter = cps.Integer("Circle diameter",
                                    20,
                                    minval=2,
                                    doc="""
            <i>(Used only if Circle is selected as object shape and diameter is
            specified manually)</i><br>
            Enter the diameter to be used for each grid circle, in pixels.
            %(HELP_ON_MEASURING_DISTANCES)s""" % globals())

        self.guiding_object_name = cps.ObjectNameSubscriber(
            "Select the guiding objects",
            cps.NONE,
            doc="""
            <i>(Used only if Circle is selected as object shape and diameter is specified
            automatically, or if Natural Location is selected as the object shape)</i><br>
            Select the names of previously identified objects that
            will be used to guide the shape and/or location of the objects created by this
            module, depending on the method chosen.""")

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

        self.outlines_name = cps.OutlineNameProvider("Name the outline image",
                                                     "GridOutlines",
                                                     doc="""
            %(NAMING_OUTLINES_HELP)s""" % globals())
    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.object_name = cps.ObjectNameSubscriber(
                "Select the objects to be edited", cps.NONE, doc="""
            Choose a set of previously identified objects
            for editing, such as those produced by one of the
            <b>Identify</b> modules.""")

        self.filtered_objects = cps.ObjectNameProvider(
                "Name the edited objects", "EditedObjects", doc="""
            Enter the name for the objects that remain
            after editing. These objects will be available for use by
            subsequent modules.""")

        self.allow_overlap = cps.Binary(
                "Allow overlapping objects?", False, doc="""
            <b>EditObjectsManually</b> can allow you to edit an
            object so that it overlaps another or it can prevent you from
            overlapping one object with another. Objects such as worms or
            the neurites of neurons may cross each other and might need to
            be edited with overlapping allowed, whereas a monolayer of cells
            might be best edited with overlapping off. <br>
            Select <i>%(YES)s</i> to allow overlaps or select <i>%(NO)s</i>
            to prevent them.""" % globals())

        self.wants_outlines = cps.Binary(
                "Retain outlines of the edited objects?", False, doc="""
            Select <i>%(YES)s</i> if you want to keep images of the outlines
            of the objects that remain after editing. This image
            can be saved by downstream modules or overlayed on other images
            using the <b>OverlayOutlines</b> module.""" % globals())

        self.outlines_name = cps.OutlineNameProvider(
                "Name the outline image", "EditedObjectOutlines", doc="""
            <i>(Used only if you have selected to retain outlines of edited objects)</i><br>
            Enter a name for the outline image.""")

        self.renumber_choice = cps.Choice(
                "Numbering of the edited objects",
                [R_RENUMBER, R_RETAIN], doc="""
            Choose how to number the objects that
            remain after editing, which controls how edited objects are associated with their predecessors:
            <ul>
            <li><i>%(R_RENUMBER)s:</i> The module will number the objects that remain
            using consecutive numbers. This
            is a good choice if you do not plan to use measurements from the
            original objects and you only want to use the edited objects in downstream modules; the
            objects that remain after editing will not have gaps in numbering
            where removed objects are missing.</li>
            <li><i>%(R_RETAIN)s:</i> This option will retain each object's original number so that the
            edited object's number matches its original number. This allows any measurements you make from
            the edited objects to be directly aligned with measurements you might
            have made of the original, unedited objects (or objects directly
            associated with them).</li>
            </ul>""" % globals())

        self.wants_image_display = cps.Binary(
                "Display a guiding image?", True, doc="""
            Select <i>%(YES)s</i> to display an image and outlines of the objects. <br>
            Select <i>%(NO)s</i> if you do not want a guide image while editing""" % globals())

        self.image_name = cps.ImageNameSubscriber(
                "Select the guiding image", cps.NONE, doc="""
            <i>(Used only if a guiding image is desired)</i><br>
            This is the image that will appear when editing objects.
            Choose an image supplied by a previous module.""")
Esempio n. 9
0
    def create_settings(self):
        self.object_name = cps.ObjectNameSubscriber(
                "Select the input objects",
                cps.NONE, doc='''
            Select the objects that you want to expand or shrink.''')

        self.output_object_name = cps.ObjectNameProvider(
                "Name the output objects",
                "ShrunkenNuclei", doc='''
            Enter a name for the resulting objects.''')

        self.operation = cps.Choice(
                "Select the operation",
                O_ALL, doc='''
            Select the operation that you want to perform:
            <ul>
            <li><i>%(O_SHRINK_INF)s:</i> Remove all pixels but one from filled objects. Thin objects
            with holes to loops unless the "fill" option is checked.</li>
            <li><i>%(O_EXPAND_INF)s:</i> Expand objects, assigning every pixel in the image to an
            object. Background pixels are assigned to the nearest object.</li>
            <li><i>%(O_DIVIDE)s:</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>%(O_SHRINK)s:</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>%(O_EXPAND)s:</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>%(O_SKELETONIZE)s:</i> Erode each object to its skeleton.</li>
            <li><i>%(O_SPUR)s:</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>''' % globals())

        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="""
            <i>(Used only if one of the "shrink" options selected)</i><br>
            Select <i>%(YES)s</i> to ensure that each object will shrink
            to a single point, by filling the holes in each object.
            <p>Select <i>%(NO)s</i> to preserve the Euler number. in this case, the
            shrink algorithm preserves each object's Euler number,
            which means that it will erode an object with a hole to a ring in order to
            keep the hole. An object with two holes will be shrunk to two rings
            connected by a line in order to keep from breaking up the object or breaking
            the hole.</p>""" % globals())

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

        self.outlines_name = cps.OutlineNameProvider(
                "Name the outline image",
                "ShrunkenNucleiOutlines", doc="""
            %(NAMING_OUTLINES_HELP)s""" % globals())