コード例 #1
0
    def add_image(self, can_delete=True):
        '''Add an image to the list of images to be straightened'''

        group = cps.SettingsGroup()
        group.append("divider", cps.Divider())
        group.append(
            "image_name",
            cps.ImageNameSubscriber(
                'Select an input image to straighten',
                'None',
                doc='''This is the name of an image that will be straightened
            similarly to the worm. The straightened image and objects can
            then be used in subsequent modules such as
            <b>MeasureObjectIntensity</b>'''))
        group.append(
            "straightened_image_name",
            cps.ImageNameProvider(
                'Name the output straightened image',
                'StraightenedImage',
                doc='''This is the name that will be given to the image
            of the straightened worms.'''))
        if can_delete:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove above image", self.images,
                                        group))
        self.images.append(group)
コード例 #2
0
ファイル: imagemath.py プロジェクト: crschmidt/CellProfiler
 def add_image(self, removable=True):
     # The text for these settings will be replaced in renumber_settings()
     group = cps.SettingsGroup()
     group.removable = removable
     group.append("image_or_measurement", cps.Choice(
         "Image or measurement?", [IM_IMAGE, IM_MEASUREMENT],
         doc="""You can perform math operations using two images or you
         can use a measurement for one of the operands. For instance,
         to divide the intensity of one image by another, choose Image
         for both and pick the respective images. To divide the intensity
         of an image by its median intensity, use <b>MeasureImageIntensity</b>
         prior to this module to calculate the median intensity, then
         select "Measurement" and use the median intensity measurement as
         the denominator"""))
     group.append("image_name", cps.ImageNameSubscriber("", "",doc="""Which image do you want to use for this operation?"""))
     group.append("measurement", cps.Measurement(
         "Measurement", lambda : cpmeas.IMAGE,"",
         doc="""This is a measurement made on the image. The value of the
         measurement is used for the operand for all of the pixels of the
         other operand's image."""))
     group.append("factor", cps.Float("", 1,doc="""By what number would you like to multiply the above image? This multiplication
             is applied before other operations."""))
     if removable:
         group.append("remover", cps.RemoveSettingButton("", "Remove this image", self.images, group))
     group.append("divider", cps.Divider())
     self.images.append(group)
コード例 #3
0
    def add_outline(self, can_remove=True):
        group = cps.SettingsGroup()
        if can_remove:
            group.append("divider", cps.Divider(line=False))

        group.append(
            "outline_name",
            cps.OutlineNameSubscriber("Select outlines to display",
                                      "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.Choice("Select outline color", COLORS.keys(), default_color))
        if can_remove:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove this outline",
                                        self.outlines, group))

        self.outlines.append(group)
コード例 #4
0
 def add_function(self, can_remove = True):
     group = MorphSettingsGroup()
     if can_remove:
         group.append("divider", cps.Divider(line=False))
     group.append("function", cps.Choice("Select the operation to perform",
                                        F_ALL, F_OPEN,doc="""
                                        What operation do you want to perform?
                 Choose one of the operations described in this module's help."""))
     group.append("repeats_choice", cps.Choice("Number of times to repeat operation",
                                               R_ALL,doc="""
                 This setting controls the number of times that the same operation is applied
                 successively to the image.
                 <ul>
                 <li><i>Once:</i> Perform the operation once on the image.</li>
                 <li><i>Forever:</i> Perform the operation on the image until successive
                 iterations yield the same image.</li>
                 <li><i>Custom:</i> Perform the operation a custom number of times.</li>
                 </ul>"""))
     group.append("custom_repeats", cps.Integer(self.CUSTOM_REPEATS_TEXT,2,1,
                  doc=self.CUSTOM_REPEATS_DOC))
     group.append("scale", cps.Float(
         "Scale",3, minval=3,
         doc="""Morphological open, close, erode and dialate are performed
         with structuring elements which determine the diameter of the
         circle enclosing the pixels to consider when applying the operation.
         This setting controls the diameter of the structuring element."""))
                                     
     if can_remove:
         group.append("remove", cps.RemoveSettingButton("", "Remove this operation", self.functions, group))
     self.functions.append(group)
コード例 #5
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)
コード例 #6
0
    def add_image(self, can_remove=True):
        '''Add an image to the image_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.ImageNameSubscriber("Select an image to measure",
                                    cps.NONE,
                                    doc="""
            Select the grayscale images whose intensity you want to measure."""
                                    ))

        group.append(
            "nchannels",
            cps.Integer("Number of channels",
                        1,
                        minval=1,
                        doc="""
                    Indicate the number of channels of the image stack"""))

        if can_remove:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove this image", self.images,
                                        group))
        self.images.append(group)
コード例 #7
0
 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 two 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>Other objects</i>: Use the centers of other objects
             for the radial measurement.</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)
コード例 #8
0
ファイル: resize.py プロジェクト: vivianleung/CellProfiler
    def add_image(self, can_remove=True):
        '''Add an image + associated questions and buttons'''
        group = cps.SettingsGroup()
        if can_remove:
            group.append("divider", cps.Divider(line=False))

        group.append(
            "input_image_name",
            cps.ImageNameSubscriber("Select the additional image?",
                                    cps.NONE,
                                    doc="""
                                            What is the name of the additional image to resize? This image will be
                                            resized with the same settings as the first image."""
                                    ))
        group.append(
            "output_image_name",
            cps.ImageNameProvider("Name the output image",
                                  "ResizedBlue",
                                  doc="""
                                            What is the name of the additional resized image?"""
                                  ))
        if can_remove:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove above image",
                                        self.additional_images, group))
        self.additional_images.append(group)
コード例 #9
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",
                                  cps.NONE,
                                  doc="""
                     Select 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)
コード例 #10
0
    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)
コード例 #11
0
    def add_image(self, can_delete=True):
        '''Add an image to the image_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_delete:
            group.append("divider", cps.Divider(line=False))
        group.append(
            "image_name",
            cps.ImageNameSubscriber('Select an image to measure',
                                    cps.NONE,
                                    doc='''
            Select an image to measure the correlation from.'''))

        if len(self.image_groups
               ) == 0:  # Insert space between 1st two images for aesthetics
            group.append("extra_divider", cps.Divider(line=False))

        if can_delete:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove this image",
                                        self.image_groups, group))

        self.image_groups.append(group)
コード例 #12
0
    def add_probability_map(self, can_remove=True):
        group = cps.SettingsGroup()
        group.can_remove = can_remove
        self.probability_maps.append(group)

        # The following settings are used for the combine option
        group.output_image = cps.ImageNameProvider(
            "Name the output probability map", "ProbabilityMap")

        group.class_sel = cps.Integer(
            "Select the class",
            0,
            0,
            42,
            doc='''Select the class you want to use. The class number 
            corresponds to the label-class in ilastik''')

        if can_remove:
            group.remover = cps.RemoveSettingButton(
                "",
                "Remove this probability map",
                self.probability_maps,
                group,
                doc="""
                Press this button to remove the
                probability map image from the list of images produced by this
                module.""")
コード例 #13
0
    def add_mapping(self):
        group = cps.SettingsGroup()
        group.append("local_directory",
                     cps.Text("Local root path",
                                cpprefs.get_default_image_directory(),doc="""
                                What is the path to files on this computer? 
                                This is the root path on the local machine (i.e., the computer setting up
                                the batch files). If <b>CreateBatchFiles</b> finds
                                any pathname that matches the local root path at the begining, it will replace the
                                start with the cluster root path.
                                <p>For example, if you have mapped the remote cluster machine like this:<br><br>
                                <tt>Z:\your_data\images</tt> (on a Windows machine, for instance)<br><br>
                                and the cluster machine sees the same folder like this:<br><br>
                                <tt>/server_name/your_name/your_data/images</tt><br><br>
                                you would enter <tt>Z:</tt> here and <t>/server_name/your_name/</tt> 
                                for the cluster path in the next setting."""))

        group.append("remote_directory",
                     cps.Text("Cluster root path",
                                cpprefs.get_default_image_directory(),doc="""
                                What is the path to files on the cluster? This is the cluster 
                                root path, i.e., how the cluster machine sees the
                                top-most folder where your input/output files are stored.
                                <p>For example, if you have mapped the remote cluster machine like this:<br><br>
                                <tt>Z:\your_data\images</tt> (on a Windows machine, for instance)<br><br>
                                and the cluster machine sees the same folder like this:<br><br>
                                <tt>/server_name/your_name/your_data/images</tt><br><br>
                                you would enter <tt>Z:</tt> in the previous setting for the
                                local machine path and <t>/server_name/your_name/</tt> here. """))
        group.append("remover",
                     cps.RemoveSettingButton("", "Remove this path mapping", self.mappings, group))
        group.append("divider", cps.Divider(line=False))
        self.mappings.append(group)
コード例 #14
0
    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)
コード例 #15
0
 def add_stack_channel_cb(self, can_remove=True):
     group = cps.SettingsGroup()
     group.append("image_name", cps.ImageNameSubscriber(
         "Select the input image to add to the stacked image", cps.NONE))
     
     if can_remove:
         group.append("remover", cps.RemoveSettingButton("", "Remove this image", self.stack_channels, group))
     self.stack_channels.append(group)
コード例 #16
0
 def add_image(self, can_remove=True):
     '''Add an image to the list of image names'''
     group = cps.SettingsGroup()
     group.append('divider', cps.Divider(line=False))
     group.append('image_name', cps.ExternalImageNameSubscriber('Select an image a name to export'))
     if can_remove:
         group.append('remover', cps.RemoveSettingButton('', 'Remove this image name', self.image_names, group))
     self.image_names.append(group)
コード例 #17
0
    def add_object_group(self, can_remove=True):
        group = cps.SettingsGroup()
        group.append(
            "name",
            EEObjectNameSubscriber(
                "Data to export",
                doc=
                """<i>(Used only when Export all measurements? is left unchecked)</i><br>
            Choose <i>Image</i>, <i>Experiment</i>, <i>Object relationships</i> 
            or an object name from the list. <b>ExportToSpreadsheet</b> will write out a
            file of measurements for the given category."""))

        group.append(
            "previous_file",
            cps.Binary(
                "Combine these object measurements with those of the previous object?",
                False,
                doc=
                """<i>(Used only when Export all measurements? is left unchecked)</i><br>Check this setting to create a file composed
                of measurements made on this object and the one directly
                above it. Leave the box unchecked to create separate
                files for this and the previous object."""))

        group.append(
            "wants_automatic_file_name",
            cps.Binary(
                "Use the object name for the file name?",
                True,
                doc=
                """<i>(Used only when Export all measurements? is left unchecked)</i><br>Use the object name as selected above to generate a file
            name for the spreadsheet. For example, if you selected <i>Image</i>,
            above and have not checked the <i>Prepend output file name</i> option,
            your output file will be named "Image.csv". You can name
            the file yourself if you leave this box unchecked."""))

        group.append(
            "file_name",
            cps.Text(
                "File name",
                "DATA.csv",
                metadata=True,
                doc=
                """<i>(Used only when Export all measurements? is left unchecked)</i><br>Enter a file name for the named objects' 
                         measurements. <b>ExportToSpreadsheet</b> will
                         prepend the name of the measurements file to this
                         if you asked to do so above. If you have metadata 
                         associated with your images, this setting will also substitute
                         metadata tags if desired. %(USING_METADATA_TAGS_REF)s%(USING_METADATA_HELP_REF)s."""
                % globals()))

        group.append(
            "remover",
            cps.RemoveSettingButton("", "Remove this data set",
                                    self.object_groups, group))
        group.append("divider", cps.Divider(line=False))

        self.object_groups.append(group)
コード例 #18
0
 def add_flag(self, can_delete=True):
     group = cps.SettingsGroup()
     group.append("divider1", cps.Divider(line=False))
     group.append("measurement_settings", [])
     group.append("measurement_count", cps.HiddenCount(group.measurement_settings))
     group.append("category", cps.Text("Name the flag's category","Metadata", doc = '''
                             Name a measurement category in which the flag should reside. Metadata allows you to 
                             later group images in the <b>LoadImages</b> module based on the flag, if you load the 
                             flag data in a future pipeline via the <b>LoadData</b> module.  Otherwise, you might 
                             choose to have the flag stored in the "Image" category or using some other word you prefer.  
                             The flag is stored as a per-image measurement whose name is a combination of the
                             flag's category and feature name, underscore delimited. 
                             For instance, if the measurement category is
                             "Metadata" and the feature name is "QCFlag", then the default
                             measurement name would be "Metadata_QCFlag". %s'''%USING_METADATA_HELP_REF))
     
     group.append("feature_name", cps.Text("Name the flag","QCFlag", doc = '''
                             The flag is stored as a per-image measurement whose name is a combination of the
                             flag's category and feature name, underscore delimited. 
                             For instance, if the measurement category is
                             "Metadata" and the feature name is "QCFlag", then the default
                             measurement name would be "Metadata_QCFlag".'''))
     
     group.append("combination_choice", cps.Choice("Flag if any, or all, measurement(s) fails to meet the criteria?",
                             [ C_ANY, C_ALL], doc = '''
                             <ul>
                             <li><i>Any:</i> An image will be flagged if any of its measurements fail. This can be useful
                             for flagging images possessing multiple QC flaws; for example, you can flag all bright images and all out of focus images with one flag.</li>
                             <li><i>All:</i> A flag will only be assigned if all measurements fail.  This can be useful for flagging  images that possess only a combination
                             of QC flaws; for example, you can flag only images that are both bright and out of focus.</li>
                             </ul>'''))
     
     group.append(
         "wants_skip", cps.Binary("Skip image set if flagged?", False,
         doc = """You can skip the remainder of the pipeline for image sets
         that are flagged by checking this setting. If you check this
         setting, CellProfiler will not run subsequent modules in the
         pipeline on the images in any image set that is flagged. 
         CellProfiler will continue to process the pipeline if you leave
         the setting unchecked.<p>
         You may want to check this setting in order to filter out
         unwanted images during processing. For instance, you may want
         to exclude out of focus images when running 
         <b>CorrectIllumination_Calculate</b>. You can do this with a
         pipeline that measures image quality and flags inappropriate
         images before it runs <b>CorrectIllumination_Calculate</b>"""))
         
     group.append("add_measurement_button", 
                  cps.DoSomething("",
                                  "Add another measurement",
                                  self.add_measurement, group))
     self.add_measurement(group, False if not can_delete else True)
     if can_delete:
         group.append("remover", cps.RemoveSettingButton("", "Remove this flag", self.flags, group))
     group.append("divider2", cps.Divider(line=True))
     self.flags.append(group)
コード例 #19
0
    def add_bin_count(self, can_remove=True):
        '''Add another radial bin count at which to measure'''
        group = cps.SettingsGroup()
        if can_remove:
            group.append("divider", cps.Divider(line=False))

        group.append(
            "wants_scaled",
            cps.Binary("Scale the bins?",
                       True,
                       doc="""
                If you check this setting, <b>MeasureObjectRadialDistribution</b>
                will divide the object radially into the number of bins you specify.
                If you leave the setting unchecked, <b>MeasureObjectRadialDistribution</b>
                will ask for a maximum radial distance and will divide that distance
                into the number of bins you specify. It is necessary to specify
                a maximum distance so that each object will have the same measurements
                (which might be zero for small objects) and so that the measurements
                can be taken without knowing the maximum object radius before the
                run starts."""))

        group.append(
            "bin_count",
            cps.Integer("Number of bins",
                        4,
                        2,
                        doc="""
                Specify the number of bins that you want to use to measure 
                the distribution. Radial distribution is measured with respect to a series
                of concentric rings starting from the object center (or 
                more generally, between contours at a normalized distance
                from the object center). This number
                specifies the number of rings into which the distribution is to
                be divided. Additional ring counts can be specified
                by clicking the <i>Add another set of bins</i> button."""))

        group.append(
            "maximum_radius",
            cps.Integer("Maximum radius",
                        100,
                        minval=1,
                        doc="""
                Specify the maximum radius for the unscaled bins. The unscaled binning 
                method creates the number of bins that you
                specify and creates equally spaced bin boundaries up to the maximum
                radius. Parts of the object that are beyond this radius will be
                counted in an overflow bin. The radius is measured in pixels."""
                        ))

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

        corrected_image_name = cps.ImageNameProvider("Name the output image",
                                                     "CorrBlue",
                                                     doc='''
            Enter a name for the corrected image.''')

        illum_correct_function_image_name = cps.ImageNameSubscriber(
            "Select the illumination function",
            cps.NONE,
            doc='''
            Select the illumination correction function image that will be used to 
            carry out the correction. This image is usually produced by another module 
            or loaded as a .mat format image using the <b>Images</b> module or 
            <b>LoadSingleImage</b>.''')

        divide_or_subtract = cps.Choice(
            "Select how the illumination function is applied",
            [DOS_DIVIDE, DOS_SUBTRACT],
            doc='''
            This choice depends on how the illumination function was calculated
            and on your physical model of the way illumination variation affects the 
            background of images relative to the objects in images; it is also somewhat empirical. 
            <ul>
            <li><i>%(DOS_SUBTRACT)s:</i> Use this option if the background signal is significant 
            relative to the real signal coming from the cells.  If you created the illumination 
            correction function using <i>%(IC_BACKGROUND)s</i>,
            then you will want to choose <i>%(DOS_SUBTRACT)s</i> here.</li>
            <li><i>%(DOS_DIVIDE)s:</i> Choose this option if the the signal to background ratio 
            is high (the cells are stained very strongly). If you created the illumination correction 
            function using <i>%(IC_REGULAR)s</i>,
            then you will want to choose <i>%(DOS_DIVIDE)s</i> here.</li>
            </ul>''' % globals())

        image_settings = cps.SettingsGroup()
        image_settings.append("image_name", image_name)
        image_settings.append("corrected_image_name", corrected_image_name)
        image_settings.append("illum_correct_function_image_name",
                              illum_correct_function_image_name)
        image_settings.append("divide_or_subtract", divide_or_subtract)
        image_settings.append("rescale_option", RE_NONE)

        if can_delete:
            image_settings.append(
                "remover",
                cps.RemoveSettingButton("", "Remove this image", self.images,
                                        image_settings))
        image_settings.append("divider", cps.Divider())
        self.images.append(image_settings)
コード例 #24
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)
コード例 #25
0
 def add_when(self, can_delete = True):
     group = cps.SettingsGroup()
     group.append("choice", cps.Choice(
         "When should the email be sent?", S_ALL,
         doc="""Select the kind of event that causes
         <b>SendEmail</b> to send an email. You have the following choices:
         <br><ul><li><i>After first cycle:</i> Send an email during
         processing of the first image cycle.</li>
         <li><i>After last cycle:</i> Send an email after all processing
         is complete.</li>
         <li><i>After group start:</i> Send an email during the first
         cycle of each group of images.</li>
         <li><i>After group end:</i> Send an email after all processing
         for a group is complete.</li>
         <li><i>Every # of cycles</i> Send an email each time a certain
         number of image cycles have been processed. You will be prompted
         for the number of image cycles if you select this choice.</li>
         <li><i>After cycle #:</i> Send an email after the given number
         of image cycles have been processed. You will be prompted for
         the image cycle number if you select this choice. You can add
         more events if you want emails after more than one image cycle.</li>
         </ul>"""))
     
     group.append("image_set_number", cps.Integer(
         "Image cycle number", 1, minval = 1,
         doc='''
         <i>(Used only if sending email after a particular cycle number)</i><br>
         Send an email during processing of the given image cycle.
         For instance, if you enter 4, then <b>SendEmail</b>
         will send an email during processing of the fourth image cycle.'''))
     
     group.append("image_set_count", cps.Integer(
         "Image cycle count", 1, minval = 1,
         doc='''
         <i>(Used only if sending email after every N cycles)</i><br>
         Send an email each time this number of image cycles have
         been processed. For instance, if you enter 4,
         then <b>SendEmail</b> will send an email during processing of
         the fourth, eighth, twelfth, etc. image cycles.'''))
     
     group.append("message", cps.Text(
         "Message text","Notification from CellProfiler",
         metadata=True,
         doc="""The body of the message sent from CellProfiler.
         Your message can include metadata values. For instance,
         if you group by plate and want to send an email after processing each
         plate, you could use the message  
         "Finished processing plate \\g<Plate>". """))
     
     if can_delete:
         group.append("remover", cps.RemoveSettingButton(
             "Remove this email event", "Remove event", self.when, group))
     group.append("divider", cps.Divider())
     self.when.append(group)
コード例 #26
0
 def add_image(self, can_remove = True):
     '''Add an image to be measured'''
     group = cps.SettingsGroup()
     if can_remove:
         group.append("divider", cps.Divider(line=False))
     group.append("image_name", cps.ImageNameSubscriber(
             "Select an image to measure", cps.NONE, doc="""
             Select the image that you want to measure the intensity from."""))
     
     if can_remove:
         group.append("remover", cps.RemoveSettingButton("", "Remove this image", self.images, group))
     self.images.append(group)
コード例 #27
0
 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)
コード例 #28
0
    def add_outline(self, can_remove=True):
        group = cps.SettingsGroup()
        if can_remove:
            group.append("divider", cps.Divider(line=False))

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

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

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

        self.outlines.append(group)
コード例 #29
0
    def add_scale_cb(self, can_remove=True):
        '''Add a scale to the scale_groups collection
        
        can_delete - set this to False to keep from showing the "remove"
                     button for scales that must be present.
        '''
        group = cps.SettingsGroup()
        if can_remove:
            group.append("divider", cps.Divider(line=False))
        group.append(
            'scale',
            cps.Integer(
                "Texture scale to measure",
                len(self.scale_groups) + 3,
                doc=
                """You can specify the scale of texture to be measured, in pixel units; 
                                 the texture scale is the distance between correlated intensities in the image. A 
                                 higher number for the scale of texture measures larger patterns of 
                                 texture whereas smaller numbers measure more localized patterns of 
                                 texture. It is best to measure texture on a scale smaller than your 
                                 objects' sizes, so be sure that the value entered for scale of texture is 
                                 smaller than most of your objects. For very small objects (smaller than 
                                 the scale of texture you are measuring), the texture cannot be measured 
                                 and will result in a undefined value in the output file."""
            ))
        group.append(
            'angles',
            cps.MultiChoice(
                "Angles to measure",
                H_ALL,
                H_ALL,
                doc=
                """The Haralick texture measurements are based on the correlation
        between pixels offset by the scale in one of four directions:
        <p><ul>
        <li><i>%(H_HORIZONTAL)s</i> - the correlated pixel is "scale" pixels
        to the right of the pixel of interest.</li>
        <li><i>%(H_VERTICAL)s</i> - the correlated pixel is "scale" pixels
        below the pixel of interest.</li>
        <li><i>%(H_DIAGONAL)s</i> - the correlated pixel is "scale" pixels
        to the right and "scale" pixels below the pixel of interest.</li>
        <li><i>%(H_ANTIDIAGONAL)s</i> - the correlated pixel is "scale"
        pixels to the left and "scale" pixels below the pixel of interest.</li>
        </ul><p>
        Choose one or more directions to measure.""" % globals()))

        if can_remove:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove this scale",
                                        self.scale_groups, group))
        self.scale_groups.append(group)
コード例 #30
0
 def add_recipient(self, can_delete = True):
     '''Add a recipient for the email to the list of emails'''
     group = cps.SettingsGroup()
     group.append("recipient", cps.Text(
         "Recipient address","recipient@domain",
         doc="""Enter the address to which the messages will be sent."""))
     if can_delete:
         group.append("remover", cps.RemoveSettingButton(
             "Remove above recipient", "Remove recipient", 
             self.recipients, group,
             doc="""Press this button to remove the above recipient from
             the list of people to receive the email"""))
     self.recipients.append(group)