Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_settings(self):
self.csv_directory_choice = cps.Choice("File location", DIR_ALL, doc="""
The folder that contains the CSV file. You can choose among the following options:
<ul><li><i>Default Input Folder</i>:
The CSV file is in the default input folder.</li>
<li><i>Default Output
Folder:</i> The CSV file is in the default output folder.</li>
<li><i>Elsewhere...</i>: You can enter a custom folder name.</li></ul>
<p>Custom folder names that start with "." are relative to the default input folder. Names that
start with "&" are relative to the default output folder. Two periods ".." specify to go
up one folder level. For example, "./CSVfiles" looks for a folder called <i>CSVfiles</i> that is
contained within the default input folder,
and <i>&/../My_folder" looks in a folder called "My_folder"
at the same level as the output folder.""")
self.csv_custom_directory = cps.DirectoryPath("Custom file location",
".", doc = </i></p>
group.append("divider", cps.Divider(line=False))
group.append("outline_name",
cps.OutlineNameSubscriber(
"Select outlines to display",
"None", doc="""
Choose outlines to display, from a previous <b>Identify</b>,
module. Each of the <b>Identify</b> modules has a checkbox that
determines whether the outlines are saved. If you have checked this,
you were asked to supply a name for the outline; you
can then select that name here.
"""))
default_color = (COLOR_ORDER[len(self.outlines)]
if len(self.outlines) < len(COLOR_ORDER)
else COLOR_ORDER[0])
group.append("color", cps.Choice(
"Select outline color",
COLORS.keys(), default_color))
if can_remove:
group.append("remover", cps.RemoveSettingButton("", "Remove this outline", self.outlines, group))
self.outlines.append(group)
files accessible via the web, you can enter a url prefix here. Eg:
If an image is loaded from the path "/cellprofiler/images/" and you use
a url prepend of "http://mysite.com/", CellProfiler Analyst will look
for your file at "http://mysite.com/cellprofiler/images/"
<p>If you are not using the web to access your files (i.e., they are locally
aceesible by your computer), leave this setting blank.""")
self.properties_plate_type = cps.Choice("Select the plate type",
PLATE_TYPES,
doc="""<i>(Used only if creating a properties file)</i><br>
If you are using a multi-well plate or microarray, you can select the plate
type here. Supported types in CellProfiler Analyst are 96- and 384-well plates,
as well as 5600-spot microarrays. If you are not using a plate or microarray, select
<i>None</i>.""")
self.properties_plate_metadata = cps.Choice("Select the plate metadata",
["None"],choices_fn = self.get_metadata_choices,
doc="""<i>(Used only if creating a properties file)</i><br>
If you are using a multi-well plate or microarray, you can select the metadata corresponding
to the plate here. If there is no plate metadata associated with the image set, select
<i>None</i>.
</p><p>%(USING_METADATA_HELP_REF)s.</p>"""% globals())
self.properties_well_metadata = cps.Choice("Select the well metadata",
["None"],choices_fn = self.get_metadata_choices,
doc="""<i>(Used only if creating a properties file)</i><br>
If you are using a multi-well plate or microarray, you can select the metadata corresponding
to the well here. If there is no well metadata associated with the image set, select
<i>None</i>.
<p>%(USING_METADATA_HELP_REF)s.</p>"""% globals())
self.properties_export_all_image_defaults = cps.Binary(
[O_TWO_CLASS, O_THREE_CLASS],doc="""
<i>(Used only for the Otsu thresholding method)</i> <br>
Select <i>Two</i> if the grayscale levels are readily distinguishable into foregound
(i.e., objects) and background. Select <i>Three</i> if there is an
middle set of grayscale levels which belong to neither the
foreground nor background.
<p>For example, three-class thresholding may
be useful for images in which you have nuclear staining along with
low-intensity non-specific cell staining. Where two-class thresholding
might incorrectly assign this intemediate staining to the nuclei
objects, three-class thresholding allows you to assign it to the
foreground or background as desired. However, in extreme cases where either
there are almost no objects or the entire field of view is covered with
objects, three-class thresholding may perform worse than two-class.""")
self.use_weighted_variance = cps.Choice(
'Minimize the weighted variance or the entropy?',
[O_WEIGHTED_VARIANCE, O_ENTROPY])
self.assign_middle_to_foreground = cps.Choice(
'Assign pixels in the middle intensity class to the foreground '
'or the background?', [O_FOREGROUND, O_BACKGROUND],doc="""
<i>(Used only for the Otsu thresholding method with three-class thresholding)</i><br></p>
def add_step_parent(self, can_delete = True):
group = cps.SettingsGroup()
group.append("step_parent_name", cps.Choice(
"Parent name", ["None"], choices_fn = self.get_step_parents,
doc = """
<i>(Used only if calculating distances to another parent)</i><br>
Choose the name of the other parent. The <b>Relate</b> module will
measure the distance from this parent to the child objects
in the same manner as it does to the primary parents.
You can only choose the parents or children of
the parent object."""))
if can_delete:
group.append("remove", cps.RemoveSettingButton(
"", "Remove this object", self.step_parent_names, group))
self.step_parent_names.append(group)
<li><i>Custom with metadata:</i> Enter the filename text with the metdata tags in the form <i>\g<metadata-tag></i>.
For example, if the <i>plate</i>, <i>well_row</i> and <i>well_column</i> tags have the values <i>XG45</i>, <i>A</i>
and <i>01</i>, respectively, the string <i>Illum_\g<plate>_\g<well_row>\g<well_column></i>
produces the output filename <i>Illum_XG45_A01</i>.</li>
Do not enter the file extension in this setting; it will be appended automatically.""")
self.file_name_suffix = cps.Text("Enter text to append to the image name",cps.DO_NOT_USE,doc="""
Enter the text that will be appended to the filename specified above.""")
self.file_format = cps.Choice("Select file format",
[FF_BMP,FF_GIF,FF_HDF,FF_JPG,FF_JPEG,
FF_PBM,FF_PCX,FF_PGM,FF_PNG,FF_PNM,
FF_PPM,FF_RAS,FF_TIF,FF_TIFF,FF_XWD,
FF_AVI,FF_MAT],FF_BMP,doc="""
Select the image or movie format to save the image(s). Most of the
most-common formats are supported.""")
self.pathname_choice = cps.Choice("Select location to save file",
[PC_DEFAULT,PC_WITH_IMAGE,
PC_CUSTOM, PC_WITH_METADATA],
PC_DEFAULT, doc = """ Where do you want to store the file?""")
self.movie_pathname_choice = cps.Choice("Select location to save file",
[PC_DEFAULT,PC_CUSTOM],
PC_DEFAULT,doc="""
There are four choices available: <ul>
<li><i>Default output folder</i></li>
<li><i>Same folder as image:</i> The file will be stored in the folder to which the
images from this image set belong.</li>
<li><i>Custom:</i> The file will be stored in a customizable folder. You can
prefix the folder name with "." (n period) to make the root folder the default
output folder or "&" (an ampersand) to make the root folder the default image
folder.</li>
<li><i>Custom with metadata:</i> The file will be stored in a customizable folder
with metadata substitution (see the <i>Name with metadata</i> setting above)</li></ul>
<ul>
<li><i>Individual images:</i> Each file represents a single image.
Some methods of file compression sacrifice image quality ("lossy") and should be avoided for automated image analysis
if at all possible (e.g., .jpg). Other file compression formats retain exactly the original image information but in
a smaller file ("lossless") so they are perfectly acceptable for image analysis (e.g., .png, .tif, .gif).
Uncompressed file formats are also fine for image analysis (e.g., .bmp).</li>
<li><i>AVI movies:</i> An AVI (Audio Video Interleave) file is a type of movie file. Only uncompressed AVIs are supported.</li>
<li><i>TIF, TIFF, FLEX movies:</i> A TIF/TIFF movie is a file that contains a series of images as individual frames.
The same is true for the FLEX file format (used by Evotec Opera automated microscopes).</li>
<li><i>STK movies:</i> STKs are a proprietary image format used by MetaMorph (Molecular Devices). It is typically
used to encode 3D image data, e.g. from confocal microscopy, and is a special version of the TIF format. </li>
<li><i>ZVI movies:</i> ZVIs are a proprietary image format used by Zeiss. It is typically
used to encode 3D image data, e.g. from fluorescence microscopy. </li>
</ul>""")
self.match_method = cps.Choice('File selection method', [MS_EXACT_MATCH, MS_REGEXP, MS_ORDER],doc="""
Three options are available:
<ul>
<li><i>Text-Exact match:</i> Used to load image (or movie) files that have a particular piece of
text in the name. The specific text that is entered will be searched for in the filenames and
the files that contain that text exactly will be loaded and given the name you specify.
The search for the text is case-sensitive.</li>
<li><i>Text-Regular expressions:</i> Used to load image (or movie) files that match
a pattern of regular expressions. Patterns are specified using
combinations of metacharacters and literal characters. There are a few
classes of metacharacters, partially listed below. A more extensive
explanation of regular expressions can be found <a href="http://www.python.org/doc/2.3/lib/re-syntax.html">here</a>
and a helpful quick reference can be found <a href="http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/">here</a>.
<p>The following metacharacters match exactly one character from its respective set of characters:<br><br>
<table border="1">
<tbody><tr><th>Metacharacter</th><th>Meaning</th></tr>
<tr><td>.</td><td>Any character</td></tr></tbody></table></p></li></ul>
retrieve the grid in subsequent modules.""")
self.grid_rows = cps.Integer("Number of rows",8,1)
self.grid_columns = cps.Integer("Number of columns",12,1)
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 <i>Top left</i>, the top left cell is
cell #1 and cells to the right and bottom are indexed with
larger numbers.""")
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).
If you choose <i>Rows</i>, then well A01 will be assigned
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
<i>9</i>. Conversely, if you choose <i>Columns</i>, well A02 will be assigned
2, well A12 will be assigned 12 and well B01 will be assigned
13.""")
self.each_or_once = cps.Choice(
"Define a grid for which cycle?",
[EO_EACH, EO_ONCE], doc="""
Would you like to define a new grid for each image cycle,
or define a grid once and use it for all images?
<ul></ul>
def create_settings(self):
'''Create the initial settings for the module'''
self.image_groups = []
self.add_image(can_delete = False)
self.spacer_1 = cps.Divider()
self.add_image(can_delete = False)
self.image_count = cps.HiddenCount(self.image_groups)
self.add_image_button = cps.DoSomething("", 'Add another image', self.add_image)
self.spacer_2 = cps.Divider()
self.images_or_objects = cps.Choice('Select where to measure correlation',
[M_IMAGES, M_OBJECTS, M_IMAGES_AND_OBJECTS],
doc = '''
Do you want to measure the correlation over the whole image,
within objects, or both?
Both methods measure correlation on a pixel by pixel basis.
Selecting <i>Objects</i> will measure correlation only in those pixels previously
identified as an object (you will be asked to specify which object). Selecting
<i>Images</i> will measure correlation across all pixels in the images.
<i>Images and objects</i> will calculate both measurements.''')
self.object_groups = []
self.add_object(can_delete = False)
self.object_count = cps.HiddenCount(self.object_groups)
self.spacer_2 = cps.Divider(line=True)
output folder or "&" (an ampersand) to make the root folder the default image
folder.
<li><i>Custom with metadata:</i> The file will be stored in a customizable folder
with metadata substitution (see the <i>Name with metadata</i> setting above)</li>
""")
self.pathname = cps.Text("Pathname of the saved image",".",doc="""
Enter the pathname to save the images here. The pathname can referenced with respect
to the default output folder with a period (".") or the default input
folder with an ampersand ("&") as the root folder.""")
self.bit_depth = cps.Choice("Enter the bit depth at which to save the images",
["8","12","16"])
self.overwrite = cps.Binary("Overwrite existing files without warning?",False)
self.when_to_save = cps.Choice("Select how often to save",
[WS_EVERY_CYCLE,WS_FIRST_CYCLE,WS_LAST_CYCLE],
WS_EVERY_CYCLE)
self.when_to_save_movie = cps.Choice("Select how often to save",
[WS_LAST_CYCLE,"1","2","3","4","5","10","20"],
WS_LAST_CYCLE,doc="""
Specify at what point during pipeline execution to save your movie.
The movie will be always be saved after the last cycle is processed; since
a movie frame is added each cycle, saving at the last cycle will output the
fully completed movie.
<p>You also have the option to save the movie periodically
during image processing, so that the partial movie will be available if you cancel
image processing partway through. Saving movies in .avi format is
quite slow, so you can enter an cycle increment for saving the movie. For example,
entering a 1 will save the movie after every cycle. Since saving movies is
time-consuming, use any value other than "Last cycle" with caution.
</p><p>The movie will be saved in uncompressed .avi format, which can be quite large.
We recommended converting the movie to a compressed movie format,
such as .mov using third-party software. """)
self.rescale = cps.Binary("Rescale the images? ",False,doc="""</p>