def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE)

        self.output_name = cps.ImageNameProvider("Name the output image",
                                                 "FlippedOrigBlue")

        self.flip_choice = cps.Choice("Select method to flip image",
                                      FLIP_ALL,
                                      doc="""
            Select how the image is to be flipped.""")

        self.rotate_choice = cps.Choice("Select method to rotate image",
                                        ROTATE_ALL,
                                        doc='''
            <ul>
            <li><i>%(ROTATE_NONE)s:</i> Leave the image unrotated. This should be used
            if you want to flip the image only.</li>
            <li><i>%(ROTATE_ANGLE)s:</i> Provide the numerical angle by which the
            image should be rotated.</li>
            <li><i>%(ROTATE_COORDINATES)s:</i> Provide the X,Y pixel locations of
            two points in the image that should be aligned horizontally or
            vertically.</li>
            <li><i>%(ROTATE_MOUSE)s:</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>''' % globals())

        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; select <i>%(YES)s</i> to crop away the incomplete rows
            and columns of the image, or select <i>%(NO)s</i> to leave it as-is.
            <p>This cropping will produce an image that
            is not exactly the same size as the original, which may affect
            downstream modules.</p>''' % globals())

        self.how_often = cps.Choice("Calculate rotation",
                                    IO_ALL,
                                    doc='''
            <i>(Used only when using "%(ROTATE_MOUSE)s" to rotate images)</i> <br>
            Select the cycle(s) at which the calculation is requested and calculated.
            <ul>
            <li><i>%(IO_INDIVIDUALLY)s:</i> Determine the amount of rotation for each image
            individually, e.g., for each cycle.</li>
            <li><i>%(IO_ONCE)s:</i> Define the rotation only once (on the first image), then
            then apply it to all images.</li>
            </ul>''' % globals())

        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 using "%(ROTATE_COORDINATES)s" to rotate images)</i><br>
            Specify whether you would like the coordinate points that
            you entered to be horizontally or
            vertically aligned after the rotation is complete.""" % globals())

        self.angle = cps.Float("Enter angle of rotation",
                               0,
                               doc="""
            <i>(Used only when using "%(ROTATE_ANGLE)s" to rotate images)</i> <br>
            Enter the angle you would like to rotate the image.
            This setting is in degrees, with positive angles corresponding
            to counterclockwise and negative as clockwise.""" % globals())
示例#2
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE,
                                                  doc="""
            Choose the image to be cropped.""")

        self.cropped_image_name = cps.CroppingNameProvider(
            "Name the output image",
            "CropBlue",
            doc="""
            Enter the name to be given to cropped image.""")

        self.shape = cps.Choice(
            "Select the cropping shape",
            [SH_RECTANGLE, SH_ELLIPSE, SH_IMAGE, SH_OBJECTS, SH_CROPPING],
            SH_RECTANGLE,
            doc="""
            Select the shape into which you would like to crop:
            <ul>
            <li><i>%(SH_RECTANGLE)s:</i> Self-explanatory.</li>
            <li><i>%(SH_ELLIPSE)s:</i> Self-explanatory.</li>
            <li><i>%(SH_IMAGE)s:</i> Cropping will occur based on a binary image you specify. A choice box
            with available images will appear from which
            you can select an image. To crop into an arbitrary shape that you define, choose
            <i>%(SH_IMAGE)s</i> and use the <b>LoadSingleImage</b> module to load a black and white image
            that you have already prepared from a file. If you have created this image in a
            program such as Photoshop, this binary image should contain only the values 0 and 255,
            with zeros (black) for the parts you want to remove and 255 (white) for
            the parts you want to retain. Alternately, you may have previously generated a
            binary image using this module (e.g., using the <i>%(SH_ELLIPSE)s</i> option) and saved
            it using the <b>SaveImages</b> module.<br>
            In any case, the image must be exactly the same starting size as your image
            and should contain a contiguous block of white pixels, because
            the cropping module may remove rows and columns that are
            completely blank.</li>
            <li><i>%(SH_OBJECTS)s:</i> Crop based on labeled objects identified by a previous
            <b>Identify</b> module.</li>
            <li><i>%(SH_CROPPING)s:</i> The cropping generated by a previous cropping module.
            You will be able to select images that were generated by previous <b>Crop</b> modules.
            This <b>Crop</b> module will use the same cropping that was used to generate whichever image
            you choose.</li>
            </ul>""" % globals())

        self.crop_method = cps.Choice("Select the cropping method",
                                      [CM_COORDINATES, CM_MOUSE],
                                      CM_COORDINATES,
                                      doc="""
            Choose whether you would like to crop by typing in pixel coordinates or clicking with the mouse.
            <ul>
            <li><i>%(CM_COORDINATES)s:</i> For <i>%(SH_ELLIPSE)s</i>, you will be asked to enter the geometric
            parameters of the ellipse. For <i>%(SH_RECTANGLE)s</i>, you will be asked to specify
            the coordinates of the corners.</li>
            <li><i>%(CM_MOUSE)s:</i> For <i>%(SH_ELLIPSE)s</i>, you will be asked to click five or more
            points to define an ellipse around the part of the image you want to
            analyze.  Keep in mind that the more points you click, the longer it will
            take to calculate the ellipse shape. For <i>%(SH_RECTANGLE)s</i>, you can click as many
            points as you like that are in the interior of the region you wish to
            retain.</li>
            </ul>""" % globals())

        self.individual_or_once = cps.Choice(
            "Apply which cycle's cropping pattern?",
            [IO_INDIVIDUALLY, IO_FIRST],
            IO_INDIVIDUALLY,
            doc="""
            Specify how a given cropping pattern should be
            applied to other image cycles:
            <ul>
            <li><i>%(IO_FIRST)s:</i> The cropping pattern from the first image cycle is applied to all
            subsequent cyles. This is useful if the first image is intended to function as a template
            in some fashion.</li>
            <li><i>%(IO_INDIVIDUALLY)s:</i> Every image cycle is cropped individually.</li>
            </ul>""" % globals())

        self.horizontal_limits = cps.IntegerOrUnboundedRange(
            "Left and right rectangle positions",
            minval=0,
            doc="""
            <i>(Used only if %(SH_RECTANGLE)s selected as cropping shape, or if using Plate Fix)</i><br>
            Specify the left and right positions for the bounding rectangle by selecting one of the following:<br>
            <ul>
            <li><i>%(ABSOLUTE)s:</i> Specify these values as absolute pixel
            coordinates in the original image. For instance, you might enter
            "25", "225", and "Absolute" to create a 200&times;200 pixel image that is
            25 pixels from the top-left corner.</li>
            <li><i>%(FROM_EDGE)s:</i> Specify the position relative to the image
            edge. For instance, you might enter "25", "25", and "Edge" to
            crop 25 pixels from both the left and right edges of the image, irrespective
            of the image's original size.</li>
            </ul>""" % globals())

        self.vertical_limits = cps.IntegerOrUnboundedRange(
            "Top and bottom rectangle positions",
            minval=0,
            doc="""
            <i>(Used only if %(SH_RECTANGLE)s selected as cropping shape, or if using Plate Fix)</i><br>
            Specify the top and bottom positions for the bounding rectangle by selecting one of the following:<br>
            <ul>
            <li><i>%(ABSOLUTE)s:</i> Specify these values as absolute pixel coordinates.
            For instance, you might enter "25", "225", and "Absolute"
            to create a 200&times;200 pixel image that's 25 pixels
            from the top-left corner.</li>
            <li><i>%(FROM_EDGE)s:</i> Specify position relative to the image edge.
            For instance, you might enter "25", "25", and "Edge" to
            crop 25 pixels from the edges of your images irrespective
            of their size.</li>
            </ul>""" % globals())

        self.ellipse_center = cps.Coordinates("Coordinates of ellipse center",
                                              (500, 500),
                                              doc="""
            <i>(Used only if %(SH_ELLIPSE)s selected as cropping shape)</i><br>
            Specify the center pixel position of the ellipse.""" % globals())

        self.ellipse_x_radius = cps.Integer("Ellipse radius, X direction",
                                            400,
                                            doc="""
            <i>(Used only if %(SH_ELLIPSE)s selected as cropping shape)</i><br>
            Specify the radius of the ellipse in the X direction.""" %
                                            globals())

        self.ellipse_y_radius = cps.Integer("Ellipse radius, Y direction",
                                            200,
                                            doc="""
            <i>(Used only if %(SH_ELLIPSE)s selected as cropping shape)</i><br>
            Specify the radius of the ellipse in the Y direction.""" %
                                            globals())

        self.image_mask_source = cps.ImageNameSubscriber(
            "Select the masking image",
            cps.NONE,
            doc="""
            <i>(Used only if %(SH_IMAGE)s selected as cropping shape)</i><br>
            Select the image to be use as a cropping mask.""" % globals())

        self.cropping_mask_source = cps.CroppingNameSubscriber(
            "Select the image with a cropping mask",
            cps.NONE,
            doc="""
            <i>(Used only if %(SH_CROPPING)s selected as cropping shape)</i><br>
            Select the image associated with the cropping mask that you want to use."""
            % globals())

        self.objects_source = cps.ObjectNameSubscriber("Select the objects",
                                                       cps.NONE,
                                                       doc="""
            <i>(Used only if %(SH_OBJECTS)s selected as cropping shape)</i><br>
            Select the objects that are to be used as a cropping mask.""" %
                                                       globals())

        self.use_plate_fix = cps.Binary("Use Plate Fix?",
                                        False,
                                        doc="""
            <i>(Used only if %(SH_IMAGE)s selected as cropping shape)</i><br>
            Select <i>%(YES)s</i> to attempt to regularize the edges around a previously-identified
            plate object.
            <p>When attempting to crop based on a previously identified object
            such as a rectangular plate, the plate may not have
            precisely straight edges: there might be a tiny, almost unnoticeable
            "appendage" sticking out. Without Plate Fix, the <b>Crop</b>
            module would not crop the image tightly enough: it would retain the tiny appendage, leaving a lot
            of blank space around the plate and potentially causing problems with later
            modules (especially ones involving illumination correction). </p>
            <p>Plate Fix takes the
            identified object and crops to exclude any minor appendages (technically,
            any horizontal or vertical line where the object covers less than 50%% of
            the image). It also sets pixels around the edge of the object (for
            regions greater than 50%% but less than 100%%) that otherwise would be 0 to the
            background pixel value of your image, thus avoiding problems with
            other modules. </p>
            <p><i>Important note:</i> Plate Fix uses the coordinates
            entered in the boxes normally used for rectangle cropping (Top, Left and
            Bottom, Right) to tighten the edges around your identified plate. This
            is done because in the majority of plate identifications you do not want
            to include the sides of the plate. If you would like the entire plate to
            be shown, you should enter "1:end" for both coordinates. If, for example, you would like
            to crop 80 pixels from each edge of the plate, you could enter Top, Left and Bottom,
            Right values of 80 and select <i>%(FROM_EDGE)s</i>.</p>""" %
                                        globals())

        self.remove_rows_and_columns = cps.Choice(
            "Remove empty rows and columns?", [RM_NO, RM_EDGES, RM_ALL],
            RM_ALL,
            doc="""
            Use this option to choose whether to remove rows and columns that lack objects:
            <ul>
            <li><i>%(RM_NO)s:</i> Leave the image the same size. The cropped areas will be set
            to zeroes, and will appear as black.</li>
            <li><i>%(RM_EDGES)s:</i> Crop the image so that its top, bottom, left and right are at
            the first non-blank pixel for that edge.</li>
            <li><i>%(RM_ALL)s:</i> Remove any row or column of all-blank pixels, even from the
            internal portion of the image.</li>
            </ul>""" % globals())
示例#3
0
    def create_settings(self):
        """Create your settings by subclassing this function

        create_settings is called at the end of initialization.
        """
        self.grid_image = cps.GridNameProvider("Name the grid",
                                               doc="""\
This is the name of the grid. You can use this name to
retrieve the grid in subsequent modules.""")

        self.grid_rows = cps.Integer(
            "Number of rows",
            8,
            1,
            doc="""Along the height of the grid, define the number of rows""")

        self.grid_columns = cps.Integer(
            "Number of columns",
            12,
            1,
            doc="""Along the width of the grid, define the number of columns"""
        )

        self.origin = cps.Choice(
            "Location of the first spot",
            [NUM_TOP_LEFT, NUM_BOTTOM_LEFT, NUM_TOP_RIGHT, NUM_BOTTOM_RIGHT],
            doc="""\
Grid cells are numbered consecutively; this option identifies the
origin for the numbering system and the direction for numbering.
For instance, if you choose "*%(NUM_TOP_LEFT)s*", the top left cell is
cell #1 and cells to the right and bottom are indexed with
larger numbers.""" % globals())

        self.ordering = cps.Choice("Order of the spots",
                                   [NUM_BY_ROWS, NUM_BY_COLUMNS],
                                   doc="""\
Grid cells can either be numbered by rows, then columns or by columns,
then rows. For instance, you might ask to start numbering a 96-well
plate at the top left (by specifying the location of the first spot).

-  *%(NUM_BY_ROWS)s:* This option will give well A01 the index 1, B01
   the index 2, and so on up to H01 which receives the index 8. Well A02
   will be assigned the index 9.
-  *%(NUM_BY_COLUMNS)s:* With this option, the well A02 will be
   assigned 2, well A12 will be assigned 12 and well B01 will be
   assigned 13.
""" % globals())

        self.each_or_once = cps.Choice("Define a grid for which cycle?",
                                       [EO_EACH, EO_ONCE],
                                       doc="""\
The setting allows you choose when you want to define a new grid:

-  *%(EO_ONCE)s:* If all of your images are perfectly aligned with each
   other (due to very consistent image acquisition, consistent grid
   location within the plate, and/or automatic cropping precisely within
   each plate), you can define the location of the marker spots once for
   all of the image cycles.
-  *%(EO_EACH)s:* If the location of the grid will vary from one image
   cycle to the next then you should define the location of the marker
   spots for each cycle independently.
""" % globals())

        self.auto_or_manual = cps.Choice(
            "Select the method to define the grid", [AM_AUTOMATIC, AM_MANUAL],
            doc="""\
Select whether you would like to define the grid automatically (based on
objects you have identified in a previous module) or manually. This
setting controls how the grid is defined:

-  *%(AM_MANUAL)s:* In manual mode, you manually indicate known
   locations of marker spots in the grid and have the rest of the
   positions calculated from those marks, no matter what the image
   itself looks like. You can define the grid either by clicking on the
   image with a mouse or by entering coordinates.
-  *%(AM_AUTOMATIC)s:* If you would like the grid to be defined
   automatically, an **IdentifyPrimaryObjects** module must be run prior
   to this module to identify the objects which will be used to define
   the grid. The left-most, right-most, top-most, and bottom-most object
   will be used to define the edges of the grid, and the rows and
   columns will be evenly spaced between these edges. Note that
   Automatic mode requires that the incoming objects are nicely defined:
   for example, if there is an object at the edge of the images that is
   not really an object that ought to be in the grid, a skewed grid will
   result. You might wish to use a **FilterObjects** module to clean up
   badly identified objects prior to defining the grid. If the spots are
   slightly out of alignment with each other from one image cycle to the
   next, this allows the identification to be a bit flexible and adapt
   to the real location of the spots.
""" % globals())

        self.object_name = cps.ObjectNameSubscriber(
            "Select the previously identified objects",
            cps.NONE,
            doc="""\
*(Used only if you selected "%(AM_AUTOMATIC)s" to define the grid)*

Select the previously identified objects you want to use to define the
grid. Use this setting to specify the name of the objects that will be
used to define the grid.
""" % globals())

        self.manual_choice = cps.Choice(
            "Select the method to define the grid manually",
            [MAN_MOUSE, MAN_COORDINATES],
            doc="""\
*(Used only if you selected "%(AM_MANUAL)s" to define the grid)*

Specify whether you want to define the grid using the mouse or by
entering the coordinates of the cells.

-  *%(MAN_MOUSE)s:* The user interface displays the image you specify.
   You will be asked to click in the center of two of the grid cells and
   specify the row and column for each. The grid coordinates will be
   computed from this information.
-  *%(MAN_COORDINATES)s:* Enter the X and Y coordinates of the grid
   cells directly. You can display an image of your grid to find the
   locations of the centers of the cells, then enter the X and Y
   position and cell coordinates for each of two cells.
""" % globals())

        self.manual_image = cps.ImageNameSubscriber(
            "Select the image to display",
            cps.NONE,
            doc="""\
*(Used only if you selected "%(AM_MANUAL)s" and "%(MAN_MOUSE)s" to define
the grid)*

Specify the image you want to display when defining the grid. This
setting lets you choose the image to display in the grid definition user
interface.
""" % globals())

        self.first_spot_coordinates = cps.Coordinates(
            "Coordinates of the first cell", (0, 0),
            doc="""\
*(Used only if you selected "%(AM_MANUAL)s" and "%(MAN_COORDINATES)s" to
define the grid)*

Enter the coordinates of the first cell on your grid. This setting
defines the location of the first of two cells in your grid. You should
enter the coordinates of the center of the cell. You can display an
image of your grid and use the pixel coordinate display to determine the
coordinates of the center of your cell.
""" % globals())

        self.first_spot_row = cps.Integer("Row number of the first cell",
                                          1,
                                          minval=1,
                                          doc="""\
*(Used only if you selected "%(AM_MANUAL)s" and "%(MAN_COORDINATES)s" to
define the grid)*

Enter the row index for the first cell here. Rows are numbered starting
at the origin. For instance, if you chose "*%(NUM_TOP_LEFT)s*" as your
origin, well A01 will be row number 1 and H01 will be row number 8. If
you chose "*%(NUM_BOTTOM_LEFT)s*", A01 will be row number 8 and H01 will
be row number 12.
""" % globals())

        self.first_spot_col = cps.Integer("Column number of the first cell",
                                          1,
                                          minval=1,
                                          doc="""\
*(Used only if you selected "%(AM_MANUAL)s" and "%(MAN_COORDINATES)s" to
define the grid)*

Enter the column index for the first cell here. Columns are numbered
starting at the origin. For instance, if you chose "*%(NUM_TOP_LEFT)s*"
as your origin, well A01 will be column number *1* and A12 will be
column number *12*. If you chose "*%(NUM_TOP_RIGHT)s*", A01 and A12 will
be *12* and *1*, respectively.
""" % globals())

        self.second_spot_coordinates = cps.Coordinates(
            "Coordinates of the second cell", (0, 0),
            doc="""\
*(Used only if you selected "%(AM_MANUAL)s" and "%(MAN_COORDINATES)s" to
define the grid)*

This setting defines the location of the second of two cells in your
grid. You should enter the coordinates of the center of the cell. You
can display an image of your grid and use use the pixel coordinate
display to determine the coordinates of the center of your cell.
""" % globals())

        self.second_spot_row = cps.Integer("Row number of the second cell",
                                           1,
                                           minval=1,
                                           doc="""\
*(Used only if you selected "%(AM_MANUAL)s" and "%(MAN_COORDINATES)s" to
define the grid)*

Enter the row index for the second cell here. Rows are numbered starting
at the origin. For instance, if you chose "*%(NUM_TOP_LEFT)s*" as your
origin, well A01 will be row number 1 and H01 will be row number 8. If
you chose "*%(NUM_BOTTOM_LEFT)s*", A01 will be row number 8 and H01 will
be row number 12.
""" % globals())

        self.second_spot_col = cps.Integer("Column number of the second cell",
                                           1,
                                           minval=1,
                                           doc="""\
*(Used only if you selected "%(AM_MANUAL)s" and "%(MAN_COORDINATES)s" to
define the grid)*

Enter the column index for the second cell here. Columns are numbered
starting at the origin. For instance, if you chose "*%(NUM_TOP_LEFT)s*"
as your origin, well A01 will be column number 1 and A12 will be column
number 12. If you chose "*%(NUM_TOP_RIGHT)s*", A01 and A12 will be 12
and 1, respectively.
""" % globals())

        self.wants_image = cps.Binary("Retain an image of the grid?",
                                      False,
                                      doc="""\
Select "*%(YES)s*" to retain an image of the grid for use later in the
pipeline. This module can create an annotated image of the grid that can
be saved using the **SaveImages** module.
""" % globals())

        self.display_image_name = cps.ImageNameSubscriber(
            "Select the image on which to display the grid",
            cps.LEAVE_BLANK,
            can_be_blank=True,
            doc="""\
*(Used only if saving an image of the grid)*

Enter the name of the image that should be used as the background for
annotations (grid lines and grid indexes). This image will be used for
the figure and for the saved image.
""")

        self.save_image_name = cps.ImageNameProvider("Name the output image",
                                                     "Grid",
                                                     doc="""\
*(Used only if retaining an image of the grid for use later in the
pipeline)*

Enter the name you want to use for the output image. You can save this
image using the **SaveImages** module.
""")

        self.failed_grid_choice = cps.Choice(
            "Use a previous grid if gridding fails?",
            [FAIL_NO, FAIL_ANY_PREVIOUS, FAIL_FIRST],
            doc="""\
If the gridding fails, this setting allows you to control how the module
responds to the error:

-  *%(FAIL_NO)s:* The module will stop the pipeline if gridding fails.
-  *%(FAIL_ANY_PREVIOUS)s:*: The module will use the the most recent
   successful gridding.
-  *%(FAIL_FIRST)s:* The module will use the first gridding.

Note that the pipeline will stop in all cases if gridding fails on the
first image.
""" % globals())
示例#4
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE,
                                                  doc="""\
Choose the image to be cropped.""")

        self.cropped_image_name = cps.CroppingNameProvider(
            "Name the output image",
            "CropBlue",
            doc="""\
Enter the name to be given to cropped image.""")

        self.shape = cps.Choice(
            "Select the cropping shape",
            [SH_RECTANGLE, SH_ELLIPSE, SH_IMAGE, SH_OBJECTS, SH_CROPPING],
            SH_RECTANGLE,
            doc="""\
Select the shape into which you would like to crop:

-  *%(SH_RECTANGLE)s:* Self-explanatory.
-  *%(SH_ELLIPSE)s:* Self-explanatory.
-  *%(SH_IMAGE)s:* Cropping will occur based on a binary image you
   specify. A choice box with available images will appear from which
   you can select an image. To crop into an arbitrary shape that you
   define, choose *%(SH_IMAGE)s* and use the **LoadSingleImage** module
   to load a black and white image that you have already prepared from a
   file. If you have created this image in a program such as Photoshop,
   this binary image should contain only the values 0 and 255, with
   zeros (black) for the parts you want to remove and 255 (white) for
   the parts you want to retain. Alternately, you may have previously
   generated a binary image using this module (e.g., using the
   *%(SH_ELLIPSE)s* option) and saved it using the **SaveImages**
   module.
   In any case, the image must be exactly the same starting size as your
   image and should contain a contiguous block of white pixels, because
   the cropping module may remove rows and columns that are completely
   blank.
-  *%(SH_OBJECTS)s:* Crop based on labeled objects identified by a
   previous **Identify** module.
-  *%(SH_CROPPING)s:* The cropping generated by a previous cropping
   module. You will be able to select images that were generated by
   previous **Crop** modules. This **Crop** module will use the same
   cropping that was used to generate whichever image you choose.
""" % globals())

        self.crop_method = cps.Choice("Select the cropping method",
                                      [CM_COORDINATES, CM_MOUSE],
                                      CM_COORDINATES,
                                      doc="""\
Choose whether you would like to crop by typing in pixel coordinates or
clicking with the mouse.

-  *%(CM_COORDINATES)s:* For *%(SH_ELLIPSE)s*, you will be asked to
   enter the geometric parameters of the ellipse. For
   *%(SH_RECTANGLE)s*, you will be asked to specify the coordinates of
   the corners.
-  *%(CM_MOUSE)s:* For *%(SH_ELLIPSE)s*, you will be asked to click
   five or more points to define an ellipse around the part of the image
   you want to analyze. Keep in mind that the more points you click, the
   longer it will take to calculate the ellipse shape. For
   *%(SH_RECTANGLE)s*, you can click as many points as you like that
   are in the interior of the region you wish to retain.
""" % globals())

        self.individual_or_once = cps.Choice(
            "Apply which cycle's cropping pattern?",
            [IO_INDIVIDUALLY, IO_FIRST],
            IO_INDIVIDUALLY,
            doc="""\
Specify how a given cropping pattern should be applied to other image cycles:

-  *%(IO_FIRST)s:* The cropping pattern from the first image cycle is
   applied to all subsequent cyles. This is useful if the first image is
   intended to function as a template in some fashion.
-  *%(IO_INDIVIDUALLY)s:* Every image cycle is cropped individually.
""" % globals())

        self.horizontal_limits = cps.IntegerOrUnboundedRange(
            "Left and right rectangle positions",
            minval=0,
            doc="""\
*(Used only if "%(SH_RECTANGLE)s" selected as cropping shape, or if using Plate Fix)*

Specify the left and right positions for the bounding rectangle by selecting one of the following:

-  *%(ABSOLUTE)s:* Specify these values as absolute pixel coordinates in
   the original image. For instance, you might enter “25”, “225”, and
   “Absolute” to create a 200×200 pixel image that is 25 pixels from the
   top-left corner.
-  *%(FROM_EDGE)s:* Specify the position relative to the image edge.
   For instance, you might enter “25”, “25”, and “Edge” to crop 25
   pixels from both the left and right edges of the image, irrespective
   of the image’s original size.
""" % globals())

        self.vertical_limits = cps.IntegerOrUnboundedRange(
            "Top and bottom rectangle positions",
            minval=0,
            doc="""\
*(Used only if "%(SH_RECTANGLE)s" selected as cropping shape, or if using Plate Fix)*

Specify the top and bottom positions for the bounding rectangle by selecting one of the following:

-  *%(ABSOLUTE)s:* Specify these values as absolute pixel coordinates.
   For instance, you might enter “25”, “225”, and “Absolute” to create a
   200×200 pixel image that’s 25 pixels from the top-left corner.
-  *%(FROM_EDGE)s:* Specify position relative to the image edge. For
   instance, you might enter “25”, “25”, and “Edge” to crop 25 pixels
   from the edges of your images irrespective of their size.
""" % globals())

        self.ellipse_center = cps.Coordinates("Coordinates of ellipse center",
                                              (500, 500),
                                              doc="""\
*(Used only if "%(SH_ELLIPSE)s" selected as cropping shape)*

Specify the center pixel position of the ellipse.""" % globals())

        self.ellipse_x_radius = cps.Integer("Ellipse radius, X direction",
                                            400,
                                            doc="""\
*(Used only if "%(SH_ELLIPSE)s" selected as cropping shape)*

Specify the radius of the ellipse in the X direction.""" % globals())

        self.ellipse_y_radius = cps.Integer("Ellipse radius, Y direction",
                                            200,
                                            doc="""\
*(Used only if "%(SH_ELLIPSE)s" selected as cropping shape)*

Specify the radius of the ellipse in the Y direction.""" % globals())

        self.image_mask_source = cps.ImageNameSubscriber(
            "Select the masking image",
            cps.NONE,
            doc="""\
*(Used only if "%(SH_IMAGE)s" selected as cropping shape)*

Select the image to be use as a cropping mask.""" % globals())

        self.cropping_mask_source = cps.CroppingNameSubscriber(
            "Select the image with a cropping mask",
            cps.NONE,
            doc="""\
*(Used only if "%(SH_CROPPING)s" selected as cropping shape)*

Select the image associated with the cropping mask that you want to use.""" %
            globals())

        self.objects_source = cps.ObjectNameSubscriber("Select the objects",
                                                       cps.NONE,
                                                       doc="""\
*(Used only if "%(SH_OBJECTS)s" selected as cropping shape)*

Select the objects that are to be used as a cropping mask.""" % globals())

        self.remove_rows_and_columns = cps.Choice(
            "Remove empty rows and columns?", [RM_NO, RM_EDGES, RM_ALL],
            RM_ALL,
            doc="""\
Use this option to choose whether to remove rows and columns that lack
objects:

-  *%(RM_NO)s:* Leave the image the same size. The cropped areas will
   be set to zeroes, and will appear as black.
-  *%(RM_EDGES)s:* Crop the image so that its top, bottom, left and
   right are at the first non-blank pixel for that edge.
-  *%(RM_ALL)s:* Remove any row or column of all-blank pixels, even
   from the internal portion of the image.""" % globals())