Пример #1
0
    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 <b>CreateBatchFiles</b> finds
                        any pathname that matches the local root path at the begining, it will replace the
                        start with the cluster root path.
                        <p>For example, if you have mapped the remote cluster machine like this:<br><br>
                        <tt>Z:\your_data\images</tt> (on a Windows machine, for instance)<br><br>
                        and the cluster machine sees the same folder like this:<br><br>
                        <tt>/server_name/your_name/your_data/images</tt><br><br>
                        you would enter <tt>Z:\</tt> here and <t>/server_name/your_name/</tt>
                        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.
                        <p>For example, if you have mapped the remote cluster machine like this:<br><br>
                        <tt>Z:\your_data\images</tt> (on a Windows machine, for instance)<br><br>
                        and the cluster machine sees the same folder like this:<br><br>
                        <tt>/server_name/your_name/your_data/images</tt><br><br>
                        you would enter <tt>Z:\</tt> in the previous setting for the
                        local machine path and <t>/server_name/your_name/</tt> 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 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)
Пример #3
0
    def create_settings(self):
        self.image_name = cps.ImageNameSubscriber("Select the input image",
                                                  cps.NONE)

        self.conversion_method = cps.Choice("Conversion method",
                                            [MEAN, MEDIAN, CUSTOMFUNCTION],
                                            doc='''
            How do you want to summarize the multichannel image?
            <ul>
            <li><i>%(MEAN)s:</i> Takes the mean.</li>
            <li><i>%(MEDIAN)s</i> Takes the median</li>
            <li><i>%(MEDIAN)s</i> Applies a cutstom python function</li>
            </ul>''' % globals())

        self.custom_function = cps.Text("Input a Python function",
                                        'np.mean',
                                        doc='''
        Can be a simple function as "np.max" (without ") or complicated as "functools.partial(np.percentile,q=80, axis=2)".
        functools is imported as convenience.
        ''')
        # The following settings are used for the combine option
        self.grayscale_name = cps.ImageNameProvider("Name the output image",
                                                    "OrigGray")

        # The alternative model:
        self.channels = []
Пример #4
0
    def add_dose_value(self, can_remove=True):
        '''Add a dose value measurement to the list

        can_delete - set this to False to keep from showing the "remove"
                     button for images that must be present.'''
        group = cps.SettingsGroup()
        group.append("measurement",
                     cps.Measurement("Select the image measurement describing the treatment dose",
                                     lambda: cpmeas.IMAGE,
                                     doc="""\
The V and Z’ factors, metrics of assay quality, and the EC50,
indicating dose-response, are calculated by this module based on each
image being specified as a particular treatment dose. Choose a
measurement that gives the dose of some treatment for each of your
images. See the help for the previous setting for details."""))

        group.append("log_transform", cps.Binary(
                "Log-transform the dose values?", False, doc='''\
Select *%(YES)s* if you have dose-response data and you want to
log-transform the dose values before fitting a sigmoid curve.

Select *%(NO)s* if your data values indicate only positive vs. negative
controls.
''' % globals()))

        group.append('wants_save_figure', cps.Binary(
                '''Create dose-response plots?''', False, doc='''Select *%(YES)s* if you want to create and save dose-response plots.
You will be asked for information on how to save the plots.''' % globals()))

        group.append('figure_name', cps.Text(
                "Figure prefix", "", doc='''\
*(Used only when creating dose-response plots)*

CellProfiler will create a file name by appending the measurement name
to the prefix you enter here. For instance, if you specify a prefix
of “Dose\_”, when saving a file related to objects you have chosen (for
example, *Cells*) and a particular measurement (for example, *AreaShape_Area*),
CellProfiler will save the figure as *Dose_Cells_AreaShape_Area.m*.
Leave this setting blank if you do not want a prefix.
'''
        ))
        group.append('pathname', cps.DirectoryPath(
                "Output file location",
                dir_choices=[
                    cps.DEFAULT_OUTPUT_FOLDER_NAME, cps.DEFAULT_INPUT_FOLDER_NAME,
                    cps.ABSOLUTE_FOLDER_NAME, cps.DEFAULT_OUTPUT_SUBFOLDER_NAME,
                    cps.DEFAULT_INPUT_SUBFOLDER_NAME], doc="""\
*(Used only when creating dose-response plots)*

This setting lets you choose the folder for the output files. %(IO_FOLDER_CHOICE_HELP_TEXT)s

%(IO_WITH_METADATA_HELP_TEXT)s
""" % globals()))

        group.append("divider", cps.Divider())

        group.append("remover", cps.RemoveSettingButton("", "Remove this dose measurement",
                                                        self.dose_values,
                                                        group))
        self.dose_values.append(group)
Пример #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.""",
        )
Пример #6
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)
Пример #7
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)
Пример #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.""")
Пример #9
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)
Пример #10
0
    def create_settings(self):
        self.input_type = cps.Choice("Select the type of input",
                                     [IF_IMAGE, IF_OBJECTS], IF_IMAGE)

        self.image_name = cps.ImageNameSubscriber("Select input images",
                                                  cps.NONE)

        self.objects_name = cps.ObjectNameSubscriber(
            "Select the input objects",
            cps.NONE,
        )

        self.output_name = cps.ImageNameProvider(
            "Input the output image stack name",
            "BinStack",
            doc="""
            Input the output name.
            """ % globals())

        self.main_object_def = cps.Choice(
            "How should the main label be determined?",
            [SEL_MID, SEL_MAXAREA, SEL_PROVIDED],
            SEL_MID,
            doc="""
            The main object can be determined by 3 ways:
            <ul>
            <li> %(SEL_PROVIDED)s: Label provided by metadata or
            manual. <\li>
            <li> %(SEL_MAXAREA)s: Label with the biggest area is assumed to be
            the main label. <\li>
            <li> %(SEL_MID)s: The label closest to the middle of the image is
            considered the main label. <\li>
            <\ul>
            """ % globals())

        self.main_object_id = cps.Text("Indicate the object id",
                                       '1',
                                       doc="""
                Indicates the id from the main object.
                Rightclick to choose a metadata value.
                """ % globals(),
                                       metadata=True)
Пример #11
0
    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)
Пример #12
0
 def test_00_00_init(self):
     x = cps.Text("text", "value")
     x.test_valid(None)
     self.assertEqual(x.text, "text")
     self.assertEqual(x.value, "value")
     self.assertTrue(x.key())
Пример #13
0
    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).

For instance, a Windows machine might access files images by mounting the file system using a drive
letter, like this:

``Z:\your_data\images``

and the cluster computers access the same file system like this:

``/server_name/your_name/your_data/images``

In this case, since the ``your_data\images`` portion of the path is
the same for both, the local root path is the portion prior, i.e.,
``Z:\`` and similarly for the cluster root path, i.e.,
``/server_name/your_name/``.

If **CreateBatchFiles** finds any pathname that matches the local root path
at the beginning, it will replace that matching portion 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 for the local root path and ``/server_name/your_name/`` for the
cluster root 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 instance, a Windows machine might access files images by mounting the file system using a drive
letter, like this:

``Z:\your_data\images``

and the cluster computers access the same file system like this:

``/server_name/your_name/your_data/images``

In this case, since the ``your_data\images`` portion of the path is
the same for both, the local root path is the portion prior, i.e.,
``Z:\`` and similarly for the cluster root path, i.e.,
``/server_name/your_name/``.

If **CreateBatchFiles** finds any pathname that matches the local root path
at the beginning, it will replace that matching portion 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:\`` in the previous setting for the local root
path and ``/server_name/your_name/`` here for the cluster root path."""))
        group.append("remover",
                     cps.RemoveSettingButton("", "Remove this path mapping", self.mappings, group))
        group.append("divider", cps.Divider(line=False))
        self.mappings.append(group)
Пример #14
0
    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):
        """Create the module settings

        create_settings is called at the end of initialization.
        """
        self.object = cps.ObjectNameSubscriber(
            'Select the object whose measurements will be displayed',
            cps.NONE,
            doc='''
            Choose the name of objects identified by some previous
            module (such as <b>IdentifyPrimaryObjects</b> or
            <b>IdentifySecondaryObjects</b>) whose measurements are to be displayed.'''
        )

        self.x_axis = cps.Measurement('Select the object measurement to plot',
                                      self.get_object,
                                      cps.NONE,
                                      doc='''
            Choose the object measurement made by a previous
            module to plot.''')

        self.bins = cps.Integer('Number of bins',
                                100,
                                1,
                                1000,
                                doc='''
            Enter the number of equally-spaced bins that you want
            used on the X-axis.''')

        self.xscale = cps.Choice(
            'Transform the data prior to plotting along the X-axis?',
            ['no', 'log'],
            None,
            doc='''
            The measurement data can be scaled with either a
            linear scale (<i>No</i>) or a <i>log</i> (base 10)
            scaling.
            <p>Log scaling is useful when one of the
            measurements being plotted covers a large range of
            values; a log scale can bring out features in the
            measurements that would not easily be seen if the
            measurement is plotted linearly.<p>''')

        self.yscale = cps.Choice('How should the Y-axis be scaled?',
                                 ['linear', 'log'],
                                 None,
                                 doc='''
            The Y-axis can be scaled either with either a <i>linear</i>
            scale or a <i>log</i> (base 10) scaling.
            <p>Log scaling is useful when one of the
            measurements being plotted covers a large range of
            values; a log scale can bring out features in the
            measurements that would not easily be seen if the
            measurement is plotted linearly.</p>''')

        self.title = cps.Text('Enter a title for the plot, if desired',
                              '',
                              doc='''
            Enter a title for the plot. If you leave this blank,
            the title will default
            to <i>(cycle N)</i> where <i>N</i> is the current image
            cycle being executed.''')

        self.wants_xbounds = cps.Binary(
            'Specify min/max bounds for the X-axis?',
            False,
            doc='''
            Select <i>%(YES)s</i> to specify minimum and maximum values for the
            plot on the X-axis. This is helpful if an outlier bin skews the
            plot such that the bins of interest are no longer visible.''' %
            globals())

        self.xbounds = cps.FloatRange('Minimum/maximum values for the X-axis')
Пример #16
0
    def add_when(self, can_delete=True):
        group = cps.SettingsGroup()
        group.append(
            "choice",
            cps.Choice("When should the email be sent?",
                       S_ALL,
                       doc="""
            Select the kind of event that causes
            <b>SendEmail</b> to send an email. You have the following choices:
            <ul>
            <li><i>%(S_FIRST)s:</i> Send an email during
            processing of the first image cycle.</li>
            <li><i>%(S_LAST)s:</i> Send an email after all processing
            is complete.</li>
            <li><i>%(S_GROUP_START)s:</i> Send an email during the first
            cycle of each group of images.</li>
            <li><i>%(S_GROUP_END)s:</i> Send an email after all processing
            for a group is complete.</li>
            <li><i>%(S_EVERY_N)s</i> Send an email each time a certain
            number of image cycles have been processed. You will be prompted
            for the number of image cycles if you select this choice.</li>
            <li><i>%(S_CYCLE_N)s:</i> Send an email after the given number
            of image cycles have been processed. You will be prompted for
            the image cycle number if you select this choice. You can add
            more events if you want emails after more than one image cycle.</li>
            </ul>""" % globals()))

        group.append(
            "image_set_number",
            cps.Integer("Image cycle number",
                        1,
                        minval=1,
                        doc='''
            <i>(Used only if sending email after a particular cycle number)</i><br>
            Send an email during processing of the given image cycle.
            For instance, if you enter 4, then <b>SendEmail</b>
            will send an email during processing of the fourth image cycle.''')
        )

        group.append(
            "image_set_count",
            cps.Integer("Image cycle count",
                        1,
                        minval=1,
                        doc='''
            <i>(Used only if sending email after every N cycles)</i><br>
            Send an email each time this number of image cycles have
            been processed. For instance, if you enter 4,
            then <b>SendEmail</b> will send an email during processing of
            the fourth, eighth, twelfth, etc. image cycles.'''))

        group.append(
            "message",
            cps.Text("Message text",
                     "Notification from CellProfiler",
                     metadata=True,
                     doc="""
            The body of the message sent from CellProfiler.
            Your message can include metadata values. For instance,
            if you group by plate and want to send an email after processing each
            plate, you could use the message
            "Finished processing plate \\g&lt;Plate&gt;". """))

        if can_delete:
            group.append(
                "remover",
                cps.RemoveSettingButton("Remove this email event",
                                        "Remove event", self.when, group))
        group.append("divider", cps.Divider())
        self.when.append(group)
Пример #17
0
    def create_settings(self):
        '''Create the UI settings for this module'''

        self.recipients = []
        self.recipient_count = cps.HiddenCount(self.recipients)
        self.add_recipient(False)
        self.add_recipient_button = cps.DoSomething("Add a recipient address.",
                                                    "Add address",
                                                    self.add_recipient)

        if sys.platform.startswith("win"):
            user = os.environ.get("USERNAME", "yourname@yourdomain")
        else:
            user = os.environ.get("USER", "yourname@yourdomain")

        self.from_address = cps.Text("Sender address",
                                     user,
                                     doc="""
            Enter the address for the email's "From" field.""")

        self.subject = cps.Text("Subject line",
                                "CellProfiler notification",
                                metadata=True,
                                doc="""
            Enter the text for the email's subject line. If you have metadata
            associated with your images, you can use metadata tags here. %(USING_METADATA_TAGS_REF)s<br>
            For instance, if you have plate metadata,
            you might use the line, "CellProfiler: processing plate " and insert the metadata tag
            for the plate at the end. %(USING_METADATA_HELP_REF)s.""" %
                                globals())

        self.smtp_server = cps.Text("Server name",
                                    "mail",
                                    doc="""
            Enter the address of your SMTP server. You can ask your
            network administrator for your outgoing mail server which is often
            made up of part of your email address, e.g.,
            "*****@*****.**". You might be able to find this information
            by checking your settings or preferences in whatever email program
            you use.""")

        self.port = cps.Integer("Port",
                                smtplib.SMTP_PORT,
                                0,
                                65535,
                                doc="""
            Enter your server's SMTP port. The default (25) is the
            port used by most SMTP servers. Your network administrator may
            have set up SMTP to use a different port; also, the connection
            security settings may require a different port.""")

        self.connection_security = cps.Choice("Select connection security",
                                              C_ALL,
                                              doc="""
            Select the connection security. Your network administrator
            can tell you which setting is appropriate, or you can check the
            settings on your favorite email program.""")

        self.use_authentication = cps.Binary(
            "Username and password required to login?",
            False,
            doc="""
            Select <i>%(YES)s</i> if you need to enter a username and password
            to authenticate.""" % globals())

        self.username = cps.Text("Username",
                                 user,
                                 doc="""
            Enter your server's SMTP username.""")

        self.password = cps.Text("Password",
                                 "",
                                 doc="""
            Enter your server's SMTP password.""")

        self.when = []
        self.when_count = cps.HiddenCount(self.when)
        self.add_when(False)

        self.add_when_button = cps.DoSomething("Add another email event",
                                               "Add email event",
                                               self.add_when,
                                               doc="""
            Press this button to add another event or condition.
            <b>SendEmail</b> will send an email when this event happens""")
Пример #18
0
    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 <i>Metadata</i>
                        category is the default used in CellProfiler to store information about
                        images (referred to as <i>metadata</i>).</p>
                        <p>The flag is stored as a per-image measurement whose name is a combination of the
                        flag's category and feature name, underscore delimited.
                        For instance, if the measurement category is
                        <i>Metadata</i> and the feature name is <i>QCFlag</i>, then the default
                        measurement name would be <i>Metadata_QCFlag</i>. %s</p>'''
                     % USING_METADATA_HELP_REF))

        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 feature name, separated by underscores.
                        For instance, if the measurement category is
                        <i>Metadata</i> and the feature name is <i>QCFlag</i>, then the default
                        measurement name would be <i>Metadata_QCFlag</i>.'''))

        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:
                        <ul>
                        <li><i>%(C_ANY)s:</i> 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.</li>
                        <li><i>%(C_ALL)s:</i> 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.</li>
                        </ul>''' % globals()))

        group.append(
            "wants_skip",
            cps.Binary("Skip image set if flagged?",
                       False,
                       doc="""
                        <p>Select <i>%(YES)s</i> 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 in any image set that is flagged.
                        Select <i>%(NO)s</i> for CellProfiler to continue to process the pipeline regardless
                        of flagging.</p>
                        <p>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
                        <b>CorrectIllumination_Calculate</b>. You can do this with a
                        pipeline that measures image quality and flags inappropriate
                        images before it runs <b>CorrectIllumination_Calculate</b>.</p>"""
                       % globals()))

        group.append(
            "add_measurement_button",
            cps.DoSomething("", "Add another measurement",
                            self.add_measurement, group))
        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):
        self.mode = cps.Choice("Classify or train?",
                               [MODE_CLASSIFY, MODE_TRAIN])
        self.advanced_or_automatic = cps.Choice(
            "Configuration mode", [AA_AUTOMATIC, AA_ADVANCED],
            doc="""Do you want to automatically choose the training parameters
            or use the defaults?""")
        self.radius = cps.Integer("Radius", DEFAULT_RADIUS, 1)
        self.n_features = cps.Integer(
            "Number of features",
            DEFAULT_N_FEATURES,
            1,
            doc="""The classifier runs a feature reduction set. This creates
            <i>Eigentextures</i> which are representative texture patches
            found throughout the image. The module scores each patch around
            a pixel according to how much it has each of these textures and
            those scores are fed into the final classifier. Raise the number of
            features if some of the textures or edges of your classes are
            misclassified. Lower the number of features to improve processing
            time or to reduce overfitting if you have a smaller amount of
            ground truth.
            """)
        self.n_estimators = cps.Integer(
            "Number of estimators",
            DEFAULT_N_ESTIMATORS,
            1,
            doc="""The classifier uses a voting scheme where it trains this
            many estimators. It purposefully does a bad job training and makes
            up for this deficit by having many poor classification judges.
            This protects against overfitting by not relying on having a single
            classifier that is very good at classifying the ground truth, but
            mistakenly uses irrelevant information to do so. Raise the number
            of estimators if the classifier is making obvious mistakes with
            unwarranted certainty. Lower the number of estimators to improve
            processing speed.""")
        self.min_samples_per_leaf = cps.Integer(
            "Minimum samples per leaf",
            DEFAULT_MIN_SAMPLES_PER_LEAF,
            1,
            doc="""This setting determines the minimum number of ground truth
            pixels that the classifier will use to split a decision tree.
            There must be at least this number of example pixels in each branch
            for the classifier to have confidence that the split is real and
            not just an artifact of an irrelevant measurement.
            
            Lower this setting if the classifier does a good job on most of the
            pixels but does not draw sharp distinctions between one class and
            another at the border between the classes (e.g. at the edges of
            cells). Raise this setting if the classifier misclassifies pixels
            that are clearly not the right class - this is overtraining.
            """)
        self.path = cps.DirectoryPath("Classifier folder")

        def get_directory_fn():
            '''Get the directory for the file name'''
            return self.path.get_absolute_path()

        def set_directory_fn(path):
            dir_choice, custom_path = self.path.get_parts_from_path(path)
            self.path.join_parts(dir_choice, custom_path)

        self.filename = cps.FilenameText(
            "Classifier file",
            "Classifier.cpclassifier",
            get_directory_fn=get_directory_fn,
            set_directory_fn=set_directory_fn,
            exts=[("Pixel classifier (*.cpclassifier)", "*.cpclassifier"),
                  ("All files (*.*)", "*.*")])
        self.gt_source = cps.Choice("Ground truth source",
                                    [SRC_OBJECTS, SRC_ILASTIK],
                                    doc="""
        The ground truth data can either be taken from objects or can be
        the exported TIF "labels" output of Ilastik.
        """)
        self.labels_image = cps.ImageNameSubscriber("Ilastik labels image",
                                                    "labels.tif",
                                                    doc="""
            <i>Used only if the ground truth source is "Ilastik"</i>
            <br>
            This image should be the exported labels image from Ilastik.
            """)
        self.wants_background_class = cps.Binary(
            "Do you want a background class?", True)
        self.background_class_name = cps.Text("Background class name",
                                              "Background")
        self.object_classes = []
        self.object_class_count = cps.HiddenCount(self.object_classes,
                                                  "Object class count")
        self.add_objects(False)
        self.add_objects_button = cps.DoSomething("Add another class", "Add",
                                                  self.add_objects)
        self.label_classes = []
        self.label_class_count = cps.HiddenCount(self.label_classes,
                                                 "Label class count")
        self.add_labels(False)
        self.add_labels_button = cps.DoSomething("Add another class", "Add",
                                                 self.add_labels)

        self.images = []
        self.image_count = cps.HiddenCount(self.images, "Image count")
        self.add_image(False)
        self.add_image_button = cps.DoSomething("Add another image", "Add",
                                                self.add_image)
        self.outputs = []
        self.output_count = cps.HiddenCount(self.outputs, "Output count")
        self.add_output(False)
        self.add_output_button = cps.DoSomething("Add another output", "Add",
                                                 self.add_output)
Пример #20
0
    def create_settings(self):
        self.objects_or_image = cps.Choice(
            "Display object or image measurements?",
            [OI_OBJECTS, OI_IMAGE],
            doc="""\
-  *%(OI_IMAGE)s* allows you to select an image measurement to display
   for each well.
-  *%(OI_OBJECTS)s* allows you to select an object measurement to
   display for each well.
""" % globals(),
        )

        self.object = cps.ObjectNameSubscriber(
            "Select the object whose measurements will be displayed",
            cps.NONE,
            doc="""\
Choose the name of objects identified by some previous module (such as
**IdentifyPrimaryObjects** or **IdentifySecondaryObjects**)
whose measurements are to be displayed.
""",
        )

        self.plot_measurement = cps.Measurement(
            "Select the measurement to plot",
            self.get_object,
            cps.NONE,
            doc=
            """Choose the image or object measurement made by a previous module to plot.""",
        )

        self.plate_name = cps.Measurement(
            "Select your plate metadata",
            lambda: cpmeas.IMAGE,
            "Metadata_Plate",
            doc="""\
Choose the metadata tag that corresponds to the plate identifier. That
is, each plate should have a metadata tag containing a specifier
corresponding uniquely to that plate.

%(USING_METADATA_HELP_REF)s
""" % globals(),
        )

        self.plate_type = cps.Choice(
            "Multiwell plate format",
            ["96", "384"],
            doc="""\
The module assumes that your data is laid out in a multi-well plate
format common to high-throughput biological screens. Supported formats
are:

-  *96:* A 96-well plate with 8 rows × 12 columns
-  *384:* A 384-well plate with 16 rows × 24 columns
""",
        )

        self.well_format = cps.Choice(
            "Well metadata format",
            [WF_NAME, WF_ROWCOL],
            doc="""\
-  *%(WF_NAME)s* allows you to select an image measurement to display
   for each well.
-  *%(WF_ROWCOL)s* allows you to select an object measurement to
   display for each well.
""" % globals(),
        )

        self.well_name = cps.Measurement(
            "Select your well metadata",
            lambda: cpmeas.IMAGE,
            "Metadata_Well",
            doc="""\
Choose the metadata tag that corresponds to the well identifier. The
row-column format of these entries should be an alphabetical character
(specifying the plate row), followed by two integer characters
(specifying the plate column). For example, a standard format 96-well
plate would span from “A1” to “H12”, whereas a 384-well plate (16 rows
and 24 columns) would span from well “A01” to well “P24”."

%(USING_METADATA_HELP_REF)s
""" % globals(),
        )

        self.well_row = cps.Measurement(
            "Select your well row metadata",
            lambda: cpmeas.IMAGE,
            "Metadata_WellRow",
            doc="""\
Choose the metadata tag that corresponds to the well row identifier,
typically specified as an alphabetical character. For example, a
standard format 96-well plate would span from row “A” to “H”, whereas a
384-well plate (16 rows and 24 columns) would span from row “A” to “P”.

%(USING_METADATA_HELP_REF)s
""" % globals(),
        )

        self.well_col = cps.Measurement(
            "Select your well column metadata",
            lambda: cpmeas.IMAGE,
            "Metadata_WellCol",
            doc="""\
Choose the metadata tag that corresponds to the well column identifier,
typically specified with two integer characters. For example, a standard
format 96-well plate would span from column “01” to “12”, whereas a
384-well plate (16 rows and 24 columns) would span from column “01” to
“24”.

%(USING_METADATA_HELP_REF)s
""" % globals(),
        )

        self.agg_method = cps.Choice(
            "How should the values be aggregated?",
            AGG_NAMES,
            AGG_NAMES[0],
            doc="""\
Measurements must be aggregated to a single number for each well so that
they can be represented by a color. Options are:

-  *%(AGG_AVG)s:* Average
-  *%(AGG_STDEV)s:* Standard deviation
-  *%(AGG_MEDIAN)s*
-  *%(AGG_CV)s:* Coefficient of variation, defined as the ratio of the
   standard deviation to the mean. This is useful for comparing between
   data sets with different units or widely different means.
""" % globals(),
        )

        self.title = cps.Text(
            "Enter a title for the plot, if desired",
            "",
            doc="""\
Enter a title for the plot. If you leave this blank, the title will
default to *(cycle N)* where *N* is the current image cycle being
executed.
""",
        )
Пример #21
0
    def add_single_measurement(self, can_delete=True):
        """Add a single measurement to the group of single measurements

        can_delete - True to include a "remove" button, False if you're not
                     allowed to remove it.
        """
        group = cps.SettingsGroup()
        if can_delete:
            group.append("divider", cps.Divider(line=True))

        group.append(
            "object_name",
            cps.ObjectNameSubscriber(
                "Select the object to be classified",
                cps.NONE,
                doc="""\
The name of the objects to be classified. You can choose from objects
created by any previous module. See **IdentifyPrimaryObjects**,
**IdentifySecondaryObjects**, **IdentifyTertiaryObjects**, or **Watershed**
""",
            ),
        )

        def object_fn():
            return group.object_name.value

        group.append(
            "measurement",
            cps.Measurement(
                "Select the measurement to classify by",
                object_fn,
                doc="""\
*(Used only if using a single measurement)*

Select a measurement made by a previous module. The objects will be
classified according to their values for this measurement.
""",
            ),
        )

        group.append(
            "bin_choice",
            cps.Choice(
                "Select bin spacing",
                [BC_EVEN, BC_CUSTOM],
                doc="""\
*(Used only if using a single measurement)*

Select how you want to define the spacing of the bins. You have the
following options:

-  *%(BC_EVEN)s:* Choose this if you want to specify bins of equal
   size, bounded by upper and lower limits. If you want two bins, choose
   this option and then provide a single threshold when asked.
-  *%(BC_CUSTOM)s:* Choose this option to create the indicated number
   of bins at evenly spaced intervals between the low and high
   threshold. You also have the option to create bins for objects that
   fall below or above the low and high threshold.
""" % globals(),
            ),
        )

        group.append(
            "bin_count",
            cps.Integer(
                "Number of bins",
                3,
                minval=1,
                doc="""\
*(Used only if using a single measurement)*

This is the number of bins that will be created between
the low and high threshold""",
            ),
        )

        group.append(
            "low_threshold",
            cps.Float(
                "Lower threshold",
                0,
                doc="""\
*(Used only if using a single measurement and "%(BC_EVEN)s" selected)*

This is the threshold that separates the lowest bin from the others. The
lower threshold, upper threshold, and number of bins define the
thresholds of bins between the lowest and highest.
""" % globals(),
            ),
        )

        group.append(
            "wants_low_bin",
            cps.Binary(
                "Use a bin for objects below the threshold?",
                False,
                doc="""\
*(Used only if using a single measurement)*

Select "*Yes*" if you want to create a bin for objects whose values
fall below the low threshold. Select "*No*" if you do not want a bin
for these objects.
""" % globals(),
            ),
        )

        def min_upper_threshold():
            return group.low_threshold.value + np.finfo(float).eps

        group.append(
            "high_threshold",
            cps.Float(
                "Upper threshold",
                1,
                minval=cps.NumberConnector(min_upper_threshold),
                doc="""\
*(Used only if using a single measurement and "%(BC_EVEN)s" selected)*

This is the threshold that separates the last bin from the others. Note
that if you would like two bins, you should select "*%(BC_CUSTOM)s*".
""" % globals(),
            ),
        )

        group.append(
            "wants_high_bin",
            cps.Binary(
                "Use a bin for objects above the threshold?",
                False,
                doc="""\
*(Used only if using a single measurement)*

Select "*Yes*" if you want to create a bin for objects whose values
are above the high threshold.

Select "*No*" if you do not want a bin for these objects.
""" % globals(),
            ),
        )

        group.append(
            "custom_thresholds",
            cps.Text(
                "Enter the custom thresholds separating the values between bins",
                "0,1",
                doc="""\
*(Used only if using a single measurement and "%(BC_CUSTOM)s" selected)*

This setting establishes the threshold values for the bins. You should
enter one threshold between each bin, separating thresholds with commas
(for example, *0.3, 1.5, 2.1* for four bins). The module will create one
more bin than there are thresholds.
""" % globals(),
            ),
        )

        group.append(
            "wants_custom_names",
            cps.Binary(
                "Give each bin a name?",
                False,
                doc="""\
*(Used only if using a single measurement)*

Select "*Yes*" to assign custom names to bins you have specified.

Select "*No*" for the module to automatically assign names based on
the measurements and the bin number.
""" % globals(),
            ),
        )

        group.append(
            "bin_names",
            cps.Text(
                "Enter the bin names separated by commas",
                cps.NONE,
                doc="""\
*(Used only if "Give each bin a name?" is checked)*

Enter names for each of the bins, separated by commas.
An example including three bins might be *First,Second,Third*.""",
            ),
        )

        group.append(
            "wants_images",
            cps.Binary(
                "Retain an image of the classified objects?",
                False,
                doc="""\
Select "*Yes*" to keep an image of the objects which is color-coded
according to their classification, for use later in the pipeline (for
example, to be saved by a **SaveImages** module).
""" % globals(),
            ),
        )

        group.append(
            "image_name",
            cps.ImageNameProvider(
                "Name the output image",
                "ClassifiedNuclei",
                doc=
                """Enter the name to be given to the classified object image.""",
            ),
        )

        group.can_delete = can_delete

        def number_of_bins():
            """Return the # of bins in this classification"""
            if group.bin_choice == BC_EVEN:
                value = group.bin_count.value
            else:
                value = len(group.custom_thresholds.value.split(",")) - 1
            if group.wants_low_bin:
                value += 1
            if group.wants_high_bin:
                value += 1
            return value

        group.number_of_bins = number_of_bins

        def measurement_name():
            """Get the measurement name to use inside the bin name

            Account for conflicts with previous measurements
            """
            measurement_name = group.measurement.value
            other_same = 0
            for other in self.single_measurements:
                if id(other) == id(group):
                    break
                if other.measurement.value == measurement_name:
                    other_same += 1
            if other_same > 0:
                measurement_name += str(other_same)
            return measurement_name

        def bin_feature_names():
            """Return the feature names for each bin"""
            if group.wants_custom_names:
                return [
                    name.strip() for name in group.bin_names.value.split(",")
                ]
            return [
                "_".join((measurement_name(), "Bin_%d" % (i + 1)))
                for i in range(number_of_bins())
            ]

        group.bin_feature_names = bin_feature_names

        def validate_group():
            bin_name_count = len(bin_feature_names())
            bin_count = number_of_bins()
            if bin_count < 1:
                bad_setting = (group.bin_count if group.bin_choice == BC_EVEN
                               else group.custom_thresholds)
                raise cps.ValidationError(
                    "You must have at least one bin in order to take measurements. "
                    "Either add more bins or ask for bins for objects above or below threshold",
                    bad_setting,
                )
            if bin_name_count != number_of_bins():
                raise cps.ValidationError(
                    "The number of bin names (%d) does not match the number of bins (%d)."
                    % (bin_name_count, bin_count),
                    group.bin_names,
                )
            for bin_feature_name in bin_feature_names():
                cps.AlphanumericText.validate_alphanumeric_text(
                    bin_feature_name, group.bin_names, True)
            if group.bin_choice == BC_CUSTOM:
                try:
                    [
                        float(x.strip())
                        for x in group.custom_thresholds.value.split(",")
                    ]
                except ValueError:
                    raise cps.ValidationError(
                        "Custom thresholds must be a comma-separated list "
                        'of numbers (example: "1.0, 2.3, 4.5")',
                        group.custom_thresholds,
                    )

        group.validate_group = validate_group

        if can_delete:
            group.remove_settings_button = cps.RemoveSettingButton(
                "", "Remove this classification", self.single_measurements,
                group)
        self.single_measurements.append(group)
    def create_settings(self):
        self.objects_or_image = cps.Choice(
                "Display object or image measurements?",
                [OI_OBJECTS, OI_IMAGE], doc="""
            <ul>
            <li><i>%(OI_IMAGE)s</i> allows you to select an image
            measurement to display for each well.</li>
            <li><i>%(OI_OBJECTS)s</i> allows you to select an object measurement to display
            for each well.</li>
            </ul>""" % globals())

        self.object = cps.ObjectNameSubscriber(
                'Select the object whose measurements will be displayed',
                cps.NONE, doc='''
            Choose the name of objects identified by some previous
            module (such as <b>IdentifyPrimaryObjects</b> or
            <b>IdentifySecondaryObjects</b>) whose measurements are to be displayed.''')

        self.plot_measurement = cps.Measurement(
                'Select the measurement to plot',
                self.get_object, cps.NONE, doc='''
            Choose the image or object measurement made by a previous module to plot.''')

        self.plate_name = cps.Measurement('Select your plate metadata',
                                          lambda: cpmeas.IMAGE,
                                          'Metadata_Plate', doc='''
            Choose the metadata tag that corresponds to the plate identifier. That is,
            each plate should have a metadata tag containing a specifier corresponding
            uniquely to that plate.
            <p>%(USING_METADATA_HELP_REF)s.</p>''' % globals())

        self.plate_type = cps.Choice(
                'Multiwell plate format',
                ['96', '384'], doc=
                '''The module assumes that your data is laid out in a multi-well plate format
                common to high-throughput biological screens. Supported formats are:
                <ul>
                <li><i>96:</i> A 96-well plate with 8 rows &times; 12 columns</li>
                <li><i>384:</i> A 384-well plate with 16 rows &times; 24 columns</li>
                </ul>''')

        self.well_format = cps.Choice(
                "Well metadata format",
                [WF_NAME, WF_ROWCOL], doc="""
            <ul>
            <li> <i>%(WF_NAME)s</i> allows you to select an image
            measurement to display for each well.</li>
            <li><i>%(WF_ROWCOL)s</i> allows you to select an object measurement to display
            for each well.</li>
            </ul>""" % globals())

        self.well_name = cps.Measurement(
                'Select your well metadata',
                lambda: cpmeas.IMAGE, 'Metadata_Well', doc='''
            Choose the metadata tag that corresponds to the well identifier.
            The row-column format of these entries should be an
            alphabetical character (specifying the plate row), followed by two integer
            characters (specifying the plate column). For example, a standard format
            96-well plate would span from "A1" to "H12", whereas a 384-well plate (16
            rows and 24 columns) would span from well "A01" to well "P24"."
            <p>%(USING_METADATA_HELP_REF)s.</p>''' % globals())

        self.well_row = cps.Measurement('Select your well row metadata',
                                        lambda: cpmeas.IMAGE, 'Metadata_WellRow', doc='''
            Choose the metadata tag that corresponds to the well row identifier, typically
            specified as an alphabetical character. For example, a standard format
            96-well plate would span from  row "A" to "H", whereas a 384-well plate (16
            rows and 24 columns) would span from row "A" to "P".
            <p>%(USING_METADATA_HELP_REF)s.</p>''' % globals())

        self.well_col = cps.Measurement('Select your well column metadata',
                                        lambda: cpmeas.IMAGE, 'Metadata_WellCol', doc='''
            Choose the metadata tag that corresponds to the well column identifier, typically
            specified with two integer characters. For example, a standard format
            96-well plate would span from column "01" to "12", whereas a 384-well plate (16
            rows and 24 columns) would span from column "01" to "24".
            <p>%(USING_METADATA_HELP_REF)s.</p>''' % globals())

        self.agg_method = cps.Choice(
                'How should the values be aggregated?',
                AGG_NAMES, AGG_NAMES[0], doc='''
            Measurements must be aggregated to a
            single number for each well so that they can be represented by a color.
            Options are:
            <ul>
            <li><i>%(AGG_AVG)s:</i> Average</li>
            <li><i>%(AGG_STDEV)s:</i> Standard deviation</li>
            <li><i>%(AGG_MEDIAN)s</i></li>
            <li><i>%(AGG_CV)s:</i> Coefficient of variation, defined as the ratio of the standard
            deviation to the mean. This is useful for comparing between data sets with
            different units or widely different means.</li>
            </ul>''' % globals())

        self.title = cps.Text(
                'Enter a title for the plot, if desired', '',
                doc='''
            Enter a title for the plot. If you leave this blank,
            the title will default
            to <i>(cycle N)</i> where <i>N</i> is the current image
            cycle being executed.''')
Пример #23
0
    def create_settings(self):
        self.input_type = cps.Choice("Select the type of input", [IF_IMAGE],
                                     IF_IMAGE)

        self.image_name = cps.ImageNameSubscriber("Select the image to save",
                                                  cps.NONE,
                                                  doc="""
            <i>(Used only if "%(IF_IMAGE)s", "%(IF_MASK)s" or "%(IF_CROPPING)s" are selected to save)</i><br>
            Select the image you want to save.""" % globals())

        self.input_object_name = cps.ObjectNameSubscriber(
            "Select the objects to save", cps.NONE)

        self.objects_name = cps.ObjectNameSubscriber(
            "Select the objects to crop and save",
            cps.NONE,
            doc="""
            Select the objects that you want to save.""" % globals())

        self.file_name_method = cps.Choice(
            "Select method for constructing file names", [
                FN_FROM_IMAGE,
            ],
            doc="""
            Several choices are available for constructing the image file name:
            <ul>
            <li><i>%(FN_FROM_IMAGE)s:</i> The filename will be constructed based
            on the original filename of an input image specified in <b>NamesAndTypes</b>.
            You will have the opportunity to prefix or append
            additional text.
            <p>If you have metadata associated with your images, you can append an text
            to the image filename using a metadata tag. This is especially useful if you
            want your output given a unique label according to the metadata corresponding
            to an image group. The name of the metadata to substitute can be provided for
            each image for each cycle using the <b>Metadata</b> module.
            %(USING_METADATA_TAGS_REF)s%(USING_METADATA_HELP_REF)s.</p></li>
            </ul>""" % globals())

        self.file_image_name = cps.FileImageNameSubscriber(
            "Select image name for file prefix",
            cps.NONE,
            doc="""
            <i>(Used only when "%(FN_FROM_IMAGE)s" is selected for contructing the filename)</i><br>
            Select an image loaded using <b>NamesAndTypes</b>. The original filename will be
            used as the prefix for the output filename.""" % globals())

        self.wants_file_name_suffix = cps.Binary(
            "Append a suffix to the image file name?",
            False,
            doc="""
            Select <i>%(YES)s</i> to add a suffix to the image's file name.
            Select <i>%(NO)s</i> to use the image name as-is.""" % globals())

        self.file_name_suffix = cps.Text("Text to append to the image name",
                                         "",
                                         metadata=True,
                                         doc="""
            <i>(Used only when constructing the filename from the image filename)</i><br>
            Enter the text that should be appended to the filename specified above."""
                                         )

        self.file_format = cps.Choice("Saved file format", [FF_TIFF],
                                      value=FF_TIFF,
                                      doc="""
            <i>(Used only when saving non-movie files)</i><br>
            Select the image or movie format to save the image(s). Most common
            image formats are available; MAT-files are readable by MATLAB.""")

        self.pathname = SaveImagesDirectoryPath("Output file location",
                                                self.file_image_name,
                                                doc="""
            <i>(Used only when saving non-movie files)</i><br>
            This setting lets you choose the folder for the output
            files. %(IO_FOLDER_CHOICE_HELP_TEXT)s
            <p>An additional option is the following:
            <ul>
            <li><i>Same folder as image</i>: Place the output file in the same folder
            that the source image is located.</li>
            </ul></p>
            <p>%(IO_WITH_METADATA_HELP_TEXT)s %(USING_METADATA_TAGS_REF)s.
            For instance, if you have a metadata tag named
            "Plate", you can create a per-plate folder by selecting one the subfolder options
            and then specifying the subfolder name as "\g&lt;Plate&gt;". 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>
            <p>If the subfolder does not exist when the pipeline is run, CellProfiler will
            create it.</p>
            <p>If you are creating nested subfolders using the sub-folder options, you can
            specify the additional folders separated with slashes. For example, "Outlines/Plate1" will create
            a "Plate1" folder in the "Outlines" folder, which in turn is under the Default
            Input/Output Folder. The use of a forward slash ("/") as a folder separator will
            avoid ambiguity between the various operating systems.</p>""" %
                                                globals())

        self.bit_depth = cps.Choice(
            "Image bit depth", [BIT_DEPTH_8, BIT_DEPTH_16, BIT_DEPTH_FLOAT],
            doc="""
            <i>(Used only when saving files in a non-MAT format)</i><br>
            Select the bit-depth at which you want to save the images.
            <i>%(BIT_DEPTH_FLOAT)s</i> saves the image as floating-point decimals
            with 32-bit precision in its raw form, typically scaled between
            0 and 1.
            <b>%(BIT_DEPTH_16)s and %(BIT_DEPTH_FLOAT)s images are supported only
            for TIF formats. Currently, saving images in 12-bit is not supported.</b>"""
            % globals())

        self.object_extension = cps.Integer("Object extension",
                                            value=1,
                                            doc="""
            How many pixels should the bounding box of the objects be extended
                                            before cropping""")

        self.overwrite = cps.Binary(
            "Overwrite existing files without warning?",
            False,
            doc="""
            Select <i>%(YES)s</i> to automatically overwrite a file if it already exists.
            Select <i>%(NO)s</i> to be prompted for confirmation first.
            <p>If you are running the pipeline on a computing cluster,
            select <i>%(YES)s</i> since you will not be able to intervene and answer the confirmation prompt.</p>"""
            % globals())

        self.when_to_save = cps.Choice("When to save", [WS_FIRST_CYCLE],
                                       doc="""<a name='when_to_save'>
            <i>(Used only when saving non-movie files)</i><br>
            Specify at what point during pipeline execution to save file(s). </a>
            <ul>
            <li><i>%(WS_EVERY_CYCLE)s:</i> Useful for when the image of interest is created every cycle and is
            not dependent on results from a prior cycle.</li>
            </ul> """ % globals())

        self.update_file_names = cps.Binary(
            "Record the file and path information to the saved image?",
            False,
            doc="""
            Select <i>%(YES)s</i> to store filename and pathname data for each of the new files created
            via this module as a per-image measurement.
            <p>Instances in which this information may be useful include:
            <ul>
            <li>Exporting measurements to a database, allowing
            access to the saved image. If you are using the machine-learning tools or image
            viewer in CellProfiler Analyst, for example, you will want to enable this setting if you want
            the saved images to be displayed along with the original images.</li>
            <li>Allowing downstream modules (e.g., <b>CreateWebPage</b>) to access
            the newly saved files.</li>
            </ul></p>""" % globals())

        self.create_subdirectories = cps.Binary(
            "Create subfolders in the output folder?",
            False,
            doc="""
            Select <i>%(YES)s</i> to create subfolders to match the input image folder structure."""
            % globals())

        self.root_dir = cps.DirectoryPath("Base image folder",
                                          doc="""
            <i>Used only if creating subfolders in the output folder</i>
            In subfolder mode, <b>SaveImages</b> determines the folder for
            an image file by examining the path of the matching input file.
            The path that SaveImages uses is relative to the image folder
            chosen using this setting. As an example, input images might be stored
            in a folder structure of "images%(sep)s<i>experiment-name</i>%(sep)s
            <i>date</i>%(sep)s<i>plate-name</i>". If the image folder is
            "images", <b>SaveImages</b> will store images in the subfolder,
            "<i>experiment-name</i>%(sep)s<i>date</i>%(sep)s<i>plate-name</i>".
            If the image folder is "images%(sep)s<i>experiment-name</i>",
            <b>SaveImages</b> will store images in the subfolder,
            <i>date</i>%(sep)s<i>plate-name</i>".
            """ % dict(sep=os.path.sep))
    def create_settings(self):
        '''Create the settings for the module's UI'''
        self.warning = cps.Divider(
            "This module allows you to rename (overwrite) your files. Please "
            "see the help for this module for warnings.")

        self.image_name = cps.FileImageNameSubscriber('Select the input image',
                                                      cps.NONE,
                                                      doc="""
            Select the images associated with the files
            you want to rename. This should be an image loaded by the
            <b>Input</b> modules.
            Be very careful because you will be renaming these files!""")

        self.number_characters_prefix = cps.Integer(
            "Number of characters to retain at start of file name",
            6,
            minval=0,
            doc="""
            Number of characters at the start of the old
            file name that will be copied over verbatim to the new file name. For
            instance, if this setting is "6" and the file name is
            "Image-734.tif", the output file name will also start with
            "Image-".""")

        self.number_characters_suffix = cps.Integer(
            "Number of characters to retain at the end of file name",
            4,
            minval=0,
            doc="""
            Number of characters at the end of the old
            file name that will be copied over verbatim to the new file name. For
            instance, if this setting is "4" and the file name is
            "Image-734.tif", the output file name will also end with ".tif"."""
        )

        self.action = cps.Choice("Handling of remaining characters",
                                 [A_RENUMBER, A_DELETE],
                                 doc="""
            You can either treat the characters between the start and
            end as numbers or you can delete them. If you treat them as numbers,
            you will be given the opportunity to pad the numbers with zeros
            so that all of your file names will have a uniform length. For
            instance, if you were to renumber the highlighted portion of the
            file "Image-<u>734</u>.tif" using four digits, the result would
            be "Image-0734.tif".""")

        self.number_digits = cps.Integer("Number of digits for numbers",
                                         4,
                                         minval=0,
                                         doc="""
            <i>(Used only if %(A_RENUMBER)s is selected)</i><br>
            Use this setting to pad numbers with zeros so that they
            all have a uniform number of characters. For instance, padding
            with four digits has the following result:<br>
            <code><table>
            <tr><th>Original</th><th>Padded</th></tr>
            <tr><td>1</td><td>0001</td></tr>
            <tr><td>10</td><td>0010</td></tr>
            <tr><td>100</td><td>0100</td></tr>
            <tr><td>1000</td><td>1000</td></tr>
            </table></code>""" % globals())

        self.wants_text = cps.Binary("Add text to the file name?",
                                     False,
                                     doc="""
            Select <i>%(YES)s</i> if you want to add text
            to the file name. If you had chosen <i>%(A_RENUMBER)s</i> above,
            the module will add the text after your number.
            If you had chosen <i>%(A_DELETE)s</i>, the module will replace
            the deleted text with the text you enter here.""" % globals())

        self.text_to_add = cps.Text("Replacement text",
                                    "",
                                    doc="""
            <i>(Used only if you chose to add text to the file name)</i><br>
            Enter the text that you want to add to each file name.""")

        self.wants_to_replace_spaces = cps.Binary("Replace spaces?",
                                                  False,
                                                  doc="""
            Select <i>%(YES)s</i> to replace spaces in the final
            version of the file name with some other text.
            <p>Select <i>%(NO)s</i> if the file name can have spaces
            or if none of the file names have spaces.</p>""" % globals())

        self.space_replacement = cps.Text("Space replacement",
                                          "_",
                                          doc="""
            This is the text that will be substituted for spaces
            in your file name.""")
Пример #25
0
    def create_settings(self):
        '''Create the UI settings for the module'''
        self.seed_objects_name = cps.ObjectNameSubscriber(
            "Select the seed objects",
            cps.NONE,
            doc="""\
Select the previously identified objects that you want to use as the
seeds for measuring branches and distances. Branches and trunks are assigned
per seed object. Seed objects are typically not single points/pixels but
instead are usually objects of varying sizes.""")

        self.image_name = cps.ImageNameSubscriber(
            "Select the skeletonized image",
            cps.NONE,
            doc="""\
Select the skeletonized image of the dendrites and/or axons as produced
by the **Morph** module’s *Skel* operation.""")

        self.wants_branchpoint_image = cps.Binary(
            "Retain the branchpoint image?",
            False,
            doc="""\
Select "*%(YES)s*" if you want to save the color image of branchpoints and
trunks. This is the image that is displayed in the output window for
this module.""" % globals())

        self.branchpoint_image_name = cps.ImageNameProvider(
            "Name the branchpoint image",
            "BranchpointImage",
            doc="""\
*(Used only if a branchpoint image is to be retained)*

Enter a name for the branchpoint image here. You can then use this image
in a later module, such as **SaveImages**.""")

        self.wants_to_fill_holes = cps.Binary("Fill small holes?",
                                              True,
                                              doc="""\
The algorithm reskeletonizes the image and this can leave artifacts
caused by small holes in the image prior to skeletonizing. These holes
result in false trunks and branchpoints. Select "*%(YES)s*" to fill in
these small holes prior to skeletonizing.""" % globals())

        self.maximum_hole_size = cps.Integer("Maximum hole size",
                                             10,
                                             minval=1,
                                             doc="""\
*(Used only when filling small holes)*

This is the area of the largest hole to fill, measured in pixels. The
algorithm will fill in any hole whose area is this size or smaller.""")

        self.wants_objskeleton_graph = cps.Binary(
            "Export the skeleton graph relationships?",
            False,
            doc="""\
Select "*%(YES)s*" to produce an edge file and a vertex file that gives the
relationships between vertices (trunks, branchpoints and endpoints).""" %
            globals())

        self.intensity_image_name = cps.ImageNameSubscriber("Intensity image",
                                                            cps.NONE,
                                                            doc="""\
Select the image to be used to calculate
the total intensity along the edges between the vertices (trunks, branchpoints, and endpoints)."""
                                                            )

        self.directory = cps.DirectoryPath(
            "File output directory",
            doc=
            'Select the directory you want to save the graph relationships to.',
            dir_choices=[
                cps.DEFAULT_OUTPUT_FOLDER_NAME, cps.DEFAULT_INPUT_FOLDER_NAME,
                cps.ABSOLUTE_FOLDER_NAME, cps.DEFAULT_OUTPUT_SUBFOLDER_NAME,
                cps.DEFAULT_INPUT_SUBFOLDER_NAME
            ])
        self.directory.dir_choice = cps.DEFAULT_OUTPUT_FOLDER_NAME

        self.vertex_file_name = cps.Text("Vertex file name",
                                         "vertices.csv",
                                         doc="""\
*(Used only when exporting graph relationships)*

Enter the name of the file that will hold the edge information. You can
use metadata tags in the file name.

Each line of the file is a row of comma-separated values. The first
row is the header; this names the file’s columns. Each subsequent row
represents a vertex in the skeleton graph: either a trunk, a
branchpoint or an endpoint. The file has the following columns:

-  *image\_number:* The image number of the associated image.
-  *vertex\_number:* The number of the vertex within the image.
-  *i:* The I coordinate of the vertex.
-  *j:* The J coordinate of the vertex.
-  *label:* The label of the seed object associated with the vertex.
-  *kind:* The vertex type, with the following choices:

   -  **T:** Trunk
   -  **B:** Branchpoint
   -  **E:** Endpoint
""")

        self.edge_file_name = cps.Text("Edge file name",
                                       "edges.csv",
                                       doc="""\
*(Used only when exporting graph relationships)*

Enter the name of the file that will hold the edge information. You can
use metadata tags in the file name. Each line of the file is a row of
comma-separated values. The first row is the header; this names the
file’s columns. Each subsequent row represents an edge or connection
between two vertices (including between a vertex and itself for certain
loops). Note that vertices include trunks, branchpoints, and endpoints.

The file has the following columns:

-  *image\_number:* The image number of the associated image.
-  *v1:* The zero-based index into the vertex table of the first vertex
   in the edge.
-  *v2:* The zero-based index into the vertex table of the second vertex
   in the edge.
-  *length:* The number of pixels in the path connecting the two
   vertices, including both vertex pixels.
-  *total\_intensity:* The sum of the intensities of the pixels in the
   edge, including both vertex pixel intensities.
""")
Пример #26
0
    def add_dose_value(self, can_remove=True):
        '''Add a dose value measurement to the list

        can_delete - set this to False to keep from showing the "remove"
                     button for images that must be present.'''
        group = cps.SettingsGroup()
        group.append("measurement",
                     cps.Measurement("Select the image measurement describing the treatment dose",
                                     lambda: cpmeas.IMAGE,
                                     doc="""
            The V and Z' factor, a measure of assay quality, and the EC50, indicating
            dose/response, are calculated by this module based on each image being
            specified as a particular treatment dose. Choose a measurement that gives
            the dose of some treatment for each of your images. <p>
            The typical way to provide this information in the pipeline is to create
            a comma-delimited text file (CSV) outside of CellProfiler and then load that file into the pipeline
            using <b>Metadata</b> or the <b>LoadData</b>. In that case, choose the
            measurement that matches the column header of the measurement
            in the CSV input file. See <b>LoadData</b> help for an example text file.
            """))

        group.append("log_transform", cps.Binary(
                "Log-transform the dose values?", False, doc='''
            Select <i>%(YES)s</i> if you have dose-response data and you want to log-transform
            the dose values before fitting a sigmoid curve.
            <p>Select <i>%(NO)s</i> if your data values indicate only positive vs. negative
            controls.</p>''' % globals()))

        group.append('wants_save_figure', cps.Binary(
                '''Create dose/response plots?''', False, doc='''<a name='wants_save_figure'></a>
            Select <i>%(YES)s</i> if you want to create and save
            dose response plots. You will be asked for information on how to save the plots.''' % globals()))

        group.append('figure_name', cps.Text(
                "Figure prefix", "", doc='''
            <i>(Used only when creating dose/response plots)</i><br>
            CellProfiler will create a file name by appending the measurement name
            to the prefix you enter here. For instance, if you have objects
            named, "Cells", the "AreaShape_Area measurement", and a prefix of "Dose_",
            CellProfiler will save the figure as <i>Dose_Cells_AreaShape_Area.m</i>.
            Leave this setting blank if you do not want a prefix.'''
        ))
        group.append('pathname', cps.DirectoryPath(
                "Output file location",
                dir_choices=[
                    cps.DEFAULT_OUTPUT_FOLDER_NAME, cps.DEFAULT_INPUT_FOLDER_NAME,
                    cps.ABSOLUTE_FOLDER_NAME, cps.DEFAULT_OUTPUT_SUBFOLDER_NAME,
                    cps.DEFAULT_INPUT_SUBFOLDER_NAME], doc="""
            <i>(Used only when creating dose/response plots)</i><br>
            This setting lets you choose the folder for the output
            files. %(IO_FOLDER_CHOICE_HELP_TEXT)s

            <p>%(IO_WITH_METADATA_HELP_TEXT)s %(USING_METADATA_TAGS_REF)s
            For instance, if you have a metadata tag named
            "Plate", you can create a per-plate folder by selecting one of the subfolder options
            and then specifying the subfolder name as "\g&lt;Plate&gt;". 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()))

        group.append("divider", cps.Divider())

        group.append("remover", cps.RemoveSettingButton("", "Remove this dose measurement",
                                                        self.dose_values,
                                                        group))
        self.dose_values.append(group)
Пример #27
0
    def create_settings(self):
        self.x_source = cps.Choice(
            "Type of measurement to plot on X-axis",
            SOURCE_CHOICE,
            doc="""\
You can plot two types of measurements:

-  *%(SOURCE_IM)s:* For a per-image measurement, one numerical value is
   recorded for each image analyzed. Per-image measurements are produced
   by many modules. Many have **MeasureImage** in the name but others do
   not (e.g., the number of objects in each image is a per-image
   measurement made by the **Identify** modules).
-  *%(SOURCE_OBJ)s:* For a per-object measurement, each identified
   object is measured, so there may be none or many numerical values
   recorded for each image analyzed. These are usually produced by
   modules with **MeasureObject** in the name.
""" % globals(),
        )

        self.x_object = cps.ObjectNameSubscriber(
            "Select the object to plot on the X-axis",
            cps.NONE,
            doc="""\
*(Used only when plotting objects)*

Choose the name of objects identified by some previous module (such as
**IdentifyPrimaryObjects** or **IdentifySecondaryObjects**) whose
measurements are to be displayed on the X-axis.
""",
        )

        self.x_axis = cps.Measurement(
            "Select the measurement to plot on the X-axis",
            self.get_x_object,
            cps.NONE,
            doc=
            """Choose the measurement (made by a previous module) to plot on the X-axis.""",
        )

        self.y_source = cps.Choice(
            "Type of measurement to plot on Y-axis",
            SOURCE_CHOICE,
            doc="""\
You can plot two types of measurements:

-  *%(SOURCE_IM)s:* For a per-image measurement, one numerical value is
   recorded for each image analyzed. Per-image measurements are produced
   by many modules. Many have **MeasureImage** in the name but others do
   not (e.g., the number of objects in each image is a per-image
   measurement made by **Identify** modules).
-  *%(SOURCE_OBJ)s:* For a per-object measurement, each identified
   object is measured, so there may be none or many numerical values
   recorded for each image analyzed. These are usually produced by
   modules with **MeasureObject** in the name.
""" % globals(),
        )

        self.y_object = cps.ObjectNameSubscriber(
            "Select the object to plot on the Y-axis",
            cps.NONE,
            doc="""\
*(Used only when plotting objects)*

Choose the name of objects identified by some previous module (such as
**IdentifyPrimaryObjects** or **IdentifySecondaryObjects**) whose
measurements are to be displayed on the Y-axis.
""",
        )

        self.y_axis = cps.Measurement(
            "Select the measurement to plot on the Y-axis",
            self.get_y_object,
            cps.NONE,
            doc=
            """Choose the measurement (made by a previous module) to plot on the Y-axis.""",
        )

        self.xscale = cps.Choice(
            "How should the X-axis be scaled?",
            SCALE_CHOICE,
            None,
            doc="""\
The X-axis can be scaled with either a *linear* scale or a *log* (base
10) scaling.

Log scaling is useful when one of the measurements being plotted covers
a large range of values; a log scale can bring out features in the
measurements that would not easily be seen if the measurement is plotted
linearly.
""",
        )

        self.yscale = cps.Choice(
            "How should the Y-axis be scaled?",
            SCALE_CHOICE,
            None,
            doc="""\
The Y-axis can be scaled with either a *linear* scale or with a *log*
(base 10) scaling.

Log scaling is useful when one of the measurements being plotted covers
a large range of values; a log scale can bring out features in the
measurements that would not easily be seen if the measurement is plotted
linearly.
""",
        )

        self.title = cps.Text(
            "Enter a title for the plot, if desired",
            "",
            doc="""\
Enter a title for the plot. If you leave this blank, the title will
default to *(cycle N)* where *N* is the current image cycle being
executed.
""",
        )
    def create_settings(self):
        self.x_object = cps.ObjectNameSubscriber(
            'Select the object to display on the X-axis',
            cps.NONE,
            doc='''
            Choose the name of objects identified by some previous
            module (such as <b>IdentifyPrimaryObjects</b> or
            <b>IdentifySecondaryObjects</b>) whose measurements are to be displayed on the X-axis.'''
        )

        self.x_axis = cps.Measurement(
            'Select the object measurement to plot on the X-axis',
            self.get_x_object,
            cps.NONE,
            doc='''
            Choose the object measurement made by a previous
            module to display on the X-axis.''')

        self.y_object = cps.ObjectNameSubscriber(
            'Select the object to display on the Y-axis',
            cps.NONE,
            doc='''
            Choose the name of objects identified by some previous
            module (such as <b>IdentifyPrimaryObjects</b> or
            <b>IdentifySecondaryObjects</b>) whose measurements are to be displayed on the Y-axis.'''
        )

        self.y_axis = cps.Measurement(
            'Select the object measurement to plot on the Y-axis',
            self.get_y_object,
            cps.NONE,
            doc='''
            Choose the object measurement made by a previous
            module to display on the Y-axis.''')

        self.gridsize = cps.Integer('Select the grid size',
                                    100,
                                    1,
                                    1000,
                                    doc='''
            Enter the number of grid regions you want used on each
            axis. Increasing the number of grid regions increases the
            resolution of the plot.''')

        self.xscale = cps.Choice('How should the X-axis be scaled?',
                                 ['linear', 'log'],
                                 None,
                                 doc='''
            The X-axis can be scaled either with a <i>linear</i>
            scale or with a <i>log</i> (base 10) scaling.
            <p>Using a log scaling is useful when one of the
            measurements being plotted covers a large range of
            values; a log scale can bring out features in the
            measurements that would not easily be seen if the
            measurement is plotted linearly.</p>''')

        self.yscale = cps.Choice('How should the Y-axis be scaled?',
                                 ['linear', 'log'],
                                 None,
                                 doc='''
            The Y-axis can be scaled either with a <i>linear</i>
            scale or with a <i>log</i> (base 10) scaling.
            <p>Using a log scaling is useful when one of the
            measurements being plotted covers a large range of
            values; a log scale can bring out features in the
            measurements that would not easily be seen if the
            measurement is plotted linearly.</p>''')

        self.bins = cps.Choice('How should the colorbar be scaled?',
                               ['linear', 'log'],
                               None,
                               doc='''
            The colorbar can be scaled either with a <i>linear</i>
            scale or with a <i>log</i> (base 10) scaling.
            <p>Using a log scaling is useful when one of the
            measurements being plotted covers a large range of
            values; a log scale can bring out features in the
            measurements that would not easily be seen if the
            measurement is plotted linearly.''')

        maps = [m for m in matplotlib.cm.datad.keys() if not m.endswith('_r')]
        maps.sort()

        self.colormap = cps.Choice('Select the color map',
                                   maps,
                                   'jet',
                                   doc='''
            Select the color map for the density plot. See
            <a href="http://www.astro.princeton.edu/~msshin/science/code/matplotlib_cm/">
            this page</a> for pictures of the available colormaps.''')

        self.title = cps.Text('Enter a title for the plot, if desired',
                              '',
                              doc='''
            Enter a title for the plot. If you leave this blank,
            the title will default
            to <i>(cycle N)</i> where <i>N</i> is the current image
            cycle being executed.''')
Пример #29
0
    def create_settings(self):
        self.x_object = cps.ObjectNameSubscriber(
            'Select the object to display on the X-axis',
            cps.NONE,
            doc='''\
Choose the name of objects identified by some previous module (such as
**IdentifyPrimaryObjects** or **IdentifySecondaryObjects**) whose
measurements are to be displayed on the X-axis.
''')

        self.x_axis = cps.Measurement(
            'Select the object measurement to plot on the X-axis',
            self.get_x_object,
            cps.NONE,
            doc=
            '''Choose the object measurement made by a previous module to display on the X-axis.'''
        )

        self.y_object = cps.ObjectNameSubscriber(
            'Select the object to display on the Y-axis',
            cps.NONE,
            doc='''\
Choose the name of objects identified by some previous module (such as
**IdentifyPrimaryObjects** or **IdentifySecondaryObjects**) whose
measurements are to be displayed on the Y-axis.
''')

        self.y_axis = cps.Measurement(
            'Select the object measurement to plot on the Y-axis',
            self.get_y_object,
            cps.NONE,
            doc=
            '''Choose the object measurement made by a previous module to display on the Y-axis.'''
        )

        self.gridsize = cps.Integer('Select the grid size',
                                    100,
                                    1,
                                    1000,
                                    doc='''\
Enter the number of grid regions you want used on each
axis. Increasing the number of grid regions increases the
resolution of the plot.''')

        self.xscale = cps.Choice('How should the X-axis be scaled?',
                                 ['linear', 'log'],
                                 None,
                                 doc='''\
The X-axis can be scaled either with a *linear* scale or with a *log*
(base 10) scaling.

Using a log scaling is useful when one of the measurements being plotted
covers a large range of values; a log scale can bring out features in
the measurements that would not easily be seen if the measurement is
plotted linearly.
''')

        self.yscale = cps.Choice('How should the Y-axis be scaled?',
                                 ['linear', 'log'],
                                 None,
                                 doc='''\
The Y-axis can be scaled either with a *linear* scale or with a *log*
(base 10) scaling.

Using a log scaling is useful when one of the measurements being plotted
covers a large range of values; a log scale can bring out features in
the measurements that would not easily be seen if the measurement is
plotted linearly.
''')

        self.bins = cps.Choice('How should the colorbar be scaled?',
                               ['linear', 'log'],
                               None,
                               doc='''\
The colorbar can be scaled either with a *linear* scale or with a *log*
(base 10) scaling.

Using a log scaling is useful when one of the measurements being plotted
covers a large range of values; a log scale can bring out features in
the measurements that would not easily be seen if the measurement is
plotted linearly.
''')

        maps = [m for m in matplotlib.cm.datad.keys() if not m.endswith('_r')]
        maps.sort()

        self.colormap = cps.Choice('Select the color map',
                                   maps,
                                   'jet',
                                   doc='''\
Select the color map for the density plot. See `this page`_ for pictures
of the available colormaps.

.. _this page: http://matplotlib.org/users/colormaps.html
''')

        self.title = cps.Text('Enter a title for the plot, if desired',
                              '',
                              doc='''\
Enter a title for the plot. If you leave this blank, the title will
default to *(cycle N)* where *N* is the current image cycle being
executed.
''')
Пример #30
0
    def create_settings(self):
        self.orig_image_name = cps.ImageNameSubscriber(
                "Select the input images", cps.NONE, doc="""
            Select the images to display on the web page.""")

        self.wants_thumbnails = cps.Binary(
                "Use thumbnail images?", False, doc="""
            Select <i>%(YES)s</i> to display thumbnail images (small versions of the
            images) on the web page that link to the full images. <br>
            Select <i>%(NO)s</i> to display the full image directly on the web page.
            <p>If you are going to use thumbnails, you will need to load
            them using the <b>Input</b> modules; you can also run a separate
            pipeline prior to this one to create thumbnails from your originals
            using the <b>Resize</b> and <b>SaveImages</b> modules. For some high-content
            screening systems, thumbnail files are automatically created and have
            the text "thumb" in the name.</p>""" % globals())

        self.thumbnail_image_name = cps.ImageNameSubscriber(
                "Select the thumbnail images", cps.NONE, doc="""
            <i>(Used only if using thumbnails)</i><br>
            Select the name of the images to use for thumbnails.""")

        self.web_page_file_name = cps.Text(
                "Webpage file name", "images1",
                metadata=True, doc="""
            Enter the desired file name for the web page. <b>CreateWebPage</b>
            will add the .html extension if no extension is specified.
            If you have metadata associated with your images, you can name the
            file using metadata tags. %(USING_METADATA_TAGS_REF)s<br>
            For instance, if you have metadata tags named "Plate" and
            "Well", you can create separate per-plate, per-well web pages based on
            your metadata by inserting the tags "Plate_Well" to specify the
            name. %(USING_METADATA_HELP_REF)s.""" % globals())

        self.directory_choice = CWPDirectoryPath(
                "Select the folder for the .html file",
                dir_choices=[
                    DIR_SAME, DIR_ABOVE, ABSOLUTE_FOLDER_NAME,
                    DEFAULT_INPUT_FOLDER_NAME, DEFAULT_OUTPUT_FOLDER_NAME,
                    DEFAULT_INPUT_SUBFOLDER_NAME, DEFAULT_OUTPUT_SUBFOLDER_NAME],
                doc="""
            This setting determines how <b>CreateWebPage</b> selects the
            folder for the .html file(s) it creates.
            <ul>
            <li><i>%(DIR_SAME)s</i>: Place the .html file(s) in the same folder as
            the files.</li>
            <li><i>%(DIR_ABOVE)s</i>: Place the .html file(s) in the
            image files' parent folder.</li>
            <li><i>%(ABSOLUTE_FOLDER_NAME)s</i>: Places the .html file(s) in
            a folder of your choosing. <b>CreateWebPage</b> will use absolute
            references for your image URLs if you choose this option.</li>
            <li><i>%(DEFAULT_INPUT_FOLDER_NAME)s</i>: Places the .html file(s)
            in the default input folder.</li>
            <li><i>%(DEFAULT_OUTPUT_FOLDER_NAME)s</i>: Places the .html file(s)
            in the default output folder.</li>
            <li><i>%(DEFAULT_INPUT_SUBFOLDER_NAME)s</i>: Places the .html file(s)
            in a subfolder of the default input folder. You will be prompted
            for the subfolder name after making this choice</li>
            <li><i>%(DEFAULT_OUTPUT_SUBFOLDER_NAME)s</i>: Places the .html file(s)
            in a subfolder of the default input folder. You will be prompted
            for the subfolder name after making this choice</li>
            </ul>""" % globals())

        self.title = cps.Text(
                "Webpage title", "Image", metadata=True, doc="""
            This is the title that appears at the top of the browser
            window. If you have metadata associated with your images, you can name the
            file using metadata tags. %(USING_METADATA_TAGS_REF)sFor instance, if you
            have a metadata tag named "Plate", you can type "Plate: " and then insert
            the metadata tag "Plate" to display the plate metadata item. %(USING_METADATA_HELP_REF)s."""
                                                             % globals())

        self.background_color = cps.Color(
                "Webpage background color", "White", doc="""
            This setting controls the background color for the web page.""")

        self.columns = cps.Integer(
                "Number of columns", 1, minval=1, doc="""
            This setting determines how many images are displayed
            in each row.""")

        self.table_border_width = cps.Integer(
                "Table border width", 1, minval=0, doc="""
            The table border width determines the width of the border
            around the entire grid of displayed images (i.e., the "table" of images)
            and is measured in pixels. This value can be
            set to zero, in which case you will not see the table border.""")

        self.table_border_color = cps.Color(
                "Table border color", "White")

        self.image_spacing = cps.Integer(
                "Image spacing", 1, minval=0, doc="""
            The spacing between images ("table cells"), in pixels.""")

        self.image_border_width = cps.Integer(
                "Image border width", 1, minval=0, doc="""
            The image border width determines the width of
            the border around each image and is measured in pixels.
            This value can be set to zero, in which case you will not see the
            image border.""")

        self.create_new_window = cps.Choice(
                "Open new window when viewing full image?",
                [OPEN_ONCE, OPEN_EACH, OPEN_NO], doc="""
            This controls the behavior of the thumbnail links.
            <ul>
            <li><i>%(OPEN_ONCE)s:</i> Your browser will open a new window
            when you click on the first thumbnail and will display subsequent
            images in the newly opened window. </li>
            <li><i>%(OPEN_EACH)s:</i> The browser will open a new window each time
            you click on a link.</li>
            <li><i>%(OPEN_NO)s:</i> The browser will reuse the current window
            to display the image</li>
            </ul>""" % globals())

        self.wants_zip_file = cps.Binary(
                "Make a ZIP file containing the full-size images?", False, doc="""
            ZIP files are a common archive and data compression file format, making
            it convenient to download all of the images represented on the web page with a single click.
            Select <i>%(YES)s</i> to create a ZIP file that contains all your images,
            compressed to reduce file size.""" % globals())

        self.zipfile_name = cps.Text(
                "Enter the ZIP file name", "Images.zip",
                metadata=True, doc="""
            <i>(Used only if creating a ZIP file)</i><br>
            Specify the name for the ZIP file.""")