예제 #1
0
    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.thr = cps.Float(
                "Set threshold as percentage of maximum intensity for the images",
                15, minval=0, maxval=99, doc='''\
            Select the threshold as a percentage of the maximum intensity of the above image [0-99].''')

        self.images_or_objects = cps.Choice(
                'Select where to measure correlation',
                [M_IMAGES, M_OBJECTS, M_IMAGES_AND_OBJECTS], doc='''
            You can measure the correlation in several ways:
            <ul>
            <li><i>%(M_OBJECTS)s:</i> Measure correlation only in those pixels previously
            identified as an object. You will be asked to specify which object to measure from.</li>
            <li><i>%(M_IMAGES)s:</i> Measure the correlation across all pixels in the images.</li>
            <li><i>%(M_IMAGES_AND_OBJECTS)s:</i> Calculate both measurements above.</li>
            </ul>
            All methods measure correlation on a pixel by pixel basis.''' % globals())

        self.object_groups = []
        self.add_object(can_delete=False)
        self.object_count = cps.HiddenCount(self.object_groups)

        self.spacer_2 = cps.Divider(line=True)

        self.add_object_button = cps.DoSomething("", 'Add another object', self.add_object)
예제 #2
0
    def create_settings(self):
        """Create the settings for the module at startup.
        """
        self.image_groups = []
        self.image_count = cps.HiddenCount(self.image_groups)
        self.add_image_cb(can_remove=False)
        self.add_images = cps.DoSomething("", "Add another image",
                                          self.add_image_cb)
        self.image_divider = cps.Divider()

        self.object_groups = []
        self.object_count = cps.HiddenCount(self.object_groups)
        self.add_object_cb(can_remove=True)
        self.add_objects = cps.DoSomething("", "Add another object",
                                           self.add_object_cb)
        self.object_divider = cps.Divider()

        self.moms = cps.MultiChoice(
            "Moments to compute",
            MOM_ALL,
            MOM_ALL,
            doc=
            """Moments are statistics describing the distribution of values in the set of pixels of interest:
                <p><ul>
                <li><i>%(MOM_1)s</i> - the first image moment, which corresponds to the central value of the collection of pixels of interest.</li>
                <li><i>%(MOM_2)s</i> - the second image moment, which measures the amount of variation or dispersion of pixel values about its mean.</li>
                <li><i>%(MOM_3)s</i> - a scaled version of the third moment, which measures the asymmetry of the pixel values distribution about its mean.</li>
                <li><i>%(MOM_4)s</i> - a scaled version of the fourth moment, which measures the "peakedness" of the pixel values distribution.</li>
                </ul><p>
                Choose one or more moments to measure.""" % globals())
예제 #3
0
 def create_settings(self):
     """Create the settings variables here and name the module"""
     self.operands = []
     self.count = cps.HiddenCount(self.operands)
     self.add_operand(can_remove=False)
     self.add_operand_button = cps.DoSomething("", "Add another area", self.add_operand)
     self.remover = cps.DoSomething("", "Remove this area", self.remove)
    def create_settings(self):
        """Create the settings for the module at startup.
        
        The module allows for an unlimited number of measured objects, each
        of which has an entry in self.object_groups.
        """
        self.image_groups = []
        self.object_groups = []
        self.scale_groups = []
        self.image_count = cps.HiddenCount(self.image_groups)
        self.object_count = cps.HiddenCount(self.object_groups)
        self.scale_count = cps.HiddenCount(self.scale_groups)
        self.add_image_cb(can_remove=False)
        self.add_images = cps.DoSomething("", "Add another image",
                                          self.add_image_cb)
        self.image_divider = cps.Divider()
        self.add_object_cb(can_remove=True)
        self.add_objects = cps.DoSomething("", "Add another object",
                                           self.add_object_cb)
        self.object_divider = cps.Divider()
        self.add_scale_cb(can_remove=False)
        self.add_scales = cps.DoSomething("", "Add another scale",
                                          self.add_scale_cb)
        self.scale_divider = cps.Divider()

        self.wants_gabor = cps.Binary(
            "Measure Gabor features?",
            True,
            doc="""The Gabor features measure striped texture in an object. They
            take a substantial time to calculate. Check this setting to
            measure the Gabor features. Uncheck this setting to skip
            the Gabor feature calculation if it is not informative for your
            images""")
        self.gabor_angles = cps.Integer(
            "Number of angles to compute for Gabor",
            4,
            2,
            doc="""
        <i>(Used only if Gabor features are measured)</i><br>
        How many angles do you want to use for each Gabor texture measurement?
            The default value is 4 which detects bands in the horizontal, vertical and diagonal
            orientations.""")
        self.gabor_divider = cps.Divider()

        self.wants_tamura = cps.Binary(
            "Measure Tamura features?",
            True,
            doc="""The Tamura features are very ugly.""")
        self.tamura_feats = cps.MultiChoice("Features to compute",
                                            F_ALL,
                                            F_ALL,
                                            doc="""Tamura Features:
                        <p><ul>
                        <li><i>%(F_1)s</i> - bla.</li>
                        <li><i>%(F_2)s</i> - bla.</li>
                        <li><i>%(F_3)s</i> - bla.</li>
                        </ul><p>
                        Choose one or more features to compute.""" % globals())
예제 #5
0
    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.images = []
     self.add_image(can_remove=False)
     self.image_count = cps.HiddenCount(self.images)
     self.add_image_button = cps.DoSomething("", "Add another image", self.add_image)
     self.divider = cps.Divider()
     self.objects = []
     self.add_object(can_remove=False)
     self.add_object_button = cps.DoSomething("", "Add another object", self.add_object)
예제 #7
0
    def create_settings(self):
        """Create the settings for the module at startup.

        The module allows for an unlimited number of measured objects, each
        of which has an entry in self.object_groups.
        """
        self.image_groups = []
        self.object_groups = []
        self.scale_groups = []
        self.image_count = cps.HiddenCount(self.image_groups)
        self.object_count = cps.HiddenCount(self.object_groups)
        self.scale_count = cps.HiddenCount(self.scale_groups)
        self.add_image_cb(can_remove=False)
        self.add_images = cps.DoSomething("", "Add another image",
                                          self.add_image_cb)
        self.image_divider = cps.Divider()
        self.add_object_cb(can_remove=True)
        self.add_objects = cps.DoSomething("", "Add another object",
                                           self.add_object_cb)
        self.object_divider = cps.Divider()
        self.add_scale_cb(can_remove=False)
        self.add_scales = cps.DoSomething("", "Add another scale",
                                          self.add_scale_cb)
        self.scale_divider = cps.Divider()

        self.wants_gabor = cps.Binary(
            "Measure Gabor features?",
            True,
            doc=
            """The Gabor features measure striped texture in an object, and can
                take a substantial time to calculate.
                <p>Select <i>%(YES)s</i> to measure the Gabor features. Select
                <i>%(NO)s</i> to skip the Gabor feature calculation if it is not
                informative for your images.</p>""" % globals())

        self.gabor_angles = cps.Integer(
            "Number of angles to compute for Gabor",
            4,
            2,
            doc="""
            <i>(Used only if Gabor features are measured)</i><br>
            Enter the number of angles to use for each Gabor texture measurement.
            The default value is 4 which detects bands in the horizontal, vertical and diagonal
            orientations.""")
        self.images_or_objects = cps.Choice(
            "Measure images or objects?", [IO_IMAGES, IO_OBJECTS, IO_BOTH],
            value=IO_BOTH,
            doc="""This setting determines whether the module
            computes image-wide measurements, per-object measurements or both.
            <ul>
            <li><i>%(IO_IMAGES)s:</i> Select if you only want to measure the texture of objects.</li>
            <li><i>%(IO_OBJECTS)s:</i> Select if your pipeline does not contain objects or if
            you only want to make per-image measurements.</li>
            <li><i>%(IO_BOTH)s:</i> Select to make both image and object measurements.</li>
            </ul>""" % globals())
예제 #8
0
    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 <i>%(YES)s</i> to store batch files in the Default Output folder. <br>
            Select <i>%(NO)s</i> to enter the path to the folder that will be used to store
            these files.""" % globals())

        self.custom_output_directory = cps.Text(
                "Output folder path",
                cpprefs.get_default_output_directory(), doc="""
            Enter the path to the 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 <i>%(YES)s</i> if the cluster computers are running one of the Microsoft
            Windows operating systems. In this case, <b>CreateBatchFiles</b> will
            modify all paths to use the Windows file separator (backslash &#92;). <br>
            Select <i>%(NO)s</i> for <b>CreateBatchFiles</b> to modify all paths to use
            the Unix or Macintosh file separator (slash &#47;).""" % 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.""")

        self.go_to_website = cps.Binary(
                "Launch BatchProfiler", True,
                doc="""Launch BatchProfiler after creating the batch file. This
            setting will launch a web browser to the BatchProfiler URL to
            allow you to create batch jobs to run the analysis on a cluster.
            """)

        self.check_path_button = cps.DoSomething(
                "Press this button to check pathnames on the remote server",
                "Check paths", self.check_paths, doc="""
            This button will start a routine that will ask the
            webserver to check whether the default input and default output
            folders exist. It will also check whether all remote
            path mappings exist.""")
 def create_settings(self):
     self.images = []
     self.objects = []
     self.bin_counts = []
     self.heatmaps = []
     self.image_count = cps.HiddenCount(self.images)
     self.object_count = cps.HiddenCount(self.objects)
     self.bin_counts_count = cps.HiddenCount(self.bin_counts)
     self.heatmap_count = cps.HiddenCount(self.heatmaps)
     self.wants_zernikes = cps.Choice(
         "Calculate intensity Zernikes?",
         Z_ALL,
         doc="""This setting determines whether the intensity Zernike
         moments are calculated. Choose <i>%(Z_NONE)s</i> to save computation
         time by not calculating the Zernike moments. Choose
         <i>%(Z_MAGNITUDES)s</i> to only save the magnitude information
         and discard information related to the object's angular orientation.
         Choose <i>%(Z_MAGNITUDES_AND_PHASE)s</i> to save the phase information
         as well. The last option lets you recover each object's rough
         appearance from the Zernikes but may not contribute useful
         information if used to classify phenotypes.""" % globals())
     self.zernike_degree = cps.Integer(
         "Maximum zernike moment",
         value=9,
         minval=1,
         maxval=20,
         doc="""(<i>Only if "%s" is %s or %s</i>)<br>
         This is the maximum radial moment that will be calculated.
         There are increasing numbers of azimuthal moments as you increase
         the radial moment, so higher values are increasingly expensive
         to calculate.""" %
         (self.wants_zernikes.text, Z_MAGNITUDES, Z_MAGNITUDES_AND_PHASE))
     self.add_image_button = cps.DoSomething("", "Add another image",
                                             self.add_image)
     self.spacer_1 = cps.Divider()
     self.add_object_button = cps.DoSomething("", "Add another object",
                                              self.add_object)
     self.spacer_2 = cps.Divider()
     self.add_bin_count_button = cps.DoSomething("",
                                                 "Add another set of bins",
                                                 self.add_bin_count)
     self.spacer_3 = cps.Divider()
     self.add_heatmap_button = cps.DoSomething(
         "",
         "Add another heatmap display",
         self.add_heatmap,
         doc="""
     Press this button to add a display of one of the radial distribution
     measurements. Each radial band of the object is colored using a
     heatmap according to the measurement value for that band.""")
     self.add_image(can_remove=False)
     self.add_object(can_remove=False)
     self.add_bin_count(can_remove=False)
예제 #10
0
 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)
예제 #11
0
    def create_settings(self):
        """Create the settings during initialization

        """
        self.directory = cps.DirectoryPath(
            "Input image file location",
            support_urls=True,
            doc="""\
Choose the folder containing the image(s) to be loaded. Generally, it is
best to store the image you want to load in either the Default Input or
Output Folder, so that the correct image is loaded into the pipeline and
typos are avoided.

{IO_FOLDER_CHOICE_HELP_TEXT}

{IO_WITH_METADATA_HELP_TEXT}
""".format(
                **{
                    "IO_FOLDER_CHOICE_HELP_TEXT": IO_FOLDER_CHOICE_HELP_TEXT,
                    "IO_WITH_METADATA_HELP_TEXT": IO_WITH_METADATA_HELP_TEXT
                }))

        self.file_settings = []
        self.add_file(can_remove=False)
        self.add_button = cps.DoSomething("", "Add another image",
                                          self.add_file)
예제 #12
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.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)
예제 #13
0
 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)
예제 #14
0
    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",
            cps.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.
            """,
        )
예제 #15
0
 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)
예제 #16
0
    def create_settings(self):
        self.pipeline = None
        self.metadata_keys = {}

        module_explanation = [
            "The %s module optionally allows you to split your list of images into image subsets"
            % self.module_name,
            "(groups) which will be processed independently of each other. Examples of",
            "groupings include screening batches, microtiter plates, time-lapse movies, etc."
        ]
        self.set_notes([" ".join(module_explanation)])

        self.wants_groups = cps.Binary("Do you want to group your images?",
                                       False,
                                       doc="""\
Select "*{YES}*" if you need to split your images into image subsets (or
*groups*) such that each group is processed independently of each other.
See the main module help for more details.
""".format(**{"YES": YES}))

        self.grouping_text = cps.HTMLText(
            "",
            content=
            "Each unique metadata value (or combination of values) will be defined as a group",
            size=(30, 2))

        self.grouping_metadata = []

        self.grouping_metadata_count = cps.HiddenCount(
            self.grouping_metadata, "grouping metadata count")

        self.add_grouping_metadata(can_remove=False)

        self.add_grouping_metadata_button = cps.DoSomething(
            "", "Add another metadata item", self.add_grouping_metadata)

        self.grouping_list = cps.Table("Grouping list",
                                       min_size=(300, 100),
                                       doc="""\
This list shows the unique values of the selected metadata under the
“Group” column; each of the unique values comprises a group. The “Count”
column shows the number of image sets that included in a given group;
this is useful as a “sanity check”, to make sure that the expected
number of images are present. For example, if you are grouping by
per-plate metadata from a 384-well assay with 2 sites per well
consisting of 3 plates, you would expect to see 3 groups (each from the
3 unique plate IDs), with 384 wells × 2 sites/well = 768 image sets in
each.
""")

        self.image_set_list = cps.Table("Image sets",
                                        doc="""\
This list displays the file name and location of each of the image sets
that comprise the group. For example, if you are grouping by per-plate
metadata from a 384-well assay with 2 sites per well consisting of 3
plates, you would expect to see a table consisting of 3 plates × 384
wells/plate ×2 sites/well = 2304 rows.
""")
예제 #17
0
    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)
예제 #18
0
    def create_settings(self):
        '''Create the module settings and name the module'''
        self.runname = cps.Text(
            "Run Name",
            "Run_name",
            doc=
            "Enter a recognizable identifier for the run (spaces will be replaced by undescores)",
        )
        self.n_images_per_measurement = cellprofiler.setting.Integer(
            "Number of images per measurement",
            1,
            minval=1,
            doc=
            "The number of image files in each measurement that must be present for the pipeline to run correctly. This is usually the number of image types in the NamesAndTypes module."
        )
        self.type_first = cellprofiler.setting.Binary(
            text="Image type first",
            value=True,
            doc=
            "Wether the images are ordered by image type first. If not, ordering by measurement first is assumed."
        )
        self.is_archive = cellprofiler.setting.Binary(
            text="Is image archive",
            value=False,
            doc=
            "Set to Yes if the the images are included as a single image archive, such as an Ism file."
        )
        self.measurements_in_archive = cellprofiler.setting.Integer(
            "Number of measurements in the archive",
            1,
            minval=1,
            doc="The number of measurements in the archive file.")
        self.max_walltime = cellprofiler.setting.Integer(
            "Maximum Runtime (hours)",
            24,
            doc=
            "The maximum time for reserving a node on the cluster. Should be higher than the actual runtime, or the run may not compelte. Runs with lower values will pass the queue more quickly."
        )
        self.account = cps.Text(
            "Project Code",
            "",
            doc=
            "Enter a project code of an Supercomputing Wales project you wish to run under. This can be left empty if you have only one project.",
        )

        self.cluster_settings_button = cps.DoSomething(
            "",
            "Cluster Settings",
            update_cluster_parameters,
            doc="Change cluster and edit cluster settings.")

        self.batch_mode = cps.Binary("Hidden: in batch mode", False)
        self.revision = cps.Integer("Hidden: revision number", 0)
    def create_settings(self):
        """Create the settings for the module at startup.
        """         
        self.image_groups = []
        self.image_count = cps.HiddenCount(self.image_groups)
        self.add_image_cb(can_remove = False)
        self.add_images = cps.DoSomething("", "Add another image",
                                          self.add_image_cb)
        self.image_divider = cps.Divider()          

        self.object_groups = []
        self.object_count = cps.HiddenCount(self.object_groups)
        self.add_object_cb(can_remove = True)
        self.add_objects = cps.DoSomething("", "Add another object",
                                           self.add_object_cb)
        self.object_divider = cps.Divider()        
        
        self.bins_groups = []
        self.bins_count = cps.HiddenCount(self.bins_groups)
        self.add_bins_cb(can_remove = False)
        self.add_bins = cps.DoSomething("", "Add another histogram",
                                        self.add_bins_cb)
    def create_settings(self) -> None:
        self.crop_mask_name = cps.ObjectNameSubscriber(
            text="Select the cropping mask",
            value="None",
            doc="",
            can_be_blank=True,
        )

        self.object_groups = []
        self.add_object_group(can_remove=False)
        self.divider = cps.Divider(line=True)
        self.add_object_group_button = cps.DoSomething(
            text="",
            label="Add another object",
            callback=self.add_object_group)
예제 #21
0
    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.settings.ImageNameSubscriber(...)
            # Ask the user for the name of the output image
            self.output_image = cellprofiler.settings.ImageNameProvider(...)
            # Ask the user for a parameter
            self.smoothing_size = cellprofiler.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
        )
예제 #22
0
    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": cps.YES}),
        )
예제 #23
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber(
            "Select the input image", cps.NONE, doc='''
            Select the image to be resized.''')

        self.cropped_image_name = cps.ImageNameProvider(
            "Name the output image", "CroppedImage", doc='''
            Enter the name of the cropped image.''')

        self.crop_random = cps.Choice(
            'Crop random or specified section?', [C_RANDOM, C_SPECIFIC, C_SEED_METADATA])

        self.crop_x = cps.Text(
            "X of upper left corner", '0', doc='''
            X position.''', metadata=True)

        self.crop_y = cps.Text(
            "Y of upper left corner", '0', doc='''
            Y position.''', metadata=True)

        self.crop_w = cps.Text(
            "W width", '100', doc='''
            Width of cut.''', metadata=True)

        self.crop_h = cps.Text(
            "H height", '100', doc='''
            Height of cut.''', metadata=True)

        self.seed_metadata = cps.Text(
            "Optional Random Seed", '', doc='''
            Sets the seed based on this string.
            Use the `Metadata` module to generate metadata and right click into the
            field to select metadata.''', metadata=True
        )

        self.separator = cps.Divider(line=False)

        self.additional_images = []

        self.additional_image_count = cps.HiddenCount(
            self.additional_images, "Additional image count")

        self.add_button = cps.DoSomething("", "Add another image",
                                          self.add_image)
    def create_settings(self):
        """Create the settings for the module at startup and set the module name

        The module allows for an unlimited number of measured objects, each
        of which has an entry in self.object_groups.
        """
        self.object_groups = []
        self.add_object(can_remove=False)
        self.spacer = cps.Divider(line=True)
        self.add_objects = cps.DoSomething("", "Add another object",
                                           self.add_object)

        self.calculate_zernikes = cps.Binary('Calculate the Zernike features?',
                                             True,
                                             doc="""\
Select *%(YES)s* to calculate the Zernike shape features. Since the
first 10 Zernike polynomials (from order 0 to order 9) are calculated,
this operation can be time consuming if the image contains a lot of
objects.""" % globals())
예제 #25
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber(
            "Select the input image",cps.NONE, doc = '''
            Select the image to be resized.''')

        self.cropped_image_name = cps.ImageNameProvider(
            "Name the output image", "croppedImage", doc = '''
            Enter the name of the cropped image.''')

        self.crop_random = cps.Choice(
            'Crop random or specified section?', [C_RANDOM, C_SPECIFIC])

        self.crop_x = cps.Text(
            "X of upper left corner",  '0',  doc = '''
            X position.''', metadata=True)


        self.crop_y = cps.Text(
            "Y of upper left corner",   '0',  doc = '''
            Y position.''', metadata=True)


        self.crop_w = cps.Text(
            "W width",   '100',  doc = '''
            Width of cut.''', metadata=True)

        self.crop_h = cps.Text(
            "H height",   '100',  doc = '''
            Height of cut.''', metadata=True)



        self.separator = cps.Divider(line=False)

        self.additional_images = []

        self.additional_image_count = cps.HiddenCount(
            self.additional_images, "Additional image count")

        self.add_button = cps.DoSomething("", "Add another image",
                                          self.add_image)
예제 #26
0
    def create_settings(self):
        """Create the settings during initialization

        """
        self.directory = cps.DirectoryPath(
                "Input image file location", support_urls=True, doc='''
            Select the folder containing the image(s) to be loaded. Generally,
            it is best to store the image you want to load in either the Default Input or
            Output Folder, so that the correct image is loaded into the pipeline
            and typos are avoided. %(IO_FOLDER_CHOICE_HELP_TEXT)s

            <p>%(IO_WITH_METADATA_HELP_TEXT)s %(USING_METADATA_TAGS_REF)s For instance,
            if you have a "Plate" metadata tag, and your single files are
            organized in subfolders named with the "Plate" tag, you can select one of the
            subfolder options and then specify a subfolder name of "\g&lt;Plate&gt;"
            to get the files from the subfolder associated with that image's plate. The module will
            substitute the metadata values for the current image set for any metadata tags in the
            folder name. %(USING_METADATA_HELP_REF)s.</p>''' % globals())

        self.file_settings = []
        self.add_file(can_remove=False)
        self.add_button = cps.DoSomething("", "Add another image", self.add_file)
예제 #27
0
    def create_settings(self):

        # # # # # # # # # # # # # #
        #
        # Stack settings
        #
        # # # # # # # # # # # # # #
        self.stack_image_name = cps.ImageNameProvider(
            "Name the output image",
            "ColorImage",
            doc="""Enter a name for the resulting image.""")

        self.stack_channels = []
        self.stack_channel_count = cps.HiddenCount(self.stack_channels)
        self.add_stack_channel_cb(can_remove=False)
        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.
    """)
예제 #28
0
 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)
예제 #29
0
    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 name", 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:

+-----------------------------------+--------------------------------------------------+
| Stain                             |Specific to                                       |
+===================================+==================================================+
| AEC (3-Amino-9-ethylcarbazole)    |Peroxidase                                        |
+-----------------------------------+--------------------------------------------------+
| Alican blue                       |Mucopolysaccharides                               |
+-----------------------------------+--------------------------------------------------+
| Aniline blue                      |Pollen tubes                                      |
+-----------------------------------+--------------------------------------------------+
| Azocarmine                        |Plasma                                            |
+-----------------------------------+--------------------------------------------------+
| DAB                               |Peroxisomes, mitochondria                         |
+-----------------------------------+--------------------------------------------------+
| Eosin                             |Elastic, collagen and reticular fibers            |
+-----------------------------------+--------------------------------------------------+
| Fast red                          |Nuclei                                            |
+-----------------------------------+--------------------------------------------------+
| Fast blue                         |Myelin fibers                                     |
+-----------------------------------+--------------------------------------------------+
| Feulgen                           |DNA                                               |
+-----------------------------------+--------------------------------------------------+
| Hematoxylin                       |Nucleic acids, endoplasmic reticulum              |
+-----------------------------------+--------------------------------------------------+
| Hematoxylin and PAS               |Nucleus (stained with both Hematoxylin and PAS)   |
+-----------------------------------+--------------------------------------------------+
| Methyl blue                       |Collagen                                          |
+-----------------------------------+--------------------------------------------------+
| Methyl green                      |Chromatin                                         |
+-----------------------------------+--------------------------------------------------+
| Methylene blue                    |Nuclei                                            |
+-----------------------------------+--------------------------------------------------+
| Orange G                          |Erythrocytes, pancreas, pituitary                 |
+-----------------------------------+--------------------------------------------------+
| PAS                               |Glycogen, carbohydrates                           |
+-----------------------------------+--------------------------------------------------+
| Ponceau Fuchsin                   |Red counterstain for Masson’s trichrome           |
+-----------------------------------+--------------------------------------------------+

(Information taken from `here`_,
`here <http://en.wikipedia.org/wiki/Staining>`__, and
`here <http://stainsfile.info>`__.)
You can choose *%(CHOICE_CUSTOM)s* and enter your custom values for the
absorbance (or use the estimator to determine values from a single-stain
image).

.. _here: http://en.wikipedia.org/wiki/Histology#Staining

""" % globals()))

        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)
예제 #30
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber(
                "Select the input image", cps.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)s"* 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)s"* 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)s"* 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 ption
        self.use_hue = cps.Binary('Convert hue to gray?', True, doc="""\
*(Used only when splitting HSV images)*

Select *"%(YES)s"* 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)s"* 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)s"* 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")