How to use the cellprofiler.setting.Choice function in CellProfiler

To help you get started, we’ve selected a few CellProfiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CellProfiler / CellProfiler / tests / test_pipeline.py View on Github external
def test_17_00_get_dependency_graph_empty(self):
        for module in (
            ATestModule(),
            ATestModule([cellprofiler.setting.Choice("foo", ["Hello", "World"])]),
            ATestModule([cellprofiler.setting.ImageNameProvider("foo", IMAGE_NAME)]),
            ATestModule([cellprofiler.setting.ImageNameSubscriber("foo", IMAGE_NAME)]),
        ):
            pipeline = cellprofiler.pipeline.Pipeline()
            module.set_module_num(1)
            pipeline.add_module(module)
            result = pipeline.get_dependency_graph()
            self.assertEqual(len(result), 0)
github CellProfiler / CellProfiler / cellprofiler / modules / enhanceedges.py View on Github external
self.threshold_adjustment_factor = cps.Float(
            "Threshold adjustment factor",
            1,
            doc="""\
*(Used only with the "%(M_CANNY)s" option and automatic thresholding)*

This threshold adjustment factor is a multiplier that is applied to both
the lower and upper Canny thresholds if they are calculated
automatically. An adjustment factor of 1 indicates no adjustment. The
adjustment factor has no effect on any threshold entered manually.
"""
            % globals(),
        )

        self.direction = cps.Choice(
            "Select edge direction to enhance",
            [E_ALL, E_HORIZONTAL, E_VERTICAL],
            doc="""\
*(Used only with "%(M_PREWITT)s" and "%(M_SOBEL)s" methods)*

Select the direction of the edges you aim to identify in the image
(predominantly horizontal, predominantly vertical, or both).
"""
            % globals(),
        )

        self.wants_automatic_sigma = cps.Binary(
            "Calculate Gaussian's sigma automatically?",
            True,
            doc="""\
Select *Yes* to automatically calculate the Gaussian's sigma.
github CellProfiler / CellProfiler / cellprofiler / modules / identifysecondaryobjects.py View on Github external
def create_settings(self):
        super(IdentifySecondaryObjects, self).create_settings()

        self.x_name.text = "Select the input objects"

        self.x_name.doc = """\
What did you call the objects you want to use as primary objects ("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.y_name.text = "Name the objects to be identified"

        self.y_name.doc = "Enter the name that you want to call the objects identified by this module."

        self.method = cellprofiler.setting.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="""\
There are several methods available to find the dividing lines between
secondary objects that touch each other:

-  *{M_PROPAGATION:s}:* 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 *Watershed* 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.
github CellProfiler / CellProfiler / cellprofiler / modules / groups.py View on Github external
self.grouping_metadata.append(group)

        def get_group_metadata_choices(pipeline):
            choices = self.get_metadata_choices(pipeline, group)
            if len(choices) == 0:
                choices.append(cps.NONE)
            return choices

        if self.pipeline is not None:
            choices = get_group_metadata_choices(self.pipeline)
        else:
            choices = [cps.NONE]

        group.append(
            "metadata_choice",
            cps.Choice(
                "Metadata category",
                choices,
                choices_fn=get_group_metadata_choices,
                doc="""\
Specify the metadata category with which to define a group. Once a
selection is made, the two listings below will display the updated
values:

-  The *grouping list* (top table) shows the unique values of the
   selected metadata under the “Group” column; each of the unique values
   comprises a group. The “Count” column shows the number of image sets
   included in a given group; this is useful as a “sanity check” to make
   sure that the expected numbers of images are present.
-  The *image set list* (bottom table) shows the file name and location
   of each of the image sets that comprise the groups. In this example,
   the table has 26 rows, one for each of the DNA and GFP image sets
github CellProfiler / CellProfiler / cellprofiler / modules / measureobjectintensitydistribution.py View on Github external
if can_remove:
            group.append("divider", cellprofiler.setting.Divider(line=False))

        group.append(
            "object_name",
            cellprofiler.setting.ObjectNameSubscriber(
                "Select objects to measure",
                cellprofiler.setting.NONE,
                doc="Select the objects whose intensity distribution you want to measure.",
            ),
        )

        group.append(
            "center_choice",
            cellprofiler.setting.Choice(
                "Object to use as center?",
                C_ALL,
                doc="""\
There are three ways to specify the center of the radial measurement:

-  *{C_SELF}:* Use the centers of these objects for the radial
   measurement.
-  *{C_CENTERS_OF_OTHER}:* Use the centers of other objects for the
   radial measurement.
-  *{C_EDGES_OF_OTHER}:* 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.

For example, if measuring the radial distribution in a Cell object, you
can use the center of the Cell objects (*{C_SELF}*) or you can use
github CellProfiler / CellProfiler / cellprofiler / modules / exporttospreadsheet.py View on Github external
*"No"* to prompt before overwriting when running CellProfiler in the
GUI and to fail when running headless."""
            % globals(),
        )

        self.add_metadata = cps.Binary(
            "Add image metadata columns to your object data file?",
            False,
            doc="""\
“Image\_Metadata\_” columns are normally exported in the Image data
file, but if you select *"Yes"*, they will also be exported with the
Object data file(s)."""
            % globals(),
        )

        self.nan_representation = cps.Choice(
            "Representation of Nan/Inf",
            [NANS_AS_NANS, NANS_AS_NULLS],
            doc="""\
This setting controls the output for numeric fields if the calculated
value is infinite (*Inf*) or undefined (*NaN*). CellProfiler will
produce Inf or NaN values under certain rare circumstances, for instance
when calculating the mean intensity of an object within a masked region
of an image.

-  *%(NANS_AS_NULLS)s:* Output these values as empty fields.
-  *%(NANS_AS_NANS)s:* Output them as the strings “NaN”, “Inf” or
   “-Inf”."""
            % globals(),
        )

        self.pick_columns = cps.Binary(
github CellProfiler / CellProfiler / cellprofiler / modules / enhanceorsuppressfeatures.py View on Github external
morphological grayscale opening of the image; a black tophat
   filtering is the morphological grayscale closing of the image minus
   the image). The effect is to enhance lines whose width is the
   feature size.

.. _ImageJ Tubeness plugin: http://www.longair.net/edinburgh/imagej/tubeness/
""".format(
                **{
                    "E_NEURITES": E_NEURITES,
                    "N_GRADIENT": N_GRADIENT,
                    "N_TUBENESS": N_TUBENESS,
                }
            ),
        )

        self.speckle_accuracy = cellprofiler.setting.Choice(
            "Speed and accuracy",
            choices=[S_FAST, S_SLOW],
            doc="""\
*(Used only for the "{E_SPECKLES}" method)*

*{E_SPECKLES}* can use a fast or slow algorithm to find speckles.

-  *{S_FAST}:* Select this option for speckles that have a large radius
   (greater than 10 pixels) and need not be exactly circular.
-  *{S_SLOW}:* Use for speckles of small radius.
""".format(
                **{"E_SPECKLES": E_SPECKLES, "S_FAST": S_FAST, "S_SLOW": S_SLOW}
            ),
github CellProfiler / CellProfiler / cellprofiler / modules / identifyprimaryobjects.py View on Github external
self.low_res_maxima = cellprofiler.setting.Binary(
            "Speed up by using lower-resolution image to find local maxima?",
            True,
            doc="""\
*(Used only when distinguishing between clumped objects)*

Select "*{YES}*" to down-sample the image for declumping. This can be
helpful for saving processing time on large images.

Note that if you have entered a minimum object diameter of 10 or less,
checking this box will have no effect.""".format(
                **{"YES": cellprofiler.setting.YES}
            ),
        )

        self.fill_holes = cellprofiler.setting.Choice(
            "Fill holes in identified objects?",
            FH_ALL,
            value=FH_THRESHOLDING,
            doc="""\
This option controls how holes (regions of background surrounded by one
or more objects) are filled in:

-  *{FH_THRESHOLDING}:* Fill in holes that are smaller than
   the maximum object size prior to declumping and to fill in any holes
   after declumping.
-  *{FH_DECLUMP}:* Fill in holes located within identified
   objects after declumping.
-  *{FH_NEVER}:* Leave holes within objects.
   Please note that if an object is located within a hole and
   this option is enabled, the object will be lost when the hole is
   filled in.""".format(
github CellProfiler / CellProfiler / cellprofiler / modules / straightenworms.py View on Github external
-  *%(FLIP_TOP)s:* The brightest part of the worm should be at the top
   of the image.
-  *%(FLIP_BOTTOM)s:* The brightest part of the worm should be at the
   bottom.
-  *%(FLIP_NONE)s:* The worm should not be aligned.
-  *%(FLIP_MANUAL)s:* Bring up an editor for every cycle that allows
   you to choose the orientation of each worm.
"""
            % globals(),
        )

        def image_choices_fn(pipeline):
            """Return the image choices for the alignment image"""
            return [group.image_name.value for group in self.images]

        self.flip_image = cps.Choice(
            "Alignment image",
            [cps.NONE],
            choices_fn=image_choices_fn,
            doc="""
(*Only used if aligning worms*)

This is the image whose intensity will be used to align the worms.
You must use one of the straightened images below.""",
        )

        self.image_count = cps.HiddenCount(self.images, "Image count")

        self.add_image(False)

        self.add_image_button = cps.DoSomething(
            "",