def add_object(self, can_remove=True): '''Add an object to be measured (plus optional centers)''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append( "object_name", cps.ObjectNameSubscriber("Select objects to measure", cps.NONE, doc=""" Select the objects that you want to measure the intensity from.""" )) group.append( "center_choice", cps.Choice("Object to use as center?", C_ALL, doc=""" There are three ways to specify the center of the radial measurement: <ul> <li><i>%(C_SELF)s:</i> Use the centers of these objects for the radial measurement.</li> <li><i>%(C_CENTERS_OF_OTHER)s:</i> Use the centers of other objects for the radial measurement.</li> <li><i>%(C_EDGES_OF_OTHER)s:</i> Measure distances from the edge of the other object to each pixel outside of the centering object. Do not include pixels within the centering object in the radial measurement calculations.</li> </ul> For example, if measuring the radial distribution in a Cell object, you can use the center of the Cell objects (<i>%(C_SELF)s</i>) or you can use previously identified Nuclei objects as the centers (<i>%(C_CENTERS_OF_OTHER)s</i>).""" % globals())) group.append( "center_object_name", cps.ObjectNameSubscriber("Select objects to use as centers", cps.NONE, doc=""" <i>(Used only if "%(C_CENTERS_OF_OTHER)s" are selected for centers)</i><br> Select the object to use as the center, or select <i>None</i> to use the input object centers (which is the same as selecting <i>%(C_SELF)s</i> for the object centers).""" % globals())) if can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove this object", self.objects, group)) self.objects.append(group)
def add_channelfn(self, can_remove=True): """Add another image channel can_remove - true if we are allowed to remove this channel """ group = cps.SettingsGroup() self.channels.append(group) # Check which cellprofiler image we are in the group # (each channel translates to a single cellprofiler image) cpimg_index = 0 for channel in self.channels: if id(channel) == id(group): break cpimg_index += 1 group.append("divider", cps.Divider(line=True)) group.append( "cpimage_name", cps.ImageNameProvider("Image name", default_cpimage_name(cpimg_index)), ) channel_numbers = [ str(x) for x in range(0, max(10, len(self.channels) + 2)) ] group.append( "channel_number", cps.Choice( "Channel number:", channel_numbers, channel_numbers[len(self.channels) - 1], doc="""(Used only for multichannel images) The channels of a multichannel image are numbered starting from 0 (zero). Each channel is a greyscale image, acquired using different illumination sources and/or optics. Use this setting to pick the channel to associate with the image or images you load from OMERO.""", ), ) group.can_remove = can_remove if can_remove: group.append( "remover", cps.RemoveSettingButton("Remove this channel", "Remove channel", self.channels, group), )
def add_channel(self, can_remove=True): '''Add another channel to the channels list''' group = cps.SettingsGroup() group.can_remove = can_remove group.append( "channel_choice", cps.Integer(text="Channel number", value=len(self.channels) + 1, minval=1, doc="""\ *(Used only when splitting images)* This setting chooses a channel to be processed. For example, *1* is the first channel in a .TIF or the red channel in a traditional image file. *2* and *3* are the second and third channels of a TIF or the green and blue channels in other formats. *4* is the transparency channel for image formats that support transparency and is channel # 4 for a .TIF file. **ColorToGray** will fail to process an image if you select a channel that is not supported by that image, for example, “5” for a three-channel .PNG file.""")) group.append( "contribution", cps.Float("Relative weight of the 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.''')) group.append( "image_name", cps.ImageNameProvider("Image name", value="Channel%d" % (len(self.channels) + 1), doc="""\ *(Used only when splitting images)* Select the name of the output grayscale image.""")) if group.can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove this channel", self.channels, group)) self.channels.append(group)
def add_channel(self, can_remove=True): '''Add another channel to the channels list''' group = cps.SettingsGroup() group.can_remove = can_remove group.append( "channel_choice", cps.Choice("Channel number", self.channel_names, self.channel_names[len(self.channels) % len(self.channel_names)], doc=""" This setting chooses a channel to be processed. <i>Red: 1</i> is the first channel in a .TIF or the red channel in a traditional image file. <i>Green: 2</i> and <i>Blue: 3</i> are the second and third channels of a TIF or the green and blue channels in other formats. <i>Alpha: 4</i> is the transparency channel for image formats that support transparency and is channel # 4 for a .TIF file. <b>ColorToGray</b> will fail to process an image if you select a channel that is not supported by that image, for example, "5" for a .PNG file""")) group.append( "contribution", cps.Float("Relative weight of the channel", 1, 0, doc=''' <i>(Used only when combining channels)</i><br> Relative weights: If all relative weights are equal, all three colors contribute equally in the final image. To weight colors relative to each other, increase or decrease the relative weights.''')) group.append( "image_name", cps.ImageNameProvider("Image name", value="Channel%d" % (len(self.channels) + 1), doc=""" This is the name of the grayscale image that holds the image data from the chosen channel.""")) if group.can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove this channel", self.channels, group)) self.channels.append(group)
def add_image(self, can_remove=True): '''Add an image to the image_groups collection can_delete - set this to False to keep from showing the "remove" button for images that must be present. ''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append("name", cps.ImageNameSubscriber( "Select an image to measure", cps.NONE, doc=""" Select the grayscale images whose intensity you want to measure.""")) if can_remove: group.append("remover", cps.RemoveSettingButton("", "Remove this image", self.images, group)) self.images.append(group)
def add_image_cb(self, can_remove = True): '''Add an image to the image_groups collection can_delete - set this to False to keep from showing the "remove" button for images that must be present. ''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append('image_name', cps.ImageNameSubscriber("Select an image to measure","None", doc=""" What did you call the grayscale images whose histogram you want to calculate?""")) if can_remove: group.append("remover", cps.RemoveSettingButton("", "Remove this image", self.image_groups, group)) self.image_groups.append(group)
def add_object(self, can_remove=True): '''Add an object to the object_groups collection can_delete - set this to False to keep from showing the "remove" button for images that must be present. ''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append("name", cps.ObjectNameSubscriber( "Select objects to measure", cps.NONE, doc=""" Select the objects whose intensities you want to measure.""")) if can_remove: group.append("remover", cps.RemoveSettingButton("", "Remove this object", self.objects, group)) self.objects.append(group)
def add_labels(self, can_remove=True): group = cps.SettingsGroup() group.append( "class_name", cps.AlphanumericText("Class name", "Class %d" % (len(self.label_classes) + 1), doc=""" The name to give to pixels of this class (e.g. "Foreground") You should add one class for each class you defined in Ilastik""")) if can_remove: group.append( "remover", cps.RemoveSettingButton("Remove object", "Remove", self.label_classes, group)) self.label_classes.append(group)
def add_stack_channel_cb(self, can_remove=True): group = cps.SettingsGroup() group.append( "image_name", cps.ImageNameSubscriber("Image name", cps.NONE, doc='''\ Select the input image to add to the stacked image. ''' % globals())) if can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove this image", self.stack_channels, group)) self.stack_channels.append(group)
def add_output(self, can_remove=True): group = cps.SettingsGroup() group.append("output_image", cps.ImageNameProvider("Output image", "Probability")) group.append( "class_name", cps.Choice("Class name", choices=self.get_class_names(), choices_fn=self.get_class_names)) if can_remove: group.append( "remover", cps.RemoveSettingButton("Remove object", "Remove", self.outputs, group)) self.outputs.append(group)
def add_objects(self, can_delete=True): group = cps.SettingsGroup() self.objects_to_export.append(group) group.append( "objects_name", cps.ObjectNameSubscriber("Objects name", value="Nuclei", doc=""" This setting lets you choose the objects you want to export. <b>ExportToCellH5</b> will write the segmentation of the objects to your CellH5 file so that they can be saved and used by other applications that support the format. """)) group.append( "Remover", cps.RemoveSettingButton("Remove the objects above", "Remove", self.objects_to_export, group))
def add_bins_cb(self, can_remove = True): '''Add an histogram to the bin_groups collection can_delete - set this to False to keep from showing the "remove" button for histograms that must be present. ''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append('bins', cps.Integer("Number of bins", len(self.bins_groups)+3, doc="""How much bins do you want in your histogram? You can calculate several histograms with different number of bins using the "Add another histogram" button.""")) if can_remove: group.append("remover", cps.RemoveSettingButton("", "Remove this histogram", self.bins_groups, group)) self.bins_groups.append(group)
def add_objects(self): og = cps.SettingsGroup() og.append( "objects_name", cps.ObjectNameSubscriber("Select objects to measure", cps.NONE, doc="""\ Select the objects whose granualarity will be measured. You can select objects from prior modules that identify objects, such as **IdentifyPrimaryObjects**. If you only want to measure the granularity for the image overall, you can remove all objects using the “Remove this object” button.""")) og.append( "remover", cps.RemoveSettingButton("", "Remove this object", self.objects, og)) self.objects.append(og)
def add_image(self, can_delete=True): group = cps.SettingsGroup() self.images_to_export.append(group) group.append( "image_name", cps.ImageNameSubscriber("Image name", value="DNA", doc=""" This setting lets you choose the images you want to export. <b>ExportToCellH5</b> will write the image to your CellH5 file so that it can be used by other applications that support the format. """)) group.append( "remover", cps.RemoveSettingButton("Remove the image above", "Remove", self.objects_to_export, group))
def add_image_measurement(self, can_remove=True): group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider()) group.append( "image_name", cps.ImageNameSubscriber("Select the image to measure", cps.NONE, doc="""\ Choose an image name from the drop-down menu to calculate intensity for that image. Use the *Add another image* button below to add additional images to be measured. You can add the same image multiple times if you want to measure the intensity within several different objects.""")) group.append( "wants_objects", cps.Binary( "Measure the intensity only from areas enclosed by objects?", False, doc="""\ Select *%(YES)s* to measure only those pixels within an object type you choose, identified by a prior module. Note that this module will aggregate intensities across all objects in the image: to measure each object individually, see **MeasureObjectIntensity** instead. """ % globals())) group.append( "object_name", cps.ObjectNameSubscriber("Select the input objects", cps.NONE, doc="""\ *(Used only when measuring intensity from area occupied by objects)* Select the objects that the intensity will be aggregated within. The intensity measurement will be restricted to the pixels within these objects.""")) if can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove this image", self.images, group)) self.images.append(group)
def add_image(self, can_remove=True): '''Add an image + associated questions and buttons''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=True)) group.append( "input_image_name", cps.ImageNameSubscriber( "Select an additional image to tile", cps.NONE, doc="""Select an additional image to tile?""")) if can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove above image", self.additional_images, group)) self.additional_images.append(group)
def add_object(self, can_delete=True): '''Add an object to the object_groups collection''' group = cps.SettingsGroup() if can_delete: group.append("divider", cps.Divider(line=False)) group.append( "object_name", cps.ObjectNameSubscriber('Select an object to measure', cps.NONE, doc='Select the objects to be measured.')) if can_delete: group.append( "remover", cps.RemoveSettingButton('', 'Remove this object', self.object_groups, group)) self.object_groups.append(group)
def add_mapping(self): group = cps.SettingsGroup() group.append( "local_directory", cps.Text("Local root path", cpprefs.get_default_image_directory(), doc="""\ Enter the path to files on this computer. This is the root path on the local machine (i.e., the computer setting up the batch files). If **CreateBatchFiles** finds any pathname that matches the local root path at the begining, it will replace the start with the cluster root path. For example, if you have mapped the remote cluster machine like this: ``Z:\your_data\images`` (on a Windows machine, for instance) and the cluster machine sees the same folder like this: ``/server_name/your_name/your_data/images`` you would enter ``Z:\`` here and ``/server_name/your_name/`` for the cluster path in the next setting.""")) group.append( "remote_directory", cps.Text("Cluster root path", cpprefs.get_default_image_directory(), doc="""\ Enter the path to files on the cluster. This is the cluster root path, i.e., how the cluster machine sees the top-most folder where your input/output files are stored. For example, if you have mapped the remote cluster machine like this: ``Z:\your_data\images`` (on a Windows machine, for instance) and the cluster machine sees the same folder like this: ``/server_name/your_name/your_data/images`` you would enter ``Z:\`` in the previous setting for the local machine path and ``/server_name/your_name/`` here .""")) group.append( "remover", cps.RemoveSettingButton("", "Remove this path mapping", self.mappings, group)) group.append("divider", cps.Divider(line=False)) self.mappings.append(group)
def add_image(self, can_remove=True): '''Add an image + associated questions and buttons''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append("input_image_name", cps.ImageNameSubscriber( "Select the additional image?", cps.NONE, doc=""" What is the name of the additional image to resize? This image will be resized with the same settings as the first image.""")) group.append("output_image_name", cps.ImageNameProvider("Name the output image", "CroppedImage2", doc=""" What is the name of the additional resized image?""")) if can_remove: group.append("remover", cps.RemoveSettingButton("", "Remove above image", self.additional_images, group)) self.additional_images.append(group)
def add_image(self, can_remove=True): '''Add an image to be measured''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append( "image_name", cps.ImageNameSubscriber("Select an image to measure", cps.NONE, doc=""" Select the image that you want to measure the intensity from.""" )) if can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove this image", self.images, group)) self.images.append(group)
def add_object(self, can_remove=True): """Add a slot for another object""" group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append( "name", cps.ObjectNameSubscriber( "Select objects to measure", cps.NONE, doc="""Select the objects that you want to measure.""")) if can_remove: group.append( "remove", cps.RemoveSettingButton("", "Remove this object", self.object_groups, group)) self.object_groups.append(group)
def add_step_parent(self, can_delete=True): group = cps.SettingsGroup() group.append( "step_parent_name", cps.Choice("Parent name", [cps.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>RelateObjects</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)
def add_image(self, can_delete=True): '''Add an image to the image_groups collection can_delete - set this to False to keep from showing the "remove" button for images that must be present. ''' group = cps.SettingsGroup() if can_delete: group.append("divider", cps.Divider(line=False)) group.append("image_name", cps.ImageNameSubscriber( 'Select an image to measure', cps.NONE, doc=''' Select an image to measure the correlation from.''')) if len(self.image_groups) == 0: # Insert space between 1st two images for aesthetics group.append("extra_divider", cps.Divider(line=False)) if can_delete: group.append("remover", cps.RemoveSettingButton("", "Remove this image", self.image_groups, group)) self.image_groups.append(group)
def add_image(self, can_remove=True): '''Add an image + associated questions and buttons''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append( "input_image_name", cps.ImageNameSubscriber("Select the additional image", cps.NONE, doc=""" Select the additional image to align?""")) group.append( "output_image_name", cps.ImageNameProvider("Name the output image", "AlignedBlue", doc=""" Enter the name of the aligned image?""")) group.append( "align_choice", cps.Choice("Select how the alignment is to be applied", [A_SIMILARLY, A_SEPARATELY], doc="""\ An additional image can either be aligned similarly to the second one or a separate alignment to the first image can be calculated: - *%(A_SIMILARLY)s:* The same alignment measurements obtained from the first two input images are applied to this additional image. - *%(A_SEPARATELY)s:* A new set of alignment measurements are calculated for this additional image using the alignment method specified with respect to the first input image. """ % globals())) if can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove above image", self.additional_images, group)) self.additional_images.append(group)
def add_scale_cb(self, can_remove=True): '''Add a scale to the scale_groups collection can_delete - set this to False to keep from showing the "remove" button for scales that must be present. ''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append('scale', cps.Integer("Texture scale to measure", len(self.scale_groups) + 3, doc="""You can specify the scale of texture to be measured, in pixel units; the texture scale is the distance between correlated intensities in the image. A higher number for the scale of texture measures larger patterns of texture whereas smaller numbers measure more localized patterns of texture. It is best to measure texture on a scale smaller than your objects' sizes, so be sure that the value entered for scale of texture is smaller than most of your objects. For very small objects (smaller than the scale of texture you are measuring), the texture cannot be measured and will result in a undefined value in the output file.""")) group.append('angles', cps.MultiChoice( "Angles to measure", H_ALL, H_ALL, doc="""The Haralick texture measurements are based on the correlation between pixels offset by the scale in one of four directions: <p><ul> <li><i>%(H_HORIZONTAL)s</i> - the correlated pixel is "scale" pixels to the right of the pixel of interest.</li> <li><i>%(H_VERTICAL)s</i> - the correlated pixel is "scale" pixels below the pixel of interest.</li> <li><i>%(H_DIAGONAL)s</i> - the correlated pixel is "scale" pixels to the right and "scale" pixels below the pixel of interest.</li> <li><i>%(H_ANTIDIAGONAL)s</i> - the correlated pixel is "scale" pixels to the left and "scale" pixels below the pixel of interest.</li> </ul><p> Choose one or more directions to measure.""" % globals())) if can_remove: group.append("remover", cps.RemoveSettingButton("", "Remove this scale", self.scale_groups, group)) self.scale_groups.append(group)
def add_bin_count(self, can_remove=True): '''Add another radial bin count at which to measure''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append("wants_scaled", cps.Binary( "Scale the bins?", True, doc=""" <p>Select <i>%(YES)s</i> to divide the object radially into the number of bins that you specify. </p> <p>Select <i>%(NO)s</i> to create the number of bins you specify based on distance. For this option, the user will be asked to specify a maximum distance so that each object will have the same measurements (which might be zero for small objects) and so that the measurements can be taken without knowing the maximum object radius before the run starts.</p>""" % globals())) group.append("bin_count", cps.Integer( "Number of bins", 4, 2, doc=""" Specify the number of bins that you want to use to measure the distribution. Radial distribution is measured with respect to a series of concentric rings starting from the object center (or more generally, between contours at a normalized distance from the object center). This number specifies the number of rings into which the distribution is to be divided. Additional ring counts can be specified by clicking the <i>Add another set of bins</i> button.""")) group.append("maximum_radius", cps.Integer( "Maximum radius", 100, minval=1, doc=""" Specify the maximum radius for the unscaled bins. The unscaled binning method creates the number of bins that you specify and creates equally spaced bin boundaries up to the maximum radius. Parts of the object that are beyond this radius will be counted in an overflow bin. The radius is measured in pixels.""")) group.can_remove = can_remove if can_remove: group.append("remover", cps.RemoveSettingButton("", "Remove this set of bins", self.bin_counts, group)) self.bin_counts.append(group)
def add_stack_channel_cb(self, can_remove=True): group = cps.SettingsGroup() default_color = DEFAULT_COLORS[len(self.stack_channels) % len(DEFAULT_COLORS)] group.append( "image_name", cps.ImageNameSubscriber("Image name", cps.NONE, doc='''\ *(Used only if "%(SCHEME_STACK)s" or "%(SCHEME_COMPOSITE)s" is chosen)* Select the input image to add to the stacked image ''' % globals())) group.append( "color", cps.Color("Color", default_color, doc='''\ *(Used only if "%(SCHEME_COMPOSITE)s" is chosen)* The color to be assigned to the above image. ''' % globals())) group.append( "weight", cps.Float("Weight", 1.0, minval=.5 / 255, doc='''\ *(Used only if "%(SCHEME_COMPOSITE)s" is chosen)* The weighting of the above image relative to the others. The image’s pixel values are multiplied by this weight before assigning the color. ''' % globals())) if can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove this image", self.stack_channels, group)) self.stack_channels.append(group)
def add_object_cb(self, can_remove = True): '''Add an object to the object_groups collection can_delete - set this to False to keep from showing the "remove" button for objects that must be present. ''' group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider(line=False)) group.append('object_name', cps.ObjectNameSubscriber("Select objects to measure","None", doc=""" What did you call the objects whose histogram you want to calculate? If you only want to calculate the histogram for the image overall, you can remove all objects using the "Remove this object" button. <p>Objects specified here will have their histogram calculated against <i>all</i> images specified above, which may lead to image-object combinations that are unneccesary. If you do not want this behavior, use multiple <b>CalculateHistogram</b> modules to specify the particular image-object measures that you want.</p>""")) if can_remove: group.append("remover", cps.RemoveSettingButton("", "Remove this object", self.object_groups, group)) self.object_groups.append(group)
def add_recipient(self, can_delete=True): '''Add a recipient for the email to the list of emails''' group = cps.SettingsGroup() group.append( "recipient", cps.Text("Recipient address", "recipient@domain", doc=""" Enter the address to which the messages will be sent.""")) if can_delete: group.append( "remover", cps.RemoveSettingButton("Remove above recipient", "Remove recipient", self.recipients, group, doc=""" Press this button to remove the above recipient from the list of people to receive the email""")) self.recipients.append(group)
def add_image_measurement(self, can_remove=True): group = cps.SettingsGroup() if can_remove: group.append("divider", cps.Divider()) group.append( "image_name", cps.ImageNameSubscriber("Select the image to measure", cps.NONE, doc=''' Choose an image name from the drop-down menu to calculate intensity for that image. Use the <i>Add another image</i> button below to add additional images which will be measured. You can add the same image multiple times if you want to measure the intensity within several different objects.''')) group.append( "wants_objects", cps.Binary( "Measure the intensity only from areas enclosed by objects?", False, doc=""" Select <i>%(YES)s</i> to measure only those pixels within an object of choice.""" % globals())) group.append( "object_name", cps.ObjectNameSubscriber("Select the input objects", cps.NONE, doc=''' <i>(Used only when measuring intensity from area enclosed by objects)</i><br> Select the objects that the intensity will be aggregated within. The intensity measurement will be restricted to the pixels within these objects.''')) if can_remove: group.append( "remover", cps.RemoveSettingButton("", "Remove this image", self.images, group)) self.images.append(group)