示例#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):
     # 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?''')
示例#3
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)
示例#4
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())
示例#5
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.""")
示例#6
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 = []
示例#7
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)?""")
示例#8
0
    def add_probability_map(self, can_remove=True):
        group = cps.SettingsGroup()
        group.can_remove = can_remove
        self.probability_maps.append(group)

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

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

        if can_remove:
            group.remover = cps.RemoveSettingButton("Remove probability map",
                                                    "Remove",
                                                    self.probability_maps,
                                                    group,
                                                    doc="""
                Press the <i>Remove</i> button to remove the
                probability map image from the list of images produced by this
                module""")
示例#9
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
示例#10
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)
示例#11
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)
示例#12
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)
示例#13
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)
示例#14
0
 def create_settings(self):
     self.image_name = cps.ImageNameProvider(
         "Input image name", "TodaysImage")
     #
     # The DirectoryPath setting lets the user pick a directory
     # to be scanned.
     #
     self.folder = cps.DirectoryPath("Folder")
示例#15
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)
示例#16
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>""")
示例#17
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_heatmap(self):
     group = cps.SettingsGroup()
     if len(self.heatmaps) > 0:
         group.append("divider", cps.Divider(line=False))
     group.append("image_name", MORDImageNameSubscriber(
         "Image", doc="""
         The heatmap will be displayed with measurements taken using this image.
         The setting will let you choose from among the images you have
         specified in "Select image to measure".
         """))
     group.image_name.set_module(self)
     group.append("object_name", MORDObjectNameSubscriber(
         "Objects to display", doc = """
         The objects to display in the heatmap. You can select any of the
         objects chosen in "Select objects to measure".
         """))
     group.object_name.set_module(self)
     group.append("bin_count", cps.Choice(
         "Number of bins", self.get_bin_count_choices(), 
         choices_fn = self.get_bin_count_choices))
     def get_number_of_bins(module = self, group=group):
         if len(module.bin_counts) == 1:
             return module.bin_counts[0].bin_count.value
         else:
             return int(group.bin_count.value)
     group.get_number_of_bins = get_number_of_bins
     
     group.append("measurement", cps.Choice(
         "Measurement", MEASUREMENT_CHOICES,
         doc="""The measurement to display."""))
     group.append("colormap", cps.Colormap(
         "Color map", 
         doc="""
         The color map setting chooses the color palette that will be
         used to render the different values for your measurement. If you
         choose "gray", the image will label each of the bins with the
         actual image measurement.
         """))
     group.append("wants_to_save_display", cps.Binary(
         "Save display as image?", False,
         doc = """This setting allows you to save the heatmap display as
         an image that can be output using the <b>SaveImages</b> module.
         Choose <i>%(YES)s</i> to save the display or <i>%(NO)s</i> if the
         display is not needed."""%globals()))
     group.append("display_name", cps.ImageNameProvider(
         "Output image name", "Heatmap",
         doc = """
         <i>(Only used if "Save display as image?" is "%(YES)s")</i><br>
         This setting names the heatmap image so that the name you enter
         here can be selected in a later <b>SaveImages</b> or other module.
         """%globals()))
     group.append("remover", cps.RemoveSettingButton(
         "", "Remove this heatmap display", self.heatmaps, group))
     self.heatmaps.append(group)
    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)
示例#20
0
 def create_settings(self):
     #
     # The ImageNameSubscriber knows about the images that were provided
     # by all of the previous modules and will display those to the user
     # in a drop-down choice box.
     #
     self.input_image_name = cps.ImageNameSubscriber("Input image")
     #
     # The ImageNameProvider tells CellProfiler that this module will
     # provide an image.
     #
     self.output_image_name = cps.ImageNameProvider("Output image",
                                                    "Sharpened")
    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)
示例#22
0
    def add_channel(self, can_remove=True):
        '''Add another channel to the channels list'''
        group = cps.SettingsGroup()
        group.can_remove = can_remove
        group.append(
            "channel_choice",
            cps.Choice("Channel number",
                       self.channel_names,
                       self.channel_names[len(self.channels) %
                                          len(self.channel_names)],
                       doc="""
            This setting chooses a channel to be processed.
            <i>Red: 1</i> is the first channel in a .TIF or the red channel
            in a traditional image file. <i>Green: 2</i> and <i>Blue: 3</i>
            are the second and third channels of a TIF or the green and blue
            channels in other formats. <i>Alpha: 4</i> is the transparency
            channel for image formats that support transparency and is
            channel # 4 for a .TIF file.
            
            <b>ColorToGray</b> will fail to process an image if you select
            a channel that is not supported by that image, for example, "5"
            for a .PNG file"""))

        group.append(
            "contribution",
            cps.Float("Relative weight of the channel",
                      1,
                      0,
                      doc='''
            <i>(Used only when combining channels)</i><br>
            Relative weights: If all relative weights are equal, all three 
            colors contribute equally in the final image. To weight colors relative 
            to each other, increase or decrease the relative weights.'''))

        group.append(
            "image_name",
            cps.ImageNameProvider("Image name",
                                  value="Channel%d" % (len(self.channels) + 1),
                                  doc="""
            This is the name of the grayscale image that holds
            the image data from the chosen channel."""))

        if group.can_remove:
            group.append(
                "remover",
                cps.RemoveSettingButton("", "Remove this channel",
                                        self.channels, group))
        self.channels.append(group)
示例#23
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE,
                                                  doc='''
            Select the image to be resized.''')

        self.cropped_image_name = cps.ImageNameProvider(
            "Name the output image",
            "croppedImage",
            doc='''
            Enter the name of the cropped image.''')

        self.crop_random = cps.Choice('Crop random or specified section?',
                                      [C_RANDOM, C_SPECIFIC])

        self.crop_x = cps.Text("X of upper left corner",
                               '0',
                               doc='''
            X position.''',
                               metadata=True)

        self.crop_y = cps.Text("Y of upper left corner",
                               '0',
                               doc='''
            Y position.''',
                               metadata=True)

        self.crop_w = cps.Text("W width",
                               '100',
                               doc='''
            Width of cut.''',
                               metadata=True)

        self.crop_h = cps.Text("H height",
                               '100',
                               doc='''
            Height of cut.''',
                               metadata=True)

        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)
示例#24
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber('Select the input image',
                                                  cps.NONE)

        self.transformed_image_name = cps.ImageNameProvider(
            "Name the transformed image", 'DistanceImage')

        self.transform_method = cps.Choice('Select a transformation',
                                           [DISTANCE_BORDER],
                                           doc="""
            <ul>
            <li><i>%(DISTANCE_BORDER)s</i> Transforms the binary image to an
            eucledian distance transform to the border between the binary
            regions. The distance to a nonzero pixel will be positive, while
            the distance to a zero pixel will be negative.</li>
            </ul>""" % globals())
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  "None")

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

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

        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
            ],
            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",
            "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 (*.*)", "*.*")])
示例#26
0
    def create_settings(self):
        self.object_name = cps.ObjectNameSubscriber("Select the input objects",
                                                    "None",
                                                    doc="""
                                What did you call the objects you want to convert to an image?"""
                                                    )

        self.image_name = cps.ImageNameProvider("Name the output image",
                                                "CellImage",
                                                doc="""
                                What do you want to call the resulting image?"""
                                                )

        self.image_mode = cps.Choice("Select the color type",
                                     IM_ALL,
                                     doc="""
                                What colors should the resulting image use? Choose how you would like
                                the objects to appear:
                                <ul>
                                <li><i>Color:</i> Allows you to choose a colormap that will
                                produce jumbled colors for your objects. </li>
                                <li><i>Binary:</i> All object pixels will be assigned 1 and all
                                background pixels will be assigned 0, creating a binary image.</li>
                                <li><i>Grayscale:</i> Gives each object
                                a graylevel pixel intensity value corresponding to its number (also
                                called label), so it usually results in objects on the left side of the
                                image being very dark, progressing toward white on the right side of
                                the image. </li>
                                <li><i>uint16:</i> Assigns each object a different number,
                                from 1 to 65535 (the numbers that you can put in
                                a 16-bit integer) and numbers all pixels in each
                                object with the object's number. This format can
                                be written out as a .mat or .tiff file if you
                                want to process the label matrix image using
                                another program.</li>
                                </ul>
                                You can choose <i>Color</i> with a <i>Gray</i> colormap to produce
                                jumbled gray objects.""")

        self.colormap = cps.Colormap(
            "Select the colormap",
            doc="""<i>(Used only if Color output image selected)</i><br>
                                What do you want the colormap to be? This setting affects how the objects are colored. 
                                You can look up your default colormap under <i>File > Preferences</i>."""
        )
示例#27
0
    def add_channelfn(self, can_remove=True):
        '''Add another image channel
		
		can_remove - true if we are allowed to remove this channel
		'''
        group = cps.SettingsGroup()
        self.channels.append(group)

        #Check which cellprofiler image we are in the group
        #(each channel translates to a single cellprofiler image)
        cpimg_index = 0
        for channel in self.channels:
            if id(channel) == id(group):
                break
            cpimg_index += 1

        group.append("divider", cps.Divider(line=True))
        group.append(
            "cpimage_name",
            cps.ImageNameProvider('Image name',
                                  default_cpimage_name(cpimg_index)))
        channel_numbers = [
            str(x) for x in range(0, max(10,
                                         len(self.channels) + 2))
        ]
        group.append(
            "channel_number",
            cps.Choice("Channel number:",
                       channel_numbers,
                       channel_numbers[len(self.channels) - 1],
                       doc="""(Used only for multichannel images)
			The channels of a multichannel image are numbered starting from 0 (zero).
			
			Each channel is a greyscale image, acquired using different
			illumination sources and/or optics. Use this setting to pick
			the channel to associate with the image or images you load from
			OMERO."""))
        group.can_remove = can_remove
        if can_remove:
            group.append(
                "remover",
                cps.RemoveSettingButton("Remove this channel",
                                        "Remove channel", self.channels,
                                        group))
示例#28
0
    def create_settings(self):
        self.object_name = cps.ObjectNameSubscriber("Select the input objects",
                                                    cps.NONE,
                                                    doc="""
            Choose the name of the objects you want to convert to an image.""")

        self.image_name = cps.ImageNameProvider("Name the output image",
                                                "CellImage",
                                                doc="""
            Enter the name of the resulting image.""")

        self.image_mode = cps.Choice("Select the color format",
                                     IM_ALL,
                                     doc="""
            Select which colors the resulting image should use. You have the following
            options:
            <ul>
            <li><i>%(IM_COLOR)s:</i> Allows you to choose a colormap that will
            produce jumbled colors for your objects. </li>
            <li><i>%(IM_BINARY)s:</i> All object pixels will be assigned 1 and all
            background pixels will be assigned 0, creating a binary image.</li>
            <li><i>%(IM_GRAYSCALE)s:</i> Gives each object
            a graylevel pixel intensity value corresponding to its number (also
            called label), so it usually results in objects on the left side of the
            image being very dark, progressing toward white on the right side of
            the image. </li>
            <li><i>%(IM_UINT16)s:</i> Assigns each object a different number,
            from 1 to 65535 (the numbers that you can put in
            a 16-bit integer) and numbers all pixels in each
            object with the object's number. This format can
            be written out as a .mat or .tiff file if you
            want to process the label matrix image using
            another program.</li>
            </ul>
            You can choose <i>Color</i> with a <i>Gray</i> colormap to produce
            jumbled gray objects.""" % globals())

        self.colormap = cps.Colormap("Select the colormap",
                                     doc="""
            <i>(Used only if Color output image selected)</i><br>
            Choose the colormap to be used, which affects how the objects are colored. 
            You can look up your default colormap under <i>File > Preferences</i>."""
                                     )
示例#29
0
    def create_settings(self):
        self.input_type = cps.Choice("Select the type of input",
                                     [IF_IMAGE, IF_OBJECTS], IF_IMAGE)

        self.image_name = cps.ImageNameSubscriber("Select input images",
                                                  cps.NONE)

        self.objects_name = cps.ObjectNameSubscriber(
            "Select the input objects",
            cps.NONE,
        )

        self.output_name = cps.ImageNameProvider(
            "Input the output image stack name",
            "BinStack",
            doc="""
            Input the output name.
            """ % globals())

        self.main_object_def = cps.Choice(
            "How should the main label be determined?",
            [SEL_MID, SEL_MAXAREA, SEL_PROVIDED],
            SEL_MID,
            doc="""
            The main object can be determined by 3 ways:
            <ul>
            <li> %(SEL_PROVIDED)s: Label provided by metadata or
            manual. <\li>
            <li> %(SEL_MAXAREA)s: Label with the biggest area is assumed to be
            the main label. <\li>
            <li> %(SEL_MID)s: The label closest to the middle of the image is
            considered the main label. <\li>
            <\ul>
            """ % globals())

        self.main_object_id = cps.Text("Indicate the object id",
                                       '1',
                                       doc="""
                Indicates the id from the main object.
                Rightclick to choose a metadata value.
                """ % globals(),
                                       metadata=True)
示例#30
0
 def create_settings(self):
     #
     # Put your ImageNameProvider and ImageNameSubscriber here
     #
     # use self.input_image_name as the ImageNameSubscriber
     # use self.output_image_name as the ImageNameProvider
     #
     # Those are the names that are expected by the unit tests.
     #
     self.input_image_name = cps.ImageNameSubscriber("Input image")
     self.output_image_name = cps.ImageNameProvider("Output image", 
                                                    "Sharpened")
     self.scale = cps.Float(
         "Scale", .5, 0,
     doc="""This is the sigma of the Gaussian used as the point spread function""")
     #
     # We use a number of iterations to perform. An alternative or adjunct
     # would be to have the loop exit based on the estimated error reaching
     # a certain value
     #
     self.iterations = cps.Integer(
         "Iterations", 10, 1,
         doc = """The number of times to iterate toward maximum likelihood
         estimate.""")