How to use the cellprofiler.settings.Binary function in CellProfiler

To help you get started, we’ve selected a few CellProfiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CellProfiler / CellProfiler / pyCellProfiler / cellprofiler / modules / identifytertiaryobjects.py View on Github external
def create_settings(self):
        """Create the settings for the module
        
        Create the settings for the module during initialization.
        """
        self.secondary_objects_name = cps.ObjectNameSubscriber("Select the larger identified objects","None",doc="""
            What did you call the larger identified objects?""")
        
        self.primary_objects_name = cps.ObjectNameSubscriber("Select the smaller identified objects","None",doc="""
            What did you call the smaller identified objects?""")
        
        self.subregion_objects_name = cps.ObjectNameProvider("Name the tertiary objects to be identified","Cytoplasm",doc="""
            What do you want to call the new subregions? The new tertiary subregion 
            will consist of the smaller object subtracted from the larger object.""")
        
        self.use_outlines = cps.Binary("Retain outlines of the tertiary objects?",False)
        
        self.outlines_name = cps.OutlineNameProvider("Name the outline image","CytoplasmOutlines", doc="""\
            <i>(Used only if outlines are to be retained for later use in the pipeline)</i><br>
github CellProfiler / CellProfiler / cellprofiler / modules / trackobjects.py View on Github external
self.max_lifetime = cps.Integer(
            'Maximum lifetime', 100, doc="""
            Enter the maximum number of frames an object is permitted to persist. Objects
            which last this number of frames or more are filtered out.""")
        
        self.display_type = cps.Choice(
            'Select display option', DT_ALL, doc="""
            The output image can be saved as:
            <ul>
            <li><i>%(DT_COLOR_ONLY)s:</i> A color-labeled image, with each tracked
            object assigned a unique color</li>
            <li><i>%(DT_COLOR_AND_NUMBER)s:</i> Same as above but with the tracked object 
            number superimposed.</li>
            </ul>"""%globals())

        self.wants_image = cps.Binary(
            "Save color-coded image?", False, doc="""
            Select <i>%(YES)s</i> to retain the image showing the tracked objects 
            for later use in the pipeline. For example, a common use is for quality control purposes 
            saving the image with the <b>SaveImages</b> module.
            <p>Please note that if you are using the second phase of the %(TM_LAP)s method,
            the final labels are not assigned until <i>after</i> the pipeline has
            completed the analysis run. That means that saving the color-coded image
            will only show the penultimate result and not the final product.</p>."""%globals())

        self.image_name = cps.ImageNameProvider(
            "Name the output image", "TrackedCells", doc = '''
            <i>(Used only if saving the color-coded image)</i><br>
            Enter a name to give the color-coded image of tracked labels.''')
github CellProfiler / CellProfiler / pyCellProfiler / cellprofiler / modules / classifyobjects.py View on Github external
"Use a bin for objects below the threshold?", False,
            doc="""Check this box if you want to create a bin for objects
            whose values fall below the low threshold. Leave the box unchecked
            if you do not want a bin for these objects."""))
        
        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="""This is the threshold that separates the last bin from
            the others.
            <i>Note:</i> If you would like two bins, choose <i>Custom-defined bins</i>."""))
        
        group.append("wants_high_bin", cps.Binary(
            "Use a bin for objects above the threshold?", False,
            doc="""Check this box if you want to create a bin for objects
            whose values are above the high threshold. Leave the box unchecked
            if you do not want a bin for these objects."""))
        
        group.append("custom_thresholds", cps.Text(
            "Enter the custom thresholds separating the values between bins",
            "0,1",
            doc="""
            <i>(Used if you select Custom thresholds)</i><br>
            This setting establishes the threshold values for the
            bins. You should enter one threshold between each bin, separating
            thresholds with commas (for example, <i>0.3, 1.5, 2.1</i> for four bins).
            The module will create one more bin than there are thresholds."""))
        
        group.append("wants_custom_names", cps.Binary(
github CellProfiler / CellProfiler / cellprofiler / modules / trackobjects.py View on Github external
'Maximum gap', 5, minval=1, doc = '''
            <i>(Used only if the %(TM_LAP)s tracking method is applied and the second phase is run)</i><br>
            <b>Care must be taken to adjust this setting appropriate to the data.</b><br>
            This setting controls the maximum number of frames that can
            be skipped when merging a gap caused by an unsegmented object.
            These gaps occur when an image is mis-segmented and identification
            fails to find an object in one or more frames.
            <p><i><b>Recommendations:</b></i>
            </p><ul>
            <li>Set the maximum gap higher in order to have more chance of correctly recapturing an object after 
            erroneously losing the original for a few frames.</li>
            <li>Set the maximum gap lower to reduce the chance of erroneously connecting to the wrong object after
            correctly losing the original object (e.g., if the cell dies or moves off-screen).</li>
            </ul><p></p>'''%globals())
        
        self.wants_lifetime_filtering = cps.Binary(
            'Filter objects by lifetime?', False, doc = '''
            Select <i>%(YES)s</i> if you want objects to be filtered by their
            lifetime, i.e., total duration in frames. This is useful for
            marking objects which transiently appear and disappear, such
            as the results of a mis-segmentation. <br>
            <p><i><b>Recommendations:</b></i>
            </p><ul>
            <li>This operation does not actually delete the filtered object, 
            but merely removes its label from the tracked object list; 
            the filtered object's per-object measurements are retained.</li>
            <li>An object can be filtered only if it is tracked as an unique object.
            Splits continue the lifetime count from their parents, so the minimum
            lifetime value does not apply to them.</li>
            </ul><p></p>'''%globals())
        
        self.wants_minimum_lifetime = cps.Binary(
github CellProfiler / CellProfiler / pyCellProfiler / cellprofiler / modules / exporttospreadsheet.py View on Github external
to name the folder and to group the image sets by metadata tag.
            For instance, if you have a metadata tag named, "Plate", you can
            create a folder per-plate using the metadata tag "./&lt;Plate&gt;".
            """)
        self.custom_directory = cps.Text(
            "Folder name", ".", doc="""Name of the folder that will be used
            to store the output files. Start
            the folder name with "." to name a sub-folder of the output folder
            (for instance, "./data"). Start the folder name with "&amp;" to name
            a sub-folder of the image folder.""")
        
        self.add_metadata = cps.Binary("Add image metadata columns to your object data file?", False, doc = """&amp;qt;Image_Metadata_&amp;qt; columns are normally exported in the Image data file, but if you check this box they will also be exported with the Object data file(s).""")
        
        self.add_indexes = cps.Binary("No longer used, always saved", True)
        
        self.excel_limits = cps.Binary("Limit output to a size that is allowed in Excel?", False, doc = """
                            If your output has more than 256 columns, a window will open
                            which allows you to select the columns you'd like to export. If your output exceeds
                            65,000 rows, you can still open the .csv in Excel, but not all rows will be visible.""")
        
        self.pick_columns = cps.Binary("Select the columns of measurements to export?", False, doc = """
                            Checking this setting will open up a window that allows you to select the columns to export.""")
        
        self.wants_aggregate_means = cps.Binary("Calculate the per-image mean values for object measurements?", False, doc = """
                            <b>ExportToSpreadsheet</b> can calculate population statistics over all the 
                            objects in each image and save that value as an aggregate 
                            measurement in the Image file.  For instance, if you are measuring 
                            the area of the Nuclei objects and you check the box for this option, <b>ExportToSpreadsheet</b> will 
                            create a column in the Image file called <i>Mean_Nuclei_AreaShape_Area</i>. 
                            <p>You may not want to use <b>ExportToSpreadsheet</b> to calculate these 
                            measurements if your pipeline generates a large number of per-object 
                            measurements; doing so might exceed Excel's limits on the number of columns (256). """)</p>
github CellProfiler / CellProfiler / pyCellProfiler / cellprofiler / modules / measureimageareaoccupied.py View on Github external
def add_object(self, can_remove=True):
        # The text for these settings will be replaced in renumber_settings()
        group = cps.SettingsGroup()
        if can_remove:
            group.append("divider", cps.Divider(line=True))
        
        group.append("object_name", cps.ObjectNameSubscriber("Select objects to measure", "None"))
        
        group.append("should_save_image", cps.Binary("Retain a binary image of the object regions for use later in the pipeline (for example, in SaveImages)?", False))
        
        group.append("image_name", cps.ImageNameProvider("Name the output binary image", "Stain",doc="""
                                        <i>(Used only if the binary image of the objects is to be retained for later use in the pipeline)</i> <br> 
                                        Choose a name, which will allow the binary image of the objects to be selected later in the pipeline."""))
        if can_remove:
            group.append("remover", cps.RemoveSettingButton("", "Remove this object", self.objects, group))
        
        self.objects.append(group)
github CellProfiler / CellProfiler / pyCellProfiler / cellprofiler / modules / exporttospreadsheet.py View on Github external
def create_settings(self):
        self.delimiter = cps.CustomChoice('Select or enter the column delimiter',DELIMITERS, doc = """
                            What delimiter do you want to use? This is the character that separates columns in a file. The
                            two default choices are tab and comma, but you can type in any single character delimiter you would prefer. Be sure that the delimiter you choose is not a character that is present within your data (for example, in file names).""")
        
        self.prepend_output_filename = cps.Binary("Prepend the output file name to the data file names?", True, doc = """
                            This can be useful if you want to run a pipeline multiple 
                            times without overwriting the old results.""")
        self.directory_choice = cps.Choice(
            "Output file location",
            [DIR_DEFAULT_OUTPUT, DIR_DEFAULT_IMAGE, DIR_CUSTOM,
             DIR_CUSTOM_WITH_METADATA],
            doc="""This setting lets you choose the folder for the output
            files.<br><ul>
            <li><i>Default output folder</i> saves the .csv files in the
            default output folder.</li>
            <li><i>Default image folder</i> saves the .csv files in the
            default image folder.</li>
            <li><i>Custom folder</i> lets you specify the folder name. Start
            the folder name with "." to name a sub-folder of the output folder
            (for instance, "./data"). Start the folder name with "&amp;" to name
            a sub-folder of the image folder.</li></ul>
github CellProfiler / CellProfiler / cellprofiler / modules / exporttodatabase.py View on Github external
self.filter_field_count = cps.HiddenCount(self.filter_field_groups)
        self.add_filter_field_button = cps.DoSomething("", "Add another filter",
                                           self.add_filter_field_group)
        
        self.mysql_not_available = cps.Divider("Cannot write to MySQL directly - CSV file output only", line=False, 
            doc= """The MySQLdb python module could not be loaded.  MySQLdb is necessary for direct export.""")
        
        self.db_host = cps.Text("Database host", "")
        self.db_user = cps.Text("Username", "")
        self.db_passwd = cps.Text("Password", "")
        self.sqlite_file = cps.Text("Name the SQLite database file", 
            "DefaultDB.db", doc = """
            <i>(Used if SQLite selected as database type)</i><br>
            What is the SQLite database filename to which you want to write?""")
        
        self.wants_agg_mean = cps.Binary("Calculate the per-image mean values of object measurements?", True, doc = """
            <b>ExportToDatabase</b> can calculate population statistics over all the objects in each image
            and store the results in the database. For instance, if
            you are measuring the area of the Nuclei objects and you check the box for this option, <b>ExportToDatabase</b> will create a column in the Per_Image
            table called "Mean_Nuclei_AreaShape_Area".
            <p>You may not want to use <b>ExportToDatabase</b> to calculate these population statistics if your pipeline generates
            a large number of per-object measurements; doing so might exceed database
            column limits. These columns can be created manually for selected measurements directly in MySQL.
            For instance, the following SQL command creates the Mean_Nuclei_AreaShape_Area column:
            
                </p><p><tt>ALTER TABLE Per_Image ADD (Mean_Nuclei_AreaShape_Area);
                UPDATE Per_Image SET Mean_Nuclei_AreaShape_Area = 
                    (SELECT AVG(Nuclei_AreaShape_Area)
                     FROM Per_Object
                     WHERE Per_Image.ImageNumber = Per_Object.ImageNumber);</tt>""")
        self.wants_agg_median = cps.Binary("Calculate the per-image median values of object measurements?", False)
        self.wants_agg_std_dev = cps.Binary("Calculate the per-image standard deviation values of object measurements?", False)</p>
github CellProfiler / CellProfiler / pyCellProfiler / cellprofiler / modules / invertforprinting.py View on Github external
CC_ALL, doc = """Are you combining several grayscale images or loading a single color image?""")
        self.wants_red_input = cps.Binary(
            "Use a red image?",
            True, """Do you want to load an image for the red channel? Leave checked unless there is
            no red component to your grayscale image.""")
        self.red_input_image = cps.ImageNameSubscriber(
            "Select the red image",
            "None", doc = '''What did you call the red image?''')
        self.wants_green_input = cps.Binary(
            "Use a green image?",
            True, doc = """Do you want to load an image for the green channel? Leave checked unless there is
            no red component to your grayscale image.""")
        self.green_input_image = cps.ImageNameSubscriber(
            "Select the green image", "None",
            doc = '''What did you call the green image?''')
        self.wants_blue_input = cps.Binary(
            "Use a blue image?", True, doc = """Do you want to load an image for the blue channel?
            Leave checked unless there is no red component to your grayscale image.""")
        self.blue_input_image = cps.ImageNameSubscriber(
            "Select the blue image", "None", 
            doc = '''What did you call the blue image?''')
        self.color_input_image = cps.ImageNameSubscriber(
            "Select the color image", "None",
            doc = '''What did you call the color image?''')
        
        # output settings
        self.output_color_choice = cps.Choice(
            "Output image type",
            CC_ALL, doc = """Do you want to produce several grayscale images or one color image?""")
        self.wants_red_output = cps.Binary(
            "Produce a red image?",
            True, doc = """Do you want to produce an image for the red channel?""")
github CellProfiler / CellProfiler / pyCellProfiler / cellprofiler / modules / flagimage.py View on Github external
object measurements in an image, without averaging. In other words, if <i>any</i> of the objects meet the criteria, the image will be flagged.
                '''))
        group.append("object_name",
                     cps.ObjectNameSubscriber(
                "Select the object whose measurements will be used to flag",
                "None", doc = '''What did you call the objects whose measurements you want to use for flagging?'''))

        def object_fn():
            if group.source_choice == S_IMAGE:
                return cpmeas.IMAGE
            return group.object_name.value

        group.append("measurement", cps.Measurement("Which measurement?",
                                                    object_fn))
        group.append("wants_minimum",
                     cps.Binary("Flag images based on low values?",
                                True, doc = '''Images with measurements below this cutoff will be flagged.'''))
        group.append("minimum_value", cps.Float("Minimum value", 0))
        group.append("wants_maximum",
                     cps.Binary("Flag images based on high values?",
                                True, doc = '''Images with measurements above this cutoff will be flagged.'''))
        group.append("maximum_value", cps.Float("Maximum value", 1))
        
        if can_delete:
            group.append("remover", cps.RemoveSettingButton("", "Remove this measurement", measurement_settings, group))
            
        group.append("divider2", cps.Divider(line=True))
        measurement_settings.append(group)