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 # easier than listing every other OS in the universe except for VMS self.remote_host_is_windows = cps.Binary( "Are the cluster computers running Windows?", False, doc="""\ Select "*Yes*" if the cluster computers are running one of the Microsoft Windows operating systems. In this case, **CreateBatchFiles** will modify all paths to use the Windows file separator (backslash \\\\ ). Select "*No*" for **CreateBatchFiles** to modify all paths to use the Unix or Macintosh file separator (slash / ).""" % globals(), ) self.batch_mode = cps.Binary("Hidden: in batch mode", False) self.distributed_mode = cps.Binary("Hidden: in distributed mode", False) self.default_image_directory = cps.Setting( "Hidden: default input folder at time of save", cpprefs.get_default_image_directory(), ) self.revision = cps.Integer("Hidden: revision number", 0) self.from_old_matlab = cps.Binary("Hidden: from old matlab", False) self.acknowledge_old_matlab = cps.DoSomething( "Could not update CP1.0 pipeline to be compatible with CP2.0. See module notes.", "OK", self.clear_old_matlab, ) self.mappings = [] self.add_mapping() self.add_mapping_button = cps.DoSomething( "", "Add another path mapping", self.add_mapping, doc="""\ Use this option if another path must be mapped because there is a difference between how the local computer sees a folder location vs. how the cluster computer sees the folder location.""", )
def create_settings(self): self.outputs = [] self.stain_count = cps.HiddenCount(self.outputs, "Stain count") self.input_image_name = cps.ImageNameSubscriber( "Select the input color image", "None", doc="""\ Choose the name of the histologically stained color image loaded or created by some prior module.""", ) self.add_image(False) self.add_image_button = cps.DoSomething( "", "Add another stain", self.add_image, doc="""\ Press this button to add another stain to the list. You will be able to name the image produced and to either pick the stain from a list of pre-calibrated stains or to enter custom values for the stain's red, green and blue absorbance. """, )
def create_settings(self): self.image_name = cps.ImageNameSubscriber( "Select the input image", "None", doc="""\ Select the image that you want to perform a morphological operation on. A grayscale image can be converted to binary using the **Threshold** module. Objects can be converted to binary using the **ConvertToImage** 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)
def create_settings(self): self.divider_top = cps.Divider(line=False) self.images = [] self.image_count = cps.HiddenCount(self.images, "Image count") self.add_image(can_remove=False) self.add_button = cps.DoSomething("", "Add another image", self.add_image) self.divider_bottom = cps.Divider(line=False)
def create_settings(self): """Create the settings & name the module""" self.divider_top = cps.Divider(line=False) self.images = [] self.add_image_measurement(can_remove=False) self.add_button = cps.DoSomething("", "Add another image", self.add_image_measurement) self.divider_bottom = cps.Divider(line=False)
def create_settings(self): self.omero_host = cps.Text( "Host address", DEFAULT_OMERO_HOST, doc= """Host address of an omero server. Can be an ip-address or a hostname.""", ) self.omero_port = cps.Integer("Port", DEFAULT_OMERO_PORT, doc="""Port of an omero server.""") self.omero_username = cps.Text( "Username", DEFAULT_OMERO_USERNAME, doc="""Username is required for login into an omero server.""", ) self.omero_password = cps.Text( "Password", DEFAULT_OMERO_PASSWORD, doc="""Password is required for login into an omero server.""", ) self.omero_object = cps.Choice("Object to load", [MS_IMAGE, MS_DATASET, MS_PLATE], DEFAULT_OMERO_OBJECT) self.omero_object_id = cps.Integer( "Object id", DEFAULT_OMERO_OBJECT_ID, doc= """This is a number that omero uses to uniquely identify an object, be it a dataset, plate, or image.""", ) self.load_channels = cps.DoSomething("", "Load channels from OMERO", self.load_channels) # All the omero images that are loaded are assumed to have # as many or more channels than the highest channel number # the user specifies. self.channels = [] self.channel_count = cps.HiddenCount(self.channels, "Channel count") # Add the first channel self.add_channelfn(False) # Button for adding other channels self.add_channel = cps.DoSomething("", "Add another channel", self.add_channelfn)
def create_settings(self): self.flags = [] self.flag_count = cps.HiddenCount(self.flags) self.add_flag_button = cps.DoSomething("", "Add another flag", self.add_flag) self.spacer_1 = cps.Divider() self.add_flag(can_delete=False) self.ignore_flag_on_last = cps.Binary( "Ignore flag skips on last cycle?", False, doc="""\ When set to *{YES}*, this option allows you to bypass skipping on the last cycle of an image group. This behavior is usually not desired, but may be useful when using SaveImages 'Save on last cycle' option for an image made by any other module than MakeProjection, CorrectIlluminationCalculate, and Tile. """.format(**{"YES": "Yes"}), )
def create_settings(self): """Create your settings by subclassing this function create_settings is called at the end of initialization. You should create the setting variables for your module here: # Ask the user for the input image self.image_name = cellprofiler_core.settings.ImageNameSubscriber(...) # Ask the user for the name of the output image self.output_image = cellprofiler_core.settings.ImageNameProvider(...) # Ask the user for a parameter self.smoothing_size = cellprofiler_core.settings.Float(...)""" self.grouping_values = cps.Measurement( "Select the image measurement describing the positive and negative control status", lambda: cpmeas.IMAGE, doc="""\ The Z’ factor, a measure of assay quality, is calculated by this module based on measurements from images that are specified as positive controls and images that are specified as negative controls. Images that are neither are ignored. The module assumes that all of the negative controls are specified by a minimum value, all of the positive controls are specified by a maximum value, and all other images have an intermediate value; this might allow you to use your dosing information to also specify the positive and negative controls. If you don’t use actual dose data to designate your controls, a common practice is to designate -1 as a negative control, 0 as an experimental sample, and 1 as a positive control. In other words, positive controls should all be specified by a single high value (for instance, 1) and negative controls should all be specified by a single low value (for instance, -1). Other samples should have an intermediate value to exclude them from the Z’ factor analysis. The typical way to provide this information in the pipeline is to create a text comma-delimited (CSV) file outside of CellProfiler and then load that file into the pipeline using the **Metadata** module or the legacy **LoadData** module. In that case, choose the measurement that matches the column header of the measurement in the input file. See the main module help for this module or for the **Metadata** module for an example text file. """, ) self.dose_values = [] self.add_dose_value(can_remove=False) self.add_dose_button = cps.DoSomething( "", "Add another dose specification", self.add_dose_value)
def create_settings(self): self.scheme_choice = cps.Choice( "Select a color scheme", [SCHEME_RGB, SCHEME_CMYK, SCHEME_STACK, SCHEME_COMPOSITE], doc="""\ This module can use one of two color schemes to combine images: - *%(SCHEME_RGB)s*: Each input image determines the intensity of one of the color channels: red, green, and blue. - *%(SCHEME_CMYK)s*: Three of the input images are combined to determine the colors (cyan, magenta, and yellow) and a fourth is used only for brightness. The cyan image adds equally to the green and blue intensities. The magenta image adds equally to the red and blue intensities. The yellow image adds equally to the red and green intensities. - *%(SCHEME_STACK)s*: The channels are stacked in the order listed, from top to bottom. An arbitrary number of channels is allowed. For example, you could create a 5-channel image by providing 5 grayscale images. The first grayscale image you provide will fill the first channel, the second grayscale image you provide will fill the second channel, and so on. - *%(SCHEME_COMPOSITE)s*: A color is assigned to each grayscale image. Each grayscale image is converted to color by multiplying the intensity by the color and the resulting color images are added together. An arbitrary number of channels can be composited into a single color image. """ % globals(), ) # # # # # # # # # # # # # # # # # # RGB settings # # # # # # # # # # # # # # # # # self.red_image_name = cps.ImageNameSubscriber( "Select the image to be colored red", can_be_blank=True, blank_text=LEAVE_THIS_BLACK, doc="""\ *(Used only if "%(SCHEME_RGB)s" is selected as the color scheme)* Select the input image to be displayed in red. """ % globals(), ) self.green_image_name = cps.ImageNameSubscriber( "Select the image to be colored green", can_be_blank=True, blank_text=LEAVE_THIS_BLACK, doc="""\ *(Used only if "%(SCHEME_RGB)s" is selected as the color scheme)* Select the input image to be displayed in green. """ % globals(), ) self.blue_image_name = cps.ImageNameSubscriber( "Select the image to be colored blue", can_be_blank=True, blank_text=LEAVE_THIS_BLACK, doc="""\ *(Used only if "%(SCHEME_RGB)s" is selected as the color scheme)* Select the input image to be displayed in blue. """ % globals(), ) self.rgb_image_name = cps.ImageNameProvider( "Name the output image", "ColorImage", doc="""Enter a name for the resulting image.""", ) self.red_adjustment_factor = cps.Float( "Relative weight for the red image", value=1, minval=0, doc="""\ *(Used only if "%(SCHEME_RGB)s" is selected as the color scheme)* Enter the relative weight for the red image. 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. """ % globals(), ) self.green_adjustment_factor = cps.Float( "Relative weight for the green image", value=1, minval=0, doc="""\ *(Used only if "%(SCHEME_RGB)s" is selected as the color scheme)* Enter the relative weight for the green image. 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. """ % globals(), ) self.blue_adjustment_factor = cps.Float( "Relative weight for the blue image", value=1, minval=0, doc="""\ *(Used only if "%(SCHEME_RGB)s" is selected as the color scheme)* Enter the relative weight for the blue image. 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. """ % globals(), ) # # # # # # # # # # # # # # # # CYMK settings # # # # # # # # # # # # # # # self.cyan_image_name = cps.ImageNameSubscriber( "Select the image to be colored cyan", can_be_blank=True, blank_text=LEAVE_THIS_BLACK, doc="""\ *(Used only if "%(SCHEME_CMYK)s" is selected as the color scheme)* Select the input image to be displayed in cyan. """ % globals(), ) self.magenta_image_name = cps.ImageNameSubscriber( "Select the image to be colored magenta", can_be_blank=True, blank_text=LEAVE_THIS_BLACK, doc="""\ *(Used only if "%(SCHEME_CMYK)s" is selected as the color scheme)* Select the input image to be displayed in magenta. """ % globals(), ) self.yellow_image_name = cps.ImageNameSubscriber( "Select the image to be colored yellow", can_be_blank=True, blank_text=LEAVE_THIS_BLACK, doc="""\ *(Used only if "%(SCHEME_CMYK)s" is selected as the color scheme)* Select the input image to be displayed in yellow. """ % globals(), ) self.gray_image_name = cps.ImageNameSubscriber( "Select the image that determines brightness", can_be_blank=True, blank_text=LEAVE_THIS_BLACK, doc="""\ *(Used only if "%(SCHEME_CMYK)s" is selected as the color scheme)* Select the input image that will determine each pixel's brightness. """ % globals(), ) self.cyan_adjustment_factor = cps.Float( "Relative weight for the cyan image", value=1, minval=0, doc="""\ *(Used only if "%(SCHEME_CMYK)s" is selected as the color scheme)* Enter the relative weight for the cyan image. If all relative weights are equal, all colors contribute equally in the final image. To weight colors relative to each other, increase or decrease the relative weights. """ % globals(), ) self.magenta_adjustment_factor = cps.Float( "Relative weight for the magenta image", value=1, minval=0, doc="""\ *(Used only if "%(SCHEME_CMYK)s" is selected as the color scheme)* Enter the relative weight for the magenta image. If all relative weights are equal, all colors contribute equally in the final image. To weight colors relative to each other, increase or decrease the relative weights. """ % globals(), ) self.yellow_adjustment_factor = cps.Float( "Relative weight for the yellow image", value=1, minval=0, doc="""\ *(Used only if "%(SCHEME_CMYK)s" is selected as the color scheme)* Enter the relative weight for the yellow image. If all relative weights are equal, all colors contribute equally in the final image. To weight colors relative to each other, increase or decrease the relative weights. """ % globals(), ) self.gray_adjustment_factor = cps.Float( "Relative weight for the brightness image", value=1, minval=0, doc="""\ *(Used only if "%(SCHEME_CMYK)s" is selected as the color scheme)* Enter the relative weight for the brightness image. If all relative weights are equal, all colors contribute equally in the final image. To weight colors relative to each other, increase or decrease the relative weights. """ % globals(), ) # # # # # # # # # # # # # # # # Stack settings # # # # # # # # # # # # # # # self.stack_channels = [] self.stack_channel_count = cps.HiddenCount(self.stack_channels) self.add_stack_channel_cb(can_remove=False) self.add_stack_channel = cps.DoSomething( "Add another channel", "Add another channel", self.add_stack_channel_cb, doc="""\ Press this button to add another image to the stack. """, )
def create_settings(self): """Create the settings for the module Create the settings for the module during initialization. """ self.contrast_choice = cps.Choice( "Make each classification decision on how many measurements?", [BY_SINGLE_MEASUREMENT, BY_TWO_MEASUREMENTS], doc="""\ This setting controls how many measurements are used to make a classifications decision for each object: - *%(BY_SINGLE_MEASUREMENT)s:* Classifies each object based on a single measurement. - *%(BY_TWO_MEASUREMENTS)s:* Classifies each object based on a pair of measurements taken together (that is, an object must meet two criteria to belong to a class). """ % globals(), ) ############### Single measurement settings ################## # # A list holding groupings for each of the single measurements # to be done # self.single_measurements = [] # # A count of # of measurements # self.single_measurement_count = cps.HiddenCount( self.single_measurements) # # Add one single measurement to start off # self.add_single_measurement(False) # # A button to press to get another measurement # self.add_measurement_button = cps.DoSomething( "", "Add another classification", self.add_single_measurement) # ############### Two-measurement settings ##################### # # The object for the contrasting method # self.object_name = cps.ObjectNameSubscriber( "Select the object name", "None", doc="""\ Choose the object that you want to measure from the list. This should be an object created by a previous module such as **IdentifyPrimaryObjects**, **IdentifySecondaryObjects**, **IdentifyTertiaryObjects**, or **Watershed** """, ) # # The two measurements for the contrasting method # def object_fn(): return self.object_name.value self.first_measurement = cps.Measurement( "Select the first measurement", object_fn, doc="""\ *(Used only if using a pair of measurements)* Choose a measurement made on the above object. This is the first of two measurements that will be contrasted together. The measurement should be one made on the object in a prior module. """, ) self.first_threshold_method = cps.Choice( "Method to select the cutoff", [TM_MEAN, TM_MEDIAN, TM_CUSTOM], doc="""\ *(Used only if using a pair of measurements)* Objects are classified as being above or below a cutoff value for a measurement. You can set this cutoff threshold in one of three ways: - *%(TM_MEAN)s*: At the mean of the measurement’s value for all objects in the image cycle. - *%(TM_MEDIAN)s*: At the median of the measurement’s value for all objects in the image set. - *%(TM_CUSTOM)s*: You specify a custom threshold value. """ % globals(), ) self.first_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.second_measurement = cps.Measurement( "Select the second measurement", object_fn, doc="""\ *(Used only if using a pair of measurements)* Select a measurement made on the above object. This is the second of two measurements that will be contrasted together. The measurement should be one made on the object in a prior module.""", ) self.second_threshold_method = cps.Choice( "Method to select the cutoff", [TM_MEAN, TM_MEDIAN, TM_CUSTOM], doc="""\ *(Used only if using a pair of measurements)* Objects are classified as being above or below a cutoff value for a measurement. You can set this cutoff threshold in one of three ways: - *%(TM_MEAN)s:* At the mean of the measurement’s value for all objects in the image cycle. - *%(TM_MEDIAN)s:* At the median of the measurement’s value for all 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.low_low_custom_name = cps.AlphanumericText( "Enter the low-low bin name", "low_low", doc="""\ *(Used only if using a pair of measurements)* Name of the measurement for objects that fall below the threshold for both measurements. """, ) self.low_high_custom_name = cps.AlphanumericText( "Enter the low-high bin name", "low_high", doc="""\ *(Used only if using a pair of measurements)* Name of the measurement for objects whose first measurement is below threshold and whose second measurement is above threshold. """, ) self.high_low_custom_name = cps.AlphanumericText( "Enter the high-low bin name", "high_low", doc="""\ *(Used only if using a pair of measurements)* Name of the measurement for objects whose first measurement is above threshold and whose second measurement is below threshold.""", ) self.high_high_custom_name = cps.AlphanumericText( "Enter the high-high bin name", "high_high", doc="""\ *(Used only if using a pair of measurements)* Name of the measurement for objects that are above the threshold for both measurements.""", ) self.wants_image = cps.Binary( "Retain an image of the classified objects?", False, doc="""\ Select "*Yes*" to retain the image of the objects color-coded according to their classification, for use later in the pipeline (for example, to be saved by a **SaveImages** module). """ % globals(), ) self.image_name = cps.ImageNameProvider( "Enter the image name", "None", doc="""\ *(Used only if the classified object image is to be retained for later use in the pipeline)* Enter the name to be given to the classified object image.""", )
def add_flag(self, can_delete=True): group = cps.SettingsGroup() group.append("divider1", cps.Divider(line=False)) group.append("measurement_settings", []) group.append("measurement_count", cps.HiddenCount(group.measurement_settings)) group.append( "category", cps.Text( "Name the flag's category", "Metadata", doc="""\ Name a measurement category by which to categorize the flag. The *Metadata* category is the default used in CellProfiler to store information about images (referred to as *metadata*). The flag is stored as a per-image measurement whose name is a combination of the flag’s category and the flag name that you choose, separated by underscores. For instance, if the measurement category is *Metadata* and the flag name is *QCFlag*, then the default measurement name would be *Metadata_QCFlag*. """, ), ) group.append( "feature_name", cps.Text( "Name the flag", "QCFlag", doc="""\ The flag is stored as a per-image measurement whose name is a combination of the flag’s category and the flag name that you choose, separated by underscores. For instance, if the measurement category is *Metadata* and the flag name is *QCFlag*, then the default measurement name would be *Metadata_QCFlag*. """, ), ) group.append( "combination_choice", cps.Choice( "How should measurements be linked?", [C_ANY, C_ALL], doc="""\ For combinations of measurements, you can set the criteria under which an image set is flagged: - *%(C_ANY)s:* An image set will be flagged if any of its measurements fail. This can be useful for flagging images possessing multiple QC flaws; for example, you can flag all bright images and all out of focus images with one flag. - *%(C_ALL)s:* A flag will only be assigned if all measurements fail. This can be useful for flagging images that possess only a combination of QC flaws; for example, you can flag only images that are both bright and out of focus. """ % globals(), ), ) group.append( "wants_skip", cps.Binary( "Skip image set if flagged?", False, doc="""\ Select *Yes* to skip the remainder of the pipeline for image sets that are flagged. CellProfiler will not run subsequent modules in the pipeline on the images for any image set that is flagged. Select *No* for CellProfiler to continue to process the pipeline regardless of flagging. You may want to skip processing in order to filter out unwanted images. For instance, you may want to exclude out of focus images when running **CorrectIllumination_Calculate**. You can do this with a pipeline that measures image quality and flags inappropriate images before it runs **CorrectIllumination_Calculate**. """ % globals(), ), ) group.append( "add_measurement_button", cps.DoSomething( "", "Add another measurement", self.add_measurement, group, doc="""Add another measurement as a criteria.""", ), ) self.add_measurement(group, False if not can_delete else True) if can_delete: group.append( "remover", cps.RemoveSettingButton("", "Remove this flag", self.flags, group), ) group.append("divider2", cps.Divider(line=True)) self.flags.append(group)
def create_settings(self): """Make settings here (and set the module name)""" self.images = [] self.add_image(can_delete=False) self.add_image_button = cps.DoSomething("", "Add another image", self.add_image)
def create_settings(self): self.image_name = cps.ImageNameSubscriber( "Select the input image", "None", doc= """Select the multichannel image you want to convert to grayscale.""", ) self.combine_or_split = cps.Choice( "Conversion method", [COMBINE, SPLIT], doc="""\ How do you want to convert the color image? - *%(SPLIT)s:* Splits the channels of a color image (e.g., red, green, blue) into separate grayscale images. - *%(COMBINE)s:* Converts a color image to a grayscale image by combining channels together (e.g., red, green, blue).""" % globals(), ) self.rgb_or_channels = cps.Choice( "Image type", [CH_RGB, CH_HSV, CH_CHANNELS], doc="""\ This setting provides three options to choose from: - *%(CH_RGB)s:* The RGB (red, green, blue) color space is the typical model in which color images are stored. Choosing this option will split the image into red, green, and blue component images. - *%(CH_HSV)s:* The HSV (hue, saturation, value) color space is based on color characteristics such as tint, shade, and tone. Choosing this option will split the image into the hue, saturation, and value component images. - *%(CH_CHANNELS)s:* Many images contain color channels other than RGB or HSV. For instance, GIF and PNG formats can have an alpha channel that encodes transparency. TIF formats can have an arbitrary number of channels which represent pixel measurements made by different detectors, filters or lighting conditions. This setting allows you to handle a more complex model for images that have more than three channels.""" % globals(), ) # The following settings are used for the combine option self.grayscale_name = cps.ImageNameProvider( "Name the output image", "OrigGray", doc="""\ *(Used only when combining channels)* Enter a name for the resulting grayscale image.""", ) self.red_contribution = cps.Float( "Relative weight of the red channel", 1, 0, doc="""\ *(Used only when combining channels)* 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.""", ) self.green_contribution = cps.Float( "Relative weight of the green channel", 1, 0, doc="""\ *(Used only when combining channels)* 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.""", ) self.blue_contribution = cps.Float( "Relative weight of the blue channel", 1, 0, doc="""\ *(Used only when combining channels)* 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.""", ) # The following settings are used for the split RGB option self.use_red = cps.Binary( "Convert red to gray?", True, doc="""\ *(Used only when splitting RGB images)* Select *"Yes"* to extract the red channel to grayscale. Otherwise, the red channel will be ignored. """ % globals(), ) self.red_name = cps.ImageNameProvider( "Name the output image", "OrigRed", doc="""\ *(Used only when splitting RGB images)* Enter a name for the resulting grayscale image coming from the red channel.""", ) self.use_green = cps.Binary( "Convert green to gray?", True, doc="""\ *(Used only when splitting RGB images)* Select *"Yes"* to extract the green channel to grayscale. Otherwise, the green channel will be ignored. """ % globals(), ) self.green_name = cps.ImageNameProvider( "Name the output image", "OrigGreen", doc="""\ *(Used only when splitting RGB images)* Enter a name for the resulting grayscale image coming from the green channel.""", ) self.use_blue = cps.Binary( "Convert blue to gray?", True, doc="""\ *(Used only when splitting RGB images)* Select *"Yes"* to extract the blue channel to grayscale. Otherwise, the blue channel will be ignored. """ % globals(), ) self.blue_name = cps.ImageNameProvider( "Name the output image", "OrigBlue", doc="""\ *(Used only when splitting RGB images)* Enter a name for the resulting grayscale image coming from the blue channel.""", ) # The following settings are used for the split HSV option self.use_hue = cps.Binary( "Convert hue to gray?", True, doc="""\ *(Used only when splitting HSV images)* Select *"Yes"* to extract the hue to grayscale. Otherwise, the hue will be ignored. """ % globals(), ) self.hue_name = cps.ImageNameProvider( "Name the output image", "OrigHue", doc="""\ *(Used only when splitting HSV images)* Enter a name for the resulting grayscale image coming from the hue.""", ) self.use_saturation = cps.Binary( "Convert saturation to gray?", True, doc="""\ *(Used only when splitting HSV images)* Select *"Yes"* to extract the saturation to grayscale. Otherwise, the saturation will be ignored. """ % globals(), ) self.saturation_name = cps.ImageNameProvider( "Name the output image", "OrigSaturation", doc="""\ *(Used only when splitting HSV images)* Enter a name for the resulting grayscale image coming from the saturation.""", ) self.use_value = cps.Binary( "Convert value to gray?", True, doc="""\ *(Used only when splitting HSV images)* Select *"Yes"* to extract the value to grayscale. Otherwise, the value will be ignored. """ % globals(), ) self.value_name = cps.ImageNameProvider( "Name the output image", "OrigValue", doc="""\ *(Used only when splitting HSV images)* Enter a name for the resulting grayscale image coming from the value.""", ) # The alternative model: self.channels = [] self.add_channel(False) self.channel_button = cps.DoSomething("", "Add another channel", self.add_channel) self.channel_count = cps.HiddenCount(self.channels, "Channel count")
def add_image(self, can_remove=True): group = cps.SettingsGroup() group.can_remove = can_remove if can_remove: group.append("divider", cps.Divider()) idx = len(self.outputs) default_name = STAINS_BY_POPULARITY[idx % len(STAINS_BY_POPULARITY)] default_name = default_name.replace(" ", "") group.append( "image_name", cps.ImageNameProvider( "Name the output image", default_name, doc="""\ Use this setting to name one of the images produced by the module for a particular stain. The image can be used in subsequent modules in the pipeline. """, ), ) choices = list(sorted(STAIN_DICTIONARY.keys())) + [CHOICE_CUSTOM] group.append( "stain_choice", cps.Choice( "Stain", choices=choices, doc="""\ Use this setting to choose the absorbance values for a particular stain. The stains are: |Unmix_image0| (Information taken from `here`_, `here <http://en.wikipedia.org/wiki/Staining>`__, and `here <http://stainsfile.info>`__.) You can choose *{CHOICE_CUSTOM}* and enter your custom values for the absorbance (or use the estimator to determine values from single-stain images). .. _here: http://en.wikipedia.org/wiki/Histology#Staining .. |Unmix_image0| image:: {UNMIX_COLOR_CHART} """.format( **{ "UNMIX_COLOR_CHART": cellprofiler.gui.help.content.image_resource( "UnmixColors.png"), "CHOICE_CUSTOM": CHOICE_CUSTOM, }), ), ) group.append( "red_absorbance", cps.Float( "Red absorbance", 0.5, 0, 1, doc="""\ *(Used only if "%(CHOICE_CUSTOM)s" is selected for the stain)* The red absorbance setting estimates the dye’s absorbance of light in the red channel.You should enter a value between 0 and 1 where 0 is no absorbance and 1 is complete absorbance. You can use the estimator to calculate this value automatically. """ % globals(), ), ) group.append( "green_absorbance", cps.Float( "Green absorbance", 0.5, 0, 1, doc="""\ *(Used only if "%(CHOICE_CUSTOM)s" is selected for the stain)* The green absorbance setting estimates the dye’s absorbance of light in the green channel. You should enter a value between 0 and 1 where 0 is no absorbance and 1 is complete absorbance. You can use the estimator to calculate this value automatically. """ % globals(), ), ) group.append( "blue_absorbance", cps.Float( "Blue absorbance", 0.5, 0, 1, doc="""\ *(Used only if "%(CHOICE_CUSTOM)s" is selected for the stain)* The blue absorbance setting estimates the dye’s absorbance of light in the blue channel. You should enter a value between 0 and 1 where 0 is no absorbance and 1 is complete absorbance. You can use the estimator to calculate this value automatically. """ % globals(), ), ) def on_estimate(): result = self.estimate_absorbance() if result is not None: ( group.red_absorbance.value, group.green_absorbance.value, group.blue_absorbance.value, ) = result group.append( "estimator_button", cps.DoSomething( "Estimate absorbance from image", "Estimate", on_estimate, doc="""\ Press this button to load an image of a sample stained only with the dye of interest. **UnmixColors** will estimate appropriate red, green and blue absorbance values from the image. """, ), ) if can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove this image", self.outputs, group), ) self.outputs.append(group)
def add_image(self, can_remove=True): group = GranularitySettingsGroup() group.can_remove = can_remove if can_remove: group.append("divider", cps.Divider(line=True)) group.append( "image_name", cps.ImageNameSubscriber( "Select an image to measure", "None", doc= "Select the grayscale images whose granularity you want to measure.", ), ) group.append( "subsample_size", cps.Float( "Subsampling factor for granularity measurements", 0.25, minval=np.finfo(float).eps, maxval=1, doc="""\ If the textures of interest are larger than a few pixels, we recommend you subsample the image with a factor <1 to speed up the processing. Down sampling the image will let you detect larger structures with a smaller sized structure element. A factor >1 might increase the accuracy but also require more processing time. Images are typically of higher resolution than is required for granularity measurements, so the default value is 0.25. For low-resolution images, increase the subsampling fraction; for high-resolution images, decrease the subsampling fraction. Subsampling by 1/4 reduces computation time by (1/4) :sup:`3` because the size of the image is (1/4) :sup:`2` of original and the range of granular spectrum can be 1/4 of original. Moreover, the results are sometimes actually a little better with subsampling, which is probably because with subsampling the individual granular spectrum components can be used as features, whereas without subsampling a feature should be a sum of several adjacent granular spectrum components. The recommendation on the numerical value cannot be determined in advance; an analysis as in this reference may be required before running the whole set. See this `pdf`_, slides 27-31, 49-50. .. _pdf: http://www.ravkin.net/presentations/Statistical%20properties%20of%20algorithms%20for%20analysis%20of%20cell%20images.pdf""", ), ) group.append( "image_sample_size", cps.Float( "Subsampling factor for background reduction", 0.25, minval=np.finfo(float).eps, maxval=1, doc="""\ It is important to remove low frequency image background variations as they will affect the final granularity measurement. Any method can be used as a pre-processing step prior to this module; we have chosen to simply subtract a highly open image. To do it quickly, we subsample the image first. The subsampling factor for background reduction is usually [0.125 – 0.25]. This is highly empirical, but a small factor should be used if the structures of interest are large. The significance of background removal in the context of granulometry is that image volume at certain granular size is normalized by total image volume, which depends on how the background was removed.""", ), ) group.append( "element_size", cps.Integer( "Radius of structuring element", 10, minval=1, doc="""\ This radius should correspond to the radius of the textures of interest *after* subsampling; i.e., if textures in the original image scale have a radius of 40 pixels, and a subsampling factor of 0.25 is used, the structuring element size should be 10 or slightly smaller, and the range of the spectrum defined below will cover more sizes.""", ), ) group.append( "granular_spectrum_length", cps.Integer( "Range of the granular spectrum", 16, minval=1, doc="""\ You may need a trial run to see which granular spectrum range yields informative measurements. Start by using a wide spectrum and narrow it down to the informative range to save time.""", ), ) group.append( "add_objects_button", cps.DoSomething( "", "Add another object", group.add_objects, doc="""\ Press this button to add granularity measurements for objects, such as those identified by a prior **IdentifyPrimaryObjects** module. **MeasureGranularity** will measure the image’s granularity within each object at the requested scales.""", ), ) group.objects = [] group.object_count = cps.HiddenCount(group.objects, "Object count") if can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove this image", self.images, group), ) self.images.append(group) return group
def create_settings(self): self.input_image = cps.ImageNameSubscriber( "Select an input image", "None", doc= """Select the image to be tiled. Additional images within the cycle can be added later by choosing the "*%(T_ACROSS_CYCLES)s*" option below. """ % globals(), ) self.output_image = cps.ImageNameProvider( "Name the output image", "TiledImage", doc="""Enter a name for the final tiled image.""", ) self.additional_images = [] self.add_button = cps.DoSomething( "", "Add another image", self.add_image, doc="""Add images from other channels to perform similar tiling""", ) self.tile_method = cps.Choice( "Tile assembly method", T_ALL, doc="""\ This setting controls the method by which the final tiled image is assembled: - *%(T_WITHIN_CYCLES)s:* If you have loaded more than one image for each cycle using modules upstream in the pipeline, the images can be tiled. For example, you may tile three different channels (OrigRed, OrigBlue, and OrigGreen), and a new tiled image will be created for every image cycle. - *%(T_ACROSS_CYCLES)s:* If you want to tile images from multiple cycles together, select this option. For example, you may tile all the images of the same type (e.g., OrigBlue) across all fields of view in your experiment, which will result in one final tiled image when processing is complete. """ % globals(), ) self.rows = cps.Integer( "Final number of rows", 8, doc="""\ Specify the number of rows would you like to have in the tiled image. For example, if you want to show your images in a 96-well format, enter 8. *Special cases:* Let *M* be the total number of slots for images (i.e, number of rows x number of columns) and *N* be the number of actual images. - If *M* > *N*, blanks will be used for the empty slots. - If the *M* < *N*, an error will occur since there are not enough image slots. Check “Automatically calculate number of rows?” to avoid this error. """, ) self.columns = cps.Integer( "Final number of columns", 12, doc="""\ Specify the number of columns you like to have in the tiled image. For example, if you want to show your images in a 96-well format, enter 12. *Special cases:* Let *M* be the total number of slots for images (i.e, number of rows x number of columns) and *N* be the number of actual images. - If *M* > *N*, blanks will be used for the empty slots. - If the *M* < *N*, an error will occur since there are not enough image slots. Check “Automatically calculate number of columns?” to avoid this error. """, ) self.place_first = cps.Choice( "Image corner to begin tiling", P_ALL, doc= """Where do you want the first image to be placed? Begin in the upper left-hand corner for a typical multi-well plate format where the first image is A01. """, ) self.tile_style = cps.Choice( "Direction to begin tiling", S_ALL, doc= """This setting specifies the order that the images are to be arranged. For example, if your images are named A01, A02, etc, enter "*%(S_ROW)s*". """ % globals(), ) self.meander = cps.Binary( "Use meander mode?", False, doc="""\ Select "*Yes*" to tile adjacent images in one direction, then the next row/column is tiled in the opposite direction. Some microscopes capture images in this fashion. The default mode is “comb”, or “typewriter” mode; in this mode, when one row is completely tiled in one direction, the next row starts near where the first row started and tiles again in the same direction. """ % globals(), ) self.wants_automatic_rows = cps.Binary( "Automatically calculate number of rows?", False, doc="""\ **Tile** can automatically calculate the number of rows in the grid based on the number of image cycles that will be processed. Select "*Yes*" to create a grid that has the number of columns that you entered and enough rows to display all of your images. Select "*No*" to specify the number of rows. If you check both automatic rows and automatic columns, **Tile** will create a grid that has roughly the same number of rows and columns. """ % globals(), ) self.wants_automatic_columns = cps.Binary( "Automatically calculate number of columns?", False, doc="""\ **Tile** can automatically calculate the number of columns in the grid from the number of image cycles that will be processed. Select "*Yes*" to create a grid that has the number of rows that you entered and enough columns to display all of your images. Select "*No*" to specify the number of rows. If you check both automatic rows and automatic columns, **Tile** will create a grid that has roughly the same number of rows and columns. """ % globals(), )