def create_settings(self):
     self.images = []
     self.objects = []
     self.bin_counts = []
     self.heatmaps = []
     self.image_count = cps.HiddenCount(self.images)
     self.object_count = cps.HiddenCount(self.objects)
     self.bin_counts_count = cps.HiddenCount(self.bin_counts)
     self.heatmap_count = cps.HiddenCount(self.heatmaps)
     self.add_image_button = cps.DoSomething("", "Add another image", self.add_image)
     self.spacer_1 = cps.Divider()
     self.add_object_button = cps.DoSomething("", "Add another object",
                                              self.add_object)
     self.spacer_2 = cps.Divider()
     self.add_bin_count_button = cps.DoSomething(
         "", "Add another set of bins", self.add_bin_count)
     self.spacer_3 = cps.Divider()
     self.add_heatmap_button = cps.DoSomething(
         "", "Add another heatmap display", self.add_heatmap,
         doc = """
     Press this button to add a display of one of the radial distribution
     measurements. Each radial band of the object is colored using a
     heatmap according to the measurement value for that band.""")
     self.add_image(can_remove = False)
     self.add_object(can_remove = False)
     self.add_bin_count(can_remove = False)
Пример #2
0
 def create_settings(self):
     self.divider_top = cps.Divider(line=False)
     self.images = []
     self.image_count = cps.HiddenCount(self.images, "Image count")
     self.add_image(can_remove = False)
     self.add_button = cps.DoSomething("", "Add another image", self.add_image)
     self.divider_bottom = cps.Divider(line=False)
Пример #3
0
        def measurement_visibles(m_g):
            if hasattr(m_g, "remover"):
                result = [cps.Divider(line=True)]
            else:
                result = []
            result += [m_g.source_choice]

            if m_g.source_choice == S_ALL_OBJECTS or m_g.source_choice == S_AVERAGE_OBJECT:
                result += [m_g.object_name]
            if m_g.source_choice == S_RULES or\
               m_g.source_choice == S_CLASSIFIER:
                result += [m_g.rules_directory, m_g.rules_file_name,
                           m_g.rules_class]
                whatami = "Rules" if m_g.source_choice == S_RULES \
                    else "Classifier"
                for setting, s in ((m_g.rules_directory, "%s file location"),
                                   (m_g.rules_file_name, "%s file name")):
                    setting.text = s % whatami
            else:
                result += [m_g.measurement, m_g.wants_minimum]
                if m_g.wants_minimum.value:
                    result += [m_g.minimum_value]
                result += [m_g.wants_maximum]
                if m_g.wants_maximum.value:
                    result += [m_g.maximum_value]
            if hasattr(m_g, "remover"):
                result += [m_g.remover, cps.Divider(line=True)]
            return result
Пример #4
0
 def create_settings(self):
     '''Create the initial settings for the module'''
     self.image_groups = []
     self.add_image(can_delete = False)
     self.spacer_1 = cps.Divider()
     self.add_image(can_delete = False)
     self.image_count = cps.HiddenCount(self.image_groups)
     
     self.add_image_button = cps.DoSomething("", 'Add another image', self.add_image)
     self.spacer_2 = cps.Divider()
     self.images_or_objects = cps.Choice(
         'Select where to measure correlation',
         [M_IMAGES, M_OBJECTS, M_IMAGES_AND_OBJECTS], doc = '''
         You can measure the correlation in several ways: 
         <ul>
         <li><i>%(M_OBJECTS)s:</i> Measure correlation only in those pixels previously
         identified as an object. You will be asked to specify which object to measure from.</li>
         <li><i>%(M_IMAGES)s:</i> Measure the correlation across all pixels in the images.</li>
         <li><i>%(M_IMAGES_AND_OBJECTS)s:</i> Calculate both measurements above.</li>
         </ul>
         All methods measure correlation on a pixel by pixel basis.'''%globals())
     
     self.object_groups = []
     self.add_object(can_delete = False)
     self.object_count = cps.HiddenCount(self.object_groups)
     
     self.spacer_2 = cps.Divider(line=True)
     
     self.add_object_button = cps.DoSomething("", 'Add another object', self.add_object)
Пример #5
0
 def create_settings(self):
     """Create the settings for the module at startup.
     """ 
     self.image_groups = []
     self.image_count = cps.HiddenCount(self.image_groups)
     self.add_image_cb(can_remove = False)
     self.add_images = cps.DoSomething("", "Add another image",
                                       self.add_image_cb)
     self.image_divider = cps.Divider()  
     
     self.object_groups = []
     self.object_count = cps.HiddenCount(self.object_groups)
     self.add_object_cb(can_remove = True)
     self.add_objects = cps.DoSomething("", "Add another object",
                                        self.add_object_cb)
     self.object_divider = cps.Divider()                
     
     self.moms=cps.MultiChoice(
         "Moments to compute", MOM_ALL, MOM_ALL,
         doc = """Moments are statistics describing the distribution of values in the set of pixels of interest:
             <p><ul>
             <li><i>%(MOM_1)s</i> - the first image moment, which corresponds to the central value of the collection of pixels of interest.</li>
             <li><i>%(MOM_2)s</i> - the second image moment, which measures the amount of variation or dispersion of pixel values about its mean.</li>
             <li><i>%(MOM_3)s</i> - a scaled version of the third moment, which measures the asymmetry of the pixel values distribution about its mean.</li>
             <li><i>%(MOM_4)s</i> - a scaled version of the fourth moment, which measures the "peakedness" of the pixel values distribution.</li>
             </ul><p>
             Choose one or more moments to measure.""" % globals())    
    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)
Пример #7
0
 def create_settings(self):
     '''Create the initial settings for the module'''
     self.image_groups = []
     self.add_image(can_delete = False)
     self.spacer_1 = cps.Divider()
     self.add_image(can_delete = False)
     self.image_count = cps.HiddenCount(self.image_groups)
     
     self.add_image_button = cps.DoSomething("", 'Add another image', self.add_image)
     self.spacer_2 = cps.Divider()
     self.images_or_objects = cps.Choice('Select where to measure correlation',
                                         [M_IMAGES, M_OBJECTS, M_IMAGES_AND_OBJECTS], 
                                         doc = '''
                                         Do you want to measure the correlation over the whole image, 
                                         within objects, or both?
                                         Both methods measure correlation on a pixel by pixel basis.
                                         Selecting <i>Objects</i> will measure correlation only in those pixels previously
                                         identified as an object (you will be asked to specify which object).  Selecting 
                                         <i>Images</i> will measure correlation across all pixels in the images.
                                         <i>Images and objects</i> will calculate both measurements.''')
     
     self.object_groups = []
     self.add_object(can_delete = False)
     self.object_count = cps.HiddenCount(self.object_groups)
     
     self.spacer_2 = cps.Divider(line=True)
     
     self.add_object_button = cps.DoSomething("", 'Add another object', self.add_object)
Пример #8
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)
Пример #9
0
 def create_settings(self):
     '''Create the settings & name the module'''
     self.divider_top = cps.Divider(line=False)
     self.images = []
     self.add_image_measurement(can_remove=False)
     self.add_button = cps.DoSomething("", "Add another image",
                                       self.add_image_measurement)
     self.divider_bottom = cps.Divider(line=False)
    def create_settings(self):
        """Create the settings for the module at startup.
        
        The module allows for an unlimited number of measured objects, each
        of which has an entry in self.object_groups.
        """
        self.image_groups = []
        self.object_groups = []
        self.scale_groups = []
        self.image_count = cps.HiddenCount(self.image_groups)
        self.object_count = cps.HiddenCount(self.object_groups)
        self.scale_count = cps.HiddenCount(self.scale_groups)
        self.add_image_cb(can_remove=False)
        self.add_images = cps.DoSomething("", "Add another image",
                                          self.add_image_cb)
        self.image_divider = cps.Divider()
        self.add_object_cb(can_remove=True)
        self.add_objects = cps.DoSomething("", "Add another object",
                                           self.add_object_cb)
        self.object_divider = cps.Divider()
        self.add_scale_cb(can_remove=False)
        self.add_scales = cps.DoSomething("", "Add another scale",
                                          self.add_scale_cb)
        self.scale_divider = cps.Divider()

        self.wants_gabor = cps.Binary(
            "Measure Gabor features?",
            True,
            doc="""The Gabor features measure striped texture in an object. They
            take a substantial time to calculate. Check this setting to
            measure the Gabor features. Uncheck this setting to skip
            the Gabor feature calculation if it is not informative for your
            images""")
        self.gabor_angles = cps.Integer(
            "Number of angles to compute for Gabor",
            4,
            2,
            doc="""
        <i>(Used only if Gabor features are measured)</i><br>
        How many angles do you want to use for each Gabor texture measurement?
            The default value is 4 which detects bands in the horizontal, vertical and diagonal
            orientations.""")
        self.gabor_divider = cps.Divider()

        self.wants_tamura = cps.Binary(
            "Measure Tamura features?",
            True,
            doc="""The Tamura features are very ugly.""")
        self.tamura_feats = cps.MultiChoice("Features to compute",
                                            F_ALL,
                                            F_ALL,
                                            doc="""Tamura Features:
                        <p><ul>
                        <li><i>%(F_1)s</i> - bla.</li>
                        <li><i>%(F_2)s</i> - bla.</li>
                        <li><i>%(F_3)s</i> - bla.</li>
                        </ul><p>
                        Choose one or more features to compute.""" % globals())
Пример #11
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)
Пример #12
0
    def create_settings(self):
        """Create the settings for the module at startup.
        
        The module allows for an unlimited number of measured objects, each
        of which has an entry in self.object_groups.
        """
        self.image_groups = []
        self.object_groups = []
        self.scale_groups = []
        self.image_count = cps.HiddenCount(self.image_groups)
        self.object_count = cps.HiddenCount(self.object_groups)
        self.scale_count = cps.HiddenCount(self.scale_groups)
        self.add_image_cb(can_remove=False)
        self.add_images = cps.DoSomething("", "Add another image",
                                          self.add_image_cb)
        self.image_divider = cps.Divider()
        self.add_object_cb(can_remove=True)
        self.add_objects = cps.DoSomething("", "Add another object",
                                           self.add_object_cb)
        self.object_divider = cps.Divider()
        self.add_scale_cb(can_remove=False)
        self.add_scales = cps.DoSomething("", "Add another scale",
                                          self.add_scale_cb)
        self.scale_divider = cps.Divider()

        self.wants_gabor = cps.Binary(
            "Measure Gabor features?",
            True,
            doc=
            """The Gabor features measure striped texture in an object, and can 
            take a substantial time to calculate. 
            <p>Select <i>%(YES)s</i> to measure the Gabor features. Select 
            <i>%(NO)s</i> to skip the Gabor feature calculation if it is not 
            informative for your images.</p>""" % globals())

        self.gabor_angles = cps.Integer(
            "Number of angles to compute for Gabor",
            4,
            2,
            doc="""
            <i>(Used only if Gabor features are measured)</i><br>
            Enter the number of angles to use for each Gabor texture measurement.
            The default value is 4 which detects bands in the horizontal, vertical and diagonal
            orientations.""")
        self.images_or_objects = cps.Choice(
            "Measure images or objects?", [IO_IMAGES, IO_OBJECTS, IO_BOTH],
            value=IO_BOTH,
            doc="""This setting determines whether the module 
            computes image-wide measurements, per-object measurements or both.
            <ul>
            <li><i>%(IO_IMAGES)s:</i> Select if you only want to measure the texture of objects.</li>
            <li><i>%(IO_OBJECTS)s:</i> Select if your pipeline does not contain objects or if
            you only want to make per-image measurements.</li>
            <li><i>%(IO_BOTH)s:</i> Select to make both image and object measurements.</li>
            </ul>""" % globals())
Пример #13
0
 def create_settings(self):
     self.how_to_remove = cps.Choice("Specify which images?",
                                     [C_REMOVE, C_KEEP],
                                     doc="""
         <ul><li>Choose <i>%s</i> to remove some images from memory and keep the rest.</li>
         <li>Choose <i>%s</i> to keep some images and remove the rest.</li></ul>"""
                                     % (C_REMOVE, C_KEEP))
     self.spacer_top = cps.Divider(line=False)
     self.image_names = []
     self.add_image(can_remove=False)
     self.spacer_bottom = cps.Divider(line=False)
     self.add_image_button = cps.DoSomething("", "Add another image",
                                             self.add_image)
Пример #14
0
 def flag_visibles(flag):
     if hasattr(flag, "remover"):
         result = [cps.Divider(line=True),cps.Divider(line=True)]
     else:
         result = []
     result += [flag.category, flag.feature_name, flag.wants_skip]
     if len(flag.measurement_settings) > 1:
         result += [flag.combination_choice]
     for measurement_settings in flag.measurement_settings:
         result += measurement_visibles(measurement_settings)
     result += [flag.add_measurement_button]
     if hasattr(flag, "remover"):
         result += [flag.remover, cps.Divider(line=True),cps.Divider(line=True)]
     return result
Пример #15
0
 def create_settings(self):
     self.how_to_remove = cps.Choice(
         "Specify which images?",
         [C_REMOVE, C_KEEP], doc="""
         You can select from the following options:
         <ul>
         <li><i>%(C_REMOVE)s:</i> Remove some images from memory and keep the rest.</li>
         <li><i>%(C_KEEP)s:</i> Keep some images and remove the rest.</li>
         </ul>"""%globals())
     
     self.spacer_top = cps.Divider(line=False)
     self.image_names = []
     self.add_image(can_remove = False)
     self.spacer_bottom = cps.Divider(line=False)
     self.add_image_button = cps.DoSomething("", "Add another image",
                                             self.add_image)
Пример #16
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)
Пример #17
0
 def add_object_cb(self, can_remove=True):
     '''Add an object to the object_groups collection
     
     can_delete - set this to False to keep from showing the "remove"
                  button for objects that must be present.
     '''
     group = cps.SettingsGroup()
     if can_remove:
         group.append("divider", cps.Divider(line=False))
     group.append(
         'object_name',
         cps.ObjectNameSubscriber("Select objects to measure",
                                  "None",
                                  doc="""
                     What did you call the objects whose texture you want to measure? 
                     If you only want to measure the texture 
                     for the image overall, you can remove all objects using the "Remove this object" button. 
                     <p>Objects specified here will have their
                     texture measured against <i>all</i> images specfied above, which
                     may lead to image-object combinations that are unneccesary. If you
                     do not want this behavior, use multiple <b>MeasureTexture</b>
                     modules to specify the particular image-object measures that you want.</p>"""
                                  ))
     if can_remove:
         group.append(
             "remover",
             cps.RemoveSettingButton("", "Remove this object",
                                     self.object_groups, group))
     self.object_groups.append(group)
 def add_object(self, can_remove = True):
     '''Add an object to be measured (plus optional centers)'''
     group = cps.SettingsGroup()
     if can_remove:
         group.append("divider", cps.Divider(line=False))
     group.append("object_name", cps.ObjectNameSubscriber(
             "Select objects to measure", "None",doc="""
             What did you call the objects you want to measure?"""))
     group.append("center_choice", cps.Choice(
             "Object to use as center?", C_ALL,doc="""
             There are three ways to specify the center of the radial measurement:
             <ul>
             <li><i>These objects</i>: Use the centers of these objects for the 
             radial measurement.</li> 
             <li><i>Centers of other objects</i>: Use the centers of other objects
             for the radial measurement.</li>
             <li><i>Edges of other objects</i>: Measure distances from the
             edge of the other object to each pixel outside of the
             centering object. Do not include pixels within the centering
             object in the radial measurement calculations.</li>
             </ul>
             For example, if measuring the radial distribution in a Cell
             object, you can use the center of the Cell objects (<i>These
             objects</i>) or you can use previously identified Nuclei objects as 
             the centers (<i>Other objects</i>)."""))
     group.append("center_object_name", cps.ObjectNameSubscriber(
             "Select objects to use as centers", "None",doc="""<i>(Used only if "other objects" are selected for centers)</i><br>
             Select the object to use as the center, or select <i>None</i> to
             use the input object centers (which is the same as selecting
             <i>These objects</i> for the object centers)."""))
     if can_remove:
         group.append("remover", cps.RemoveSettingButton("", "Remove this object", self.objects, group))
     self.objects.append(group)
Пример #19
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)
Пример #20
0
 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)
Пример #21
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)
Пример #22
0
    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)
Пример #23
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)
Пример #24
0
 def create_settings(self):
     self.flags = []
     self.flag_count = cps.HiddenCount(self.flags)
     self.add_flag_button = cps.DoSomething("", "Add another flag",
                                            self.add_flag)
     self.spacer_1 = cps.Divider()
     self.add_flag(can_delete=False)
Пример #25
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)
    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)
Пример #27
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)
Пример #28
0
 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="""
                      Select the additional image to align?"""))
     
     group.append("output_image_name",
                  cps.ImageNameProvider(
                      "Name the output image",
                      "AlignedBlue",doc="""
                      Enter the name of the aligned image?"""))
     
     group.append("align_choice",
                  cps.Choice(
                      "Select how the alignment is to be applied",
                      [A_SIMILARLY, A_SEPARATELY],doc="""
                      An additional image can either be aligned similarly to the second one or 
                      a separate alignment to the first image can be calculated:
                      <ul>
                      <li><i>%(A_SIMILARLY)s:</i> The same alignment measurements obtained from
                      the first two input images are applied to this additional image.</li>
                      <li><i>%(A_SEPARATELY)s:</i> A new set of alignment measurements are
                      calculated for this additional image using the alignment method
                      specified with respect to the first input image.</li>
                      </ul>"""%globals()))
     
     if can_remove:
         group.append("remover", cps.RemoveSettingButton("", "Remove above image", self.additional_images, group))
     self.additional_images.append(group)
Пример #29
0
 def __init__(self):
     self.__spacer = cps.Divider(line=True)
     self.__operand_choice = cps.Choice("Measure the area occupied in a binary image, or in objects?", 
                                        [O_BINARY_IMAGE, O_OBJECTS], doc = """
                                        You can either measure the area occupied by previously-identified 
                                        objects, or the area occupied by the foreground in a binary (black 
                                        and white) image.""")
     self.__operand_objects = cps.ObjectNameSubscriber("Select objects to measure",
                                         "None", doc = """
                                         <i>(Used only if '%(O_OBJECTS)s' are to be measured)</i> <br>
                                         Select the previously identified objects you would like to measure. """%globals())
     self.__should_save_image = cps.Binary("Retain a binary image of the object regions?", 
                                         False, doc="""
                                         <i>(Used only if '%(O_OBJECTS)s' are to be measured)</i><br>
                                         This setting is helpful if you would like to use a binary image 
                                         later in the pipeline, for example in SaveImages.  The image will 
                                         display the object area that you have measured as the foreground 
                                         in white and the background in black. """%globals())
     self.__image_name = cps.ImageNameProvider("Name the output binary image", 
                                         "Stain",doc="""
                                         <i>(Used only if the binary image of the objects is to be retained for later use in the pipeline)</i> <br> 
                                         Specify a name that will allow the binary image of the objects to be selected later in the pipeline.""")
     self.__binary_name = cps.ImageNameSubscriber("Select a binary image to measure", 
                                         "None", doc="""
                                         <i>(Used only if '%(O_BINARY_IMAGE)s' is to be measured)</i><br>
                                         This is a binary image created earlier in the pipeline, 
                                         where you would like to measure the area occupied by the foreground 
                                         in the image."""%globals())
Пример #30
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  "None", doc = '''What did you call the image to be resized?''')

        self.resized_image_name = cps.ImageNameProvider("Name the output image",
                                                        "ResizedBlue", doc = '''What do you want to call the resized image?''')

        self.size_method = cps.Choice("Select resizing method",
                                      R_ALL, doc = """How do you want to resize the image? 
                                      <ul><li><i>Resize by a fraction or multiple of the original size:</i> 
                                      Enter a single value which specifies the scaling. </li>
                                      <li><i>Resize by specifying desired final dimensions:</i></li> 
                                      Enter the new height and width of the resized image.</ul>""")

        self.resizing_factor = cps.Float("Resizing factor",
                                         .25, minval=0, doc = '''
                                         <i>(Used only if resizing by a fraction or multiple of the original size)</i><br>
                                         Numbers less than one (that is, fractions) will shrink the image; 
                                         numbers greater than one (that is, multiples) will enlarge the image.''')

        self.use_manual_or_image = cps.Choice("How do you want to specify the dimensions?",C_ALL, doc = """
                                        <i>(Used only if resizing by specifying the dimensions)</i><br>
                                        You have two options on how to resize your image:
                                        <ul>
                                        <li><i>Manual:</i> Specify the height and width of the output image.</li>
                                        <li><i>Image:</i> Specify an image and the input image will be resized
                                        to the same dimensions.</li>
                                        </ul>""")
        
        self.specific_width = cps.Integer("Width of the final image, in pixels", 100, minval=1, doc = '''
                                         <i>(Used only if resizing by specifying desired final dimensions)</i><br>
                                         Enter the desired width of the final image.''')

        self.specific_height = cps.Integer("Height of the final image, in pixels", 100, minval=1, doc = '''
                                         <i>(Used only if resizing by specifying desired final dimensions)</i><br>
                                         Enter the desired height of the final image.''')
        
        self.specific_image = cps.ImageNameSubscriber("Select the image with the desired dimensions", "None", doc = """"
                                        <i>(Used only if resizing by specifying desired final dimensions using an image)</i><br>
                                        The input image will be resized to the dimensions of the specified image.""")

        self.interpolation = cps.Choice("Interpolation method",
                                        I_ALL, doc = '''<ul><li><i>Nearest Neighbor:</i> Each output pixel is given the intensity of the nearest
                                        corresponding pixel in the input image.</li>
                                        <li><i>Bilinear:</i> Each output pixel is given the intensity of the weighted average
                                        of the 2x2 neighborhood at the corresponding position in the input image.</li>
                                        <li><i>Bicubic:</i> Each output pixel is given the intensity of the weighted average
                                        of the 4x4 neighborhood at the corresponding position in the input image.</li>
                                        </ul>''')
        
        self.separator = cps.Divider(line=False)
        
        self.additional_images = []
        
        self.additional_image_count = cps.HiddenCount(
            self.additional_images, "Additional image count")
        
        self.add_button = cps.DoSomething("", "Add another image",
                                          self.add_image)