示例#1
0
    def create_settings(self):
        # Input settings
        self.input_color_choice = cps.Choice(
                "Input image type", CC_ALL, doc="""
            Specify whether you are combining several grayscale images or
            loading a single color image.""")

        self.wants_red_input = cps.Binary(
                "Use a red image?", True, doc="""
            Select <i>%(YES)s</i> to specify an image to use for the red channel.""" % globals())

        self.red_input_image = cps.ImageNameSubscriber(
                "Select the red image", cps.NONE)

        self.wants_green_input = cps.Binary(
                "Use a green image?", True, doc="""
            Select <i>%(YES)s</i> to specify an image to use for the green channel.""" % globals())

        self.green_input_image = cps.ImageNameSubscriber(
                "Select the green image", cps.NONE)

        self.wants_blue_input = cps.Binary(
                "Use a blue image?", True, doc="""
            Select <i>%(YES)s</i> to specify an image to use for the blue channel.""" % globals())

        self.blue_input_image = cps.ImageNameSubscriber(
                "Select the blue image", cps.NONE)

        self.color_input_image = cps.ImageNameSubscriber(
                "Select the color image", cps.NONE, doc='''
            Select the color image to use.''')

        # Output settings
        self.output_color_choice = cps.Choice(
                "Output image type", CC_ALL, doc="""
            Specify whether you want to produce several grayscale images or one color image.""")

        self.wants_red_output = cps.Binary(
                "Select <i>%(YES)s</i> to produce a red image." % globals(), True)

        self.red_output_image = cps.ImageNameProvider(
                "Name the red image", "InvertedRed")

        self.wants_green_output = cps.Binary(
                "Select <i>%(YES)s</i> to produce a green image." % globals(), True)

        self.green_output_image = cps.ImageNameProvider(
                "Name the green image", "InvertedGreen")

        self.wants_blue_output = cps.Binary(
                "Select <i>%(YES)s</i> to produce a blue image." % globals(), True)

        self.blue_output_image = cps.ImageNameProvider(
                "Name the blue image", "InvertedBlue")

        self.color_output_image = cps.ImageNameProvider(
                "Name the inverted color image",
                "InvertedColor", doc='''
            <i>(Used only when producing a color output image)</i><br>
            Enter a name for the inverted color image.''')
示例#2
0
 def create_settings(self):
     self.obj_or_img = cps.Choice(
         "Compare segmented objects, or foreground/background?", O_ALL)
     self.ground_truth = cps.ImageNameSubscriber(
         "Select the image to be used as the ground truth basis for calculating the amount of overlap",
         "None",
         doc=
         '''This binary (black and white) image is known as the "ground truth" image.  It can be the product of segmentation performed by hand, or
                                                the result of another segmentation algorithm whose results you would like to compare.'''
     )
     self.test_img = cps.ImageNameSubscriber(
         "Select the image to be used to test for overlap",
         "None",
         doc=''' This 
                                             binary (black and white) image is what you will compare with the ground truth image. It is known as the "test image".'''
     )
     self.object_name_GT = cps.ObjectNameSubscriber(
         "Select the objects to be used as the ground truth basis for calculating the amount of overlap",
         "None")
     self.img_obj_found_in_GT = cps.ImageNameSubscriber(
         "Which image did you find these objects in?", "None")
     self.object_name_ID = cps.ObjectNameSubscriber(
         "Select the objects to be tested for overlap against the ground truth",
         "None")
     self.img_obj_found_in_ID = cps.ImageNameSubscriber(
         "Which image did you find these objects in?", "None")
示例#3
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)
示例#4
0
    def create_settings(self):
        """Create the settings here and set the module name (initialization)
        
        """
        self.source_choice = cps.Choice("Use objects or an image as a mask?",
                                        [IO_OBJECTS, IO_IMAGE],
                                        doc="""
            You can mask an image in two ways:
            <ul>
            <li><i>%(IO_OBJECTS)s</i>: Using objects created by another
            module (for instance <b>IdentifyPrimaryObjects</b>). The module
            will mask out all parts of the image that are not within one
            of the objects (unless you invert the mask).</li>
            <li><i>5(IO_IMAGE)s</i>: Using a binary image as the mask, where black 
            portions of the image (false or zero-value pixels) will be masked out.
            If the image is not binary, the module will use
            all pixels whose intensity is greater than 0.5 as the mask's
            foreground (white area). You can use <b>ApplyThreshold</b> instead to create a binary
            image and have finer control over the intensity choice.</li>
            </ul>""" % globals())

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

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

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

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

        self.invert_mask = cps.Binary(
            "Invert the mask?",
            False,
            doc="""This option reverses the foreground/background relationship of
            the mask. 
            <ul>
            <li>If unchecked, the mask will be composed of the foregound 
            (white portion) of the masking image or the area within the masking 
            objects.</li>
            <li>If checked, the mask will instead be composed of the 
            <i>background</i> (black portions) of the masking image or the area 
            <i>outside</i> the masking objects.</li>
            </ul>""")
    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)
示例#6
0
 def create_settings(self):
     # Input settings
     self.input_color_choice = cps.Choice(
         "Input image type",
         CC_ALL, doc = """Are you combining several grayscale images or loading a single color image?""")
     self.wants_red_input = cps.Binary(
         "Use a red image?",
         True, """Do you want to load an image for the red channel? Leave checked unless there is
         no red component to your grayscale image.""")
     self.red_input_image = cps.ImageNameSubscriber(
         "Select the red image",
         "None", doc = '''What did you call the red image?''')
     self.wants_green_input = cps.Binary(
         "Use a green image?",
         True, doc = """Do you want to load an image for the green channel? Leave checked unless there is
         no red component to your grayscale image.""")
     self.green_input_image = cps.ImageNameSubscriber(
         "Select the green image", "None",
         doc = '''What did you call the green image?''')
     self.wants_blue_input = cps.Binary(
         "Use a blue image?", True, doc = """Do you want to load an image for the blue channel?
         Leave checked unless there is no red component to your grayscale image.""")
     self.blue_input_image = cps.ImageNameSubscriber(
         "Select the blue image", "None", 
         doc = '''What did you call the blue image?''')
     self.color_input_image = cps.ImageNameSubscriber(
         "Select the color image", "None",
         doc = '''What did you call the color image?''')
     
     # output settings
     self.output_color_choice = cps.Choice(
         "Output image type",
         CC_ALL, doc = """Do you want to produce several grayscale images or one color image?""")
     self.wants_red_output = cps.Binary(
         "Produce a red image?",
         True, doc = """Do you want to produce an image for the red channel?""")
     self.red_output_image = cps.ImageNameProvider(
         "Name the red image",
         "InvertedRed", doc = '''<i>(Used only when producing a red image)</i><br>What do you want to call the red image?''')
     self.wants_green_output = cps.Binary(
         "Produce a green image?",
         True, doc = """Do you want to produce an image for the green channel?""")
     self.green_output_image = cps.ImageNameProvider(
         "Name the green image", "InvertedGreen",
         doc = '''<i>(Used only when producing a green image)</i><br>What do you want to call the green image?''')
     self.wants_blue_output = cps.Binary(
         "Produce a blue image?", True, doc = """Do you want to produce an image for the blue channel?""")
     self.blue_output_image = cps.ImageNameProvider(
         "Name the blue image", "InvertedBlue",
         doc = '''<i>(Used only when producing a blue image)</i><br>What do you want to call the blue image?''')
     self.color_output_image = cps.ImageNameProvider(
         "Name the inverted color image",
         "InvertedColor", doc = '''<i>(Used only when producing a color output image)</i><br>What do you want to call the inverted color image?''')
示例#7
0
    def create_settings(self):
        self.obj_or_img = cps.Choice(
            "Compare segmented objects, or foreground/background?", O_ALL)

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

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

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

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

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

        self.img_obj_found_in_ID = cps.ImageNameSubscriber(
            "Select the image used to find these objects",
            cps.NONE,
            doc="""
            <i>(Used only when comparing segmented objects)</i> <br>
            Choose which image was used to produce these objects. If the objects were produced from other objects or loaded into CellProfiler,
            select "None." """)
    def 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",
            "SpillCorrected", doc = '''
            Enter a name for the corrected image.''')

        spill_correct_function_image_name = cps.ImageNameSubscriber(
            "Select the spillover function image",
            cps.NONE, doc = '''
            Select the spillover correction image that will be used to
            carry out the correction. This image is usually produced by the R
            software CATALYST or loaded as a .tiff format image using the
            <b>Images</b> module or
            <b>LoadSingleImage</b>.''')
        spill_correct_method = cps.Choice(
            "Spillover correction method",
            [ METHOD_LS, METHOD_NNLS], doc = """
            Select the spillover correction method.
            <ul>
            <li><i>%(METHOD_LS)s:</i> Gives the least square solution
            for overdetermined solutions or the exact solution for exactly 
            constraint problems. </li>
            <li><i>%(METHOD_NNLS)s:</i> Gives the non linear least squares
            solution: The most accurate solution, according to the least
            squares criterium, without any negative values.
            </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("spill_correct_function_image_name",
                              spill_correct_function_image_name)
        image_settings.append("spill_correct_method", spill_correct_method)

        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)
示例#9
0
 def add_image_measurement(self, can_remove = True):
     group = cps.SettingsGroup()
     if can_remove:
         group.append("divider", cps.Divider())
     
     group.append("image_name", cps.ImageNameSubscriber(
         "Select the image to measure",
         cps.NONE, doc = '''
         Choose an image name from the drop-down menu to calculate intensity for that
         image. Use the <i>Add another image</i> button below to add additional images which will be
         measured. You can add the same image multiple times if you want to measure
         the intensity within several different objects.'''))
     
     group.append("wants_objects", cps.Binary(
         "Measure the intensity only from areas enclosed by objects?",
         False, doc = """
         Select <i>%(YES)s</i> to measure only those pixels within an object of choice."""%globals()))
     
     group.append("object_name",cps.ObjectNameSubscriber(
         "Select the input objects",cps.NONE, doc = '''
         <i>(Used only when measuring intensity from area enclosed by objects)</i><br>
         Select the objects that the intensity will be aggregated within. The intensity measurement will be 
         restricted to the pixels within these objects.'''))
     
     if can_remove:
         group.append("remover", cps.RemoveSettingButton("", 
                                                         "Remove this image", self.images, group))
     self.images.append(group)
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE,
                                                  doc="""
            Choose the name of the image to display in the object
            selection user interface.""")

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

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

        self.outlines_name = cps.OutlineNameProvider("Name the outlines",
                                                     "CellOutlines",
                                                     doc="""
            %(NAMING_OUTLINES_HELP)s""" % globals())
示例#11
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE)

        self.conversion_method = cps.Choice("Conversion method",
                                            [MEAN, MEDIAN, CUSTOMFUNCTION],
                                            doc='''
            How do you want to summarize the multichannel image?
            <ul>
            <li><i>%(MEAN)s:</i> Takes the mean.</li>
            <li><i>%(MEDIAN)s</i> Takes the median</li>
            <li><i>%(MEDIAN)s</i> Applies a cutstom python function</li>
            </ul>''' % globals())

        self.custom_function = cps.Text("Input a Python function",
                                        'np.mean',
                                        doc='''
        Can be a simple function as "np.max" (without ") or complicated as "functools.partial(np.percentile,q=80, axis=2)".
        functools is imported as convenience.
        ''')
        # The following settings are used for the combine option
        self.grayscale_name = cps.ImageNameProvider("Name the output image",
                                                    "OrigGray")

        # The alternative model:
        self.channels = []
示例#12
0
    def create_settings(self):
        #
        # The ImageNameSubscriber "subscribes" to all ImageNameProviders in
        # prior modules. Modules before yours will put images into CellProfiler.
        # The ImageSubscriber gives your user a list of these images
        # which can then be used as inputs in your module.
        #
        self.input_image_name = cps.ImageNameSubscriber(
            # The text to the left of the edit box
            "Input image name:",
            # HTML help that gets displayed when the user presses the
            # help button to the right of the edit box
            doc="""This is the image that the module operates on. You can
            choose any image that is made available by a prior module.
            <br>
            <b>ImageTemplate</b> will do something to this image.
            """)

        #
        # The ObjectNameSubscriber is similar - it will ask the user
        # which object to pick from the list of objects provided by
        # upstream modules.
        #
        self.input_object_name = cps.ObjectNameSubscriber(
            "Input object name",
            doc="""These are the objects that the module operates on.""")
示例#13
0
 def create_settings(self):
     self.image_name = cps.ImageNameSubscriber(
         "Select the input image","None", 
         doc = '''What did you call the image in which you want to enhance the edges?''')
     self.output_image_name = cps.ImageNameProvider(
         "Name the output image","EdgedImage",
         doc = '''What do you want to call the image with edges enhanced?''')
     self.wants_automatic_threshold = cps.Binary(
         "Automatically calculate the threshold?", True,
         doc = '''<i>(Used only with the Canny option and automatic thresholding)</i> <br> 
         If you select automatic thresholding, it is done using a three-category
         Otsu algorithm performed on the Sobel transform of the image.''')
     self.manual_threshold = cps.Float(
         "Absolute threshold",.2,0,1, doc = '''<i>(Used only with the Canny option and manual thresholding)</i><br>
         The upper cutoff for Canny edges. All Sobel-transformed 
         pixels with this value or higher will be marked as an edge.
         You can enter a threshold between 0 and 1.''')
     self.threshold_adjustment_factor = cps.Float(
         "Threshold adjustment factor",1, doc = '''<i>(Used only with the Canny option and automatic thresholding)</i><br>
         This threshold adjustment factor is a multiplier that is applied to
         both the lower and upper Canny thresholds if they are calculated
         automatically. An adjustment factor of 1 indicates no adjustment.
         The adjustment factor has no effect on any threshhold entered manually entered.''')
     self.method = cps.Choice(
         "Select an edge-finding method",
         [M_SOBEL, M_PREWITT, M_ROBERTS,
          M_LOG, M_CANNY], doc = '''There are several methods that can be used to enhance edges:
          <ul><li><i>Sobel Method:</i> finds edges using the Sobel approximation to the derivative. 
          The Sobel method derives a horizontal and vertical gradient measure and returns the 
          square-root of the sum of the two squared signals.</li>
          <li><i>Prewitt Method:</i> Finds edges using the Prewitt approximation to the derivative.
          It returns edges at those points where the gradient of the image is maximum.</li>
          <li><i>Roberts Method:</i> Finds edges using the Roberts approximation to the derivative. 
          The Roberts method looks for gradients in the diagonal and anti-diagonal directions 
          and returns the square-root of the sum of the two squared signals. This method is fast,
          but it creates diagonal artifacts that may need to be removed by smoothing.</li> 
          <li><i>LoG Method:</i> Applies a Laplacian of Gaussian filter to the image 
          and finds zero crossings. </li>
          <li><i>Canny Method:</i> Finds edges by looking for local maxima 
          of the gradient of the image. The gradient is calculated using the derivative
          of a Gaussian filter. The method uses two thresholds to detect strong and weak 
          edges, and includes the weak edges in the output only if they are connected to 
          strong edges. This method is therefore less likely than the others to be fooled 
          by noise, and more likely to detect true weak edges.</li></ul>''')
     self.direction = cps.Choice("Select edge direction to enhance",
                                 [ E_ALL, E_HORIZONTAL, E_VERTICAL], doc = '''<i>(Used only with Prewitt and Sobel methods)</i> <br> 
                                 The direction of the edges
                                 are you are identifying in the image (predominantly horizontal, predominantly vertical,
                                 or both).''')
     self.wants_automatic_sigma = cps.Binary("Calculate Gaussian's sigma automatically?", True)
     self.sigma = cps.Float("Gaussian's sigma value", 10)
     self.wants_automatic_low_threshold = cps.Binary(
         "Calculate value for low threshold automatically?", True, 
         doc="""<i>(Used only with the Canny option and automatic thresholding)</i> <br>Automatically calculate the low / soft threshold cutoff for
         the Canny method""")
     self.low_threshold = cps.Float(
         "Low threshold value",.1,0,1,
         doc="""<i>(Used only with the Canny option and manual thresholding)</i><br> The soft threshold cutoff for the Canny method.
         The Canny method will mark all Sobel-transformed pixels with values
         below this threshold as not being edges.""")
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber(
            "Select the input image",
            "None",
            doc="""Choose the name of the image to display in the object
            selection user interface.""")

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

        self.wants_outlines = cps.Binary(
            "Retain outlines of the identified objects?",
            False,
            doc="""Check this setting to save the outlines around the objects
            as a binary image.""")

        self.outlines_name = cps.OutlineNameProvider(
            "Name the outlines",
            "CellOutlines",
            doc=
            """<i>(Used only if outlines are to be saved)</i><br>What do you want to call the outlines image? You can refer to
            this image in subsequent modules, such as <b>SaveImages</b>.""")
示例#15
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)
    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)
 def create_settings(self):
     self.object_name = cps.ObjectNameSubscriber(
         "Input objects",
         "None",
         doc="""Enter the name of the objects whose population context is
         to be measured.""")
     self.operation = cps.Choice(
         "Operation",
         choices=(O_POPULATION_DENSITY, O_DISTANCE_TO_EDGE, O_BOTH),
         doc="""Select the measurements you wish to perform. The choices
         are:<br><ul>
         <li><i>%(O_POPULATION_DENSITY)s</i> - calculate the population
         density within a radius from each cell.</li>
         <li><i>%(O_DISTANCE_TO_EDGE)s</i> - calculate the distance of
         each cell from the edge of a binary mask.</li>
         <li><i>%(O_BOTH)s</i> - make both measurements""" % globals())
     self.radius = cps.Integer(
         "Search radius",
         50,
         minval=1,
         doc="""Count all objects within this radius""")
     self.object_diameter = cps.Integer(
         "Object diameter",
         20,
         minval=0,
         doc="""The average diameter of objects in the image. This number
         is used to adjust the area of the image to account for objects
         that would otherwise be excluded because they were touching
         the border.""")
     self.edge_image = cps.ImageNameSubscriber(
         "Edge image",
         doc="""For measuring distance to an edge, this is the reference
         image. Cell distances will be computed to the nearest foreground / 
         background edge in the reference image.""")
示例#18
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)
示例#19
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)
示例#20
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE,
                                                  doc="""
            Select the image that you want to perform a morphological operation on.
            A grayscale image can be
            converted to binary using the <b>ApplyThreshold</b> module. Objects can be
            converted to binary using the <b>ConvertToImage</b> module.""")

        self.output_image_name = cps.ImageNameProvider("Name the output image",
                                                       "MorphBlue",
                                                       doc="""
            Enter the name for the output image It will be of the same type as the
            input image.""")

        self.add_button = cps.DoSomething("",
                                          "Add another operation",
                                          self.add_function,
                                          doc="""
            Press this button to add an operation that will be applied to the
            image resulting from the previous operation(s). The module repeats
            the previous operation the number of times you select before applying
            the operation added by this button.""")

        self.functions = []
        self.add_function(can_remove=False)
示例#21
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())
示例#22
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  "None")
        self.output_name = cps.ImageNameProvider("Name the output image",
                                                 "FlippedOrigBlue")
        self.flip_choice = cps.Choice(
            "Select method to flip image",
            FLIP_ALL,
            doc=
            """How do you want to flip the image? Left to right, Top to bottom, or both?"""
        )
        self.rotate_choice = cps.Choice("Select method to rotate image",
                                        ROTATE_ALL,
                                        doc='''
             <ul> <li> <i>Angle:</i> Provide the numerical angle by which the 
             image should be rotated.</li>
             <li><i>Coordinates:</i> Provide the X,Y pixel locations of 
             two points in the image that should be aligned horizontally or 
             vertically.</li> 
             <li> <i>Mouse:</i> CellProfiler will pause so you can select the 
             rotation interactively. When prompted during the analysis run, grab the image by 
             clicking the left mouse button, rotate the image by 
             dragging with the mouse, then release the mouse button. Press the <i>Done</i> button on the image 
             after rotating the image appropriately.</li>
             </ul>''')

        self.wants_crop = cps.Binary(
            "Crop away the rotated edges?",
            True,
            doc=
            '''<i>(Used only when rotating images)</i> <br> When an image is rotated, there will be black space at the 
             corners/edges unless you choose to crop away the incomplete rows 
             and columns of the image. This cropping will produce an image that 
             is not exactly the same size as the original, which may affect 
             downstream modules.''')

        self.how_often = cps.Choice(
            "Calculate rotation",
            IO_ALL,
            doc='''<i>(Used only when rotating images with the mouse)</i> <br> 
            Do you want to determine the amount of rotation for each image
            individually as you cycle through, or do you want to define it
            only once (on the first image) and then apply it to all images?''')
        self.first_pixel = cps.Coordinates(
            "Enter coordinates of the top or left pixel", (0, 0))
        self.second_pixel = cps.Coordinates(
            "Enter the coordinates of the bottom or right pixel", (0, 100))
        self.horiz_or_vert = cps.Choice(
            "Select how the specified points should be aligned",
            C_ALL,
            doc=
            """<i>(Used only when rotating images by entering coordinates)</i><br> Should the points you specified be horizontally or vertically aligned after the rotation is complete?"""
        )
        self.angle = cps.Float(
            "Enter angle of rotation",
            0,
            doc=
            """<i>(Used only when rotating images by entering an angle)</i> <br> By what angle would you like to rotate the image 
            (in degrees; positive = counterclockwise and 
            negative = clockwise)?""")
示例#23
0
    def create_settings(self):
        threshold_methods = [
            method for method in TM_METHODS if method != TM_BINARY_IMAGE
        ]
        self.image_name = cpsetting.ImageNameSubscriber(
            "Select the input image",
            doc='''
                                Specify the image to be thresholded.''')

        self.thresholded_image_name = cpsetting.ImageNameProvider(
            "Name the output image",
            "ThreshBlue",
            doc='''
                                Give a name to the thresholded image?''')

        self.binary = cpsetting.Choice("Select the output image type",
                                       [GRAYSCALE, BINARY],
                                       doc='''
                                Two types of output images can be produced:<br>
                                <ul>
                                <li><i>Grayscale:</i> The pixels that are retained after some pixels are set to zero or shifted (based on your selections for thresholding options) will have their original 
                                intensity values.</li>
                                <li><i>Binary:</i> The pixels that are retained after some pixels are set to zero (based on your selections for thresholding options) will be white and all other pixels will be black (zeroes).</li>
                                </ul>''')
        # if not binary:
        self.low_or_high = cpsetting.Choice(
            "Set pixels below or above the threshold to zero?",
            [TH_BELOW_THRESHOLD, TH_ABOVE_THRESHOLD],
            doc=
            """<i>(Used only when thresholding a grayscale image)</i> For grayscale output, the dim pixels below 
                                the threshold can be set to zero or the bright pixels above 
                                the threshold can be set to zero.
                                Choose <i>Below threshold</i> to threshold dim pixels and
                                <i>Above threshold</i> to threshold bright pixels."""
        )

        # if not binary and below threshold

        self.shift = cpsetting.Binary(
            "Subtract the threshold value from the remaining pixel intensities?",
            False,
            doc='''
                                <i>(Used only if the image is grayscale and pixels below a given intensity are to be set to zero)</i><br>
                                Use this setting if the dim pixels are to be shifted in value by the amount of the threshold.'''
        )

        # if not binary and above threshold

        self.dilation = cpsetting.Float(
            "Number of pixels by which to expand the thresholding around those excluded bright pixels",
            0.0,
            doc='''
                                <i>(Used only if the output image is grayscale and pixels above a given intensity are to be set to zero)</i><br>
                                This setting is useful when attempting to exclude bright artifactual objects: 
                                first, set the threshold to exclude these bright objects; it may also be desirable to expand the
                                thresholded region around those bright objects by a certain distance so as to avoid a "halo" effect.'''
        )

        self.create_threshold_settings(threshold_methods)
        self.threshold_smoothing_choice.value = TSM_NONE
示例#24
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)
    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)
示例#26
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE)

        self.probability_maps = []

        self.probability_map_count = cps.HiddenCount(self.probability_maps,
                                                     "Probability map count")

        self.add_probability_map(False)

        self.add_probability_button = cps.DoSomething(
            "",
            "Add another probability map",
            self.add_probability_map,
            doc="""
            Press this button to output another
            probability map image from the classifier. Ilastik can be trained
            to recognize any number of classes of pixels. You can generate
            probability maps for any or all of them simultaneously by adding
            more images.""")

        self.h5_directory = cps.DirectoryPath(
            "Classifier file location",
            dir_choices=[
                DEFAULT_OUTPUT_FOLDER_NAME, DEFAULT_INPUT_FOLDER_NAME,
                ABSOLUTE_FOLDER_NAME, DEFAULT_INPUT_SUBFOLDER_NAME,
                DEFAULT_OUTPUT_SUBFOLDER_NAME, URL_FOLDER_NAME
            ],
            allow_metadata=False,
            doc="""
                Select the folder containing the classifier file to be loaded.
            %(IO_FOLDER_CHOICE_HELP_TEXT)s""" % globals())

        def get_directory_fn():
            '''Get the directory for the CSV file name'''
            return self.h5_directory.get_absolute_path()

        def set_directory_fn(path):
            dir_choice, custom_path = self.h5_directory.get_parts_from_path(
                path)
            self.h5_directory.join_parts(dir_choice, custom_path)

        self.classifier_file_name = cps.FilenameText(
            "Classfier file name",
            cps.NONE,
            doc="""This is the name of the Classfier file.""",
            get_directory_fn=get_directory_fn,
            set_directory_fn=set_directory_fn,
            browse_msg="Choose Classifier file",
            exts=[("Classfier file (*.h5)", "*.h5"),
                  ("All files (*.*)", "*.*")])
        self.no_ilastik_msg = cps.HTMLText("",
                                           content="""
            ClassifyPixels cannot run on this platform because
            the necessary libraries are not available. ClassifyPixels is
            supported on 64-bit versions of Windows Vista, Windows 7 and
            Windows 8 and on Linux.""",
                                           size=(-1, 50))
示例#27
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)
示例#28
0
    def create_settings(self):
        self.blank_image = cps.Binary(
                "Display outlines on a blank image?",
                False, doc="""
            Select <i>%(YES)s</i> to produce an
            image of the outlines on a black background.
            <p>Select <i>%(NO)s</i>, the module will overlay the
            outlines on an image of your choosing.</p>""" % globals())

        self.image_name = cps.ImageNameSubscriber(
                "Select image on which to display outlines", cps.NONE, doc="""
            <i>(Used only when a blank image has not been selected)</i> <br>
            Choose the image to serve as the background for the outlines.
            You can choose from images that were loaded or created by modules
            previous to this one.""")

        self.line_width = cps.Float(
                "Width of outlines", "1", doc="""
            Enter the width, in pixels, of the
            outlines to be displayed on the image.""")

        self.output_image_name = cps.ImageNameProvider(
                "Name the output image", "OrigOverlay", doc="""
            Enter the name of the output image with the outlines overlaid.
            This image can be selected in later modules (for instance, <b>SaveImages</b>).""")

        self.wants_color = cps.Choice(
                "Outline display mode",
                [WANTS_COLOR, WANTS_GRAYSCALE], doc="""
            Specify how to display the outline contours around
            your objects. Color outlines produce a clearer display for
            images where the cell borders have a high intensity, but take
            up more space in memory. Grayscale outlines are displayed with
            either the highest possible intensity or the same intensity
            as the brightest pixel in the image.""")

        self.spacer = cps.Divider(line=False)

        self.max_type = cps.Choice(
                "Select method to determine brightness of outlines",
                [MAX_IMAGE, MAX_POSSIBLE], doc="""
            <i>(Used only when outline display mode is grayscale)</i> <br>
            The following options are possible for setting the intensity
            (brightness) of the outlines:
            <ul>
            <li><i>%(MAX_IMAGE)s:</i> Set the brighness to the
            the same as the brightest point in the image.</li>
            <li><i>%(MAX_POSSIBLE)s:</i> Set to the maximum
            possible value for this image format.</li>
            </ul>
            If your image is quite dim, then putting bright white lines
            onto it may not be useful. It may be preferable to make the
            outlines equal to the maximal brightness already occurring
            in the image.""" % globals())

        self.outlines = []
        self.add_outline(can_remove=False)
        self.add_outline_button = cps.DoSomething("", "Add another outline", self.add_outline)
示例#29
0
 def create_settings(self):
     self.input_image_name = cps.ImageNameSubscriber("Input image", "None")
     self.output_image_name = cps.ImageNameProvider("Output image",
                                                    "Projection")
     self.scale = cps.Float(
         "Scale",
         .125,
         .0001,
         1,
         doc="""Scale the image dimensions by this fraction""")
 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)