Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_01_02_set_false(self):
x = cellprofiler.setting.Binary("text", True)
x.value = False
self.assertTrue(x.value == False)
def create_settings(self):
super(ConvertImageToObjects, self).create_settings()
self.cast_to_bool = cellprofiler.setting.Binary(
text="Convert to boolean image", value=True, doc=HELP_BINARY_IMAGE
)
self.preserve_labels = cellprofiler.setting.Binary(
text="Preserve original labels",
value=False,
doc="""\
By default, this module will re-label the input image.
Setting this to *{YES}* will ensure that the original labels
(i.e. pixel values of the objects) are preserved.
""".format(
**{"YES": cellprofiler.setting.YES}
),
)
self.background_label = cellprofiler.setting.Integer(
text="Background label",
value=0,
doc="""\
Consider all pixels with this value as background pixels, and label them as 0.
method.
- *{WA_NONE}*: If objects are well separated and bright relative to
the background, it may be unnecessary to attempt to separate clumped
objects. Using the very fast *{WA_NONE}* option, a simple threshold
will be used to identify objects.
""".format(
**{
"WA_INTENSITY": WA_INTENSITY,
"WA_SHAPE": WA_SHAPE,
"WA_PROPAGATE": WA_PROPAGATE,
"WA_NONE": WA_NONE,
}
),
)
self.automatic_smoothing = cellprofiler.setting.Binary(
AUTOMATIC_SMOOTHING_SETTING_TEXT,
True,
doc="""\
*(Used only when distinguishing between clumped objects)*
Select "*{YES}*" to automatically calculate the amount of smoothing
applied to the image to assist in declumping. Select "*{NO}*" to
manually enter the smoothing filter size.
This setting, along with the *Minimum allowed distance between local
maxima* setting, affects whether objects close to each other are
considered a single object or multiple objects. It does not affect the
dividing lines between an object and the background.
Please note that this smoothing setting is applied after thresholding,
and is therefore distinct from the threshold smoothing method setting
% globals(),
)
self.wants_overwrite_without_warning = cps.Binary(
"Overwrite existing files without warning?",
False,
doc="""\
This setting either prevents or allows overwriting of old .CSV files by
**ExportToSpreadsheet** without confirmation. Select *"Yes"* to
overwrite without warning any .CSV file that already exists. Select
*"No"* to prompt before overwriting when running CellProfiler in the
GUI and to fail when running headless."""
% globals(),
)
self.add_metadata = cps.Binary(
"Add image metadata columns to your object data file?",
False,
doc="""\
“Image\_Metadata\_” columns are normally exported in the Image data
file, but if you select *"Yes"*, they will also be exported with the
Object data file(s)."""
% globals(),
)
self.nan_representation = cps.Choice(
"Representation of Nan/Inf",
[NANS_AS_NANS, NANS_AS_NULLS],
doc="""\
This setting controls the output for numeric fields if the calculated
value is infinite (*Inf*) or undefined (*NaN*). CellProfiler will
produce Inf or NaN values under certain rare circumstances, for instance
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*" 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)*
"Upper threshold",
1,
minval=cps.NumberConnector(min_upper_threshold),
doc="""\
*(Used only if using a single measurement and "%(BC_EVEN)s" selected)*
This is the threshold that separates the last bin from the others. Note
that if you would like two bins, you should select "*%(BC_CUSTOM)s*".
"""
% globals(),
),
)
group.append(
"wants_high_bin",
cps.Binary(
"Use a bin for objects above the threshold?",
False,
doc="""\
*(Used only if using a single measurement)*
Select "*Yes*" if you want to create a bin for objects whose values
are above the high threshold.
Select "*No*" if you do not want a bin for these objects.
"""
% globals(),
),
)
group.append(
"custom_thresholds",
objects in the image set.
- *%(TM_CUSTOM)s:* You specify a custom threshold value.
"""
% globals(),
)
self.second_threshold = cps.Float(
"Enter the cutoff value",
0.5,
doc="""\
*(Used only if using a pair of measurements)*
This is the cutoff value separating objects in the two classes.""",
)
self.wants_custom_names = cps.Binary(
"Use custom names for the bins?",
False,
doc="""\
*(Used only if using a pair of measurements)*
Select "*Yes*" if you want to specify the names of each bin
measurement.
Select "*No*" to create names based on the measurements. For instance,
for “Intensity_MeanIntensity_Green” and
“Intensity_TotalIntensity_Blue”, the module generates measurements
such as
“Classify_Intensity_MeanIntensity_Green_High_Intensity_TotalIntensity_Low”.
"""
% globals(),
)
self.masking_image = cps.ImageNameSubscriber(
"Select the masking image",
cps.NONE,
doc="""\
*(Used only if mask is to be made from an image)*
Select an image that was either loaded or created by a previous module.
The image should be a binary image where the white portion of the image
is the region(s) you will use for masking. Binary images can be loaded
from disk using the **NamesAndTypes** module by selecting “Binary mask”
for the image type. You can also create a binary image from a grayscale
image using **ApplyThreshold**.
""",
)
self.wants_inverted_mask = cps.Binary(
"Invert the mask?",
False,
doc="""\
This option reverses the foreground/background relationship of the mask.
- Select "*No*" for the mask to be composed of the foreground (white
portion) of the masking image or the area within the masking objects.
- Select "*Yes*" for the mask to instead be composed of the
*background* (black portions) of the masking image or the area
*outside* the masking objects.
"""
% globals(),
)
self.overlap_choice = cps.Choice(
"Handling of objects that are partially masked",
def create_settings(self):
"""Create the module settings and name the module"""
self.wants_default_output_directory = cps.Binary(
"Store batch files in default output folder?",
True,
doc="""\
Select "*Yes*" to store batch files in the Default Output folder.
Select "*No*" to enter the path to the folder that will be used to
store these files. The Default Output folder can be set by clicking the "View output settings" button in the main CP window, or in CellProfiler Preferences. """
% globals(),
)
self.custom_output_directory = cps.Text(
"Output folder path",
cpprefs.get_default_output_directory(),
doc="Enter the path to the output folder. (Used only if not using the default output folder)",
)
# Worded this way not because I am windows-centric but because it's
group.append(
"colormap",
cellprofiler.setting.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",
cellprofiler.setting.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 **SaveImages** module. Choose *{YES}* to save the
display or *{NO}* if the display is not needed.
""".format(
**{"YES": cellprofiler.setting.YES, "NO": cellprofiler.setting.NO}
),
),
)
group.append(
"display_name",
cellprofiler.setting.ImageNameProvider(
"Output image name",