Exemple #1
0
 def showTable(self):
     """
     Create the GUI and show it.  For thread safety,
     self method should be invoked from the
     event-dispatching thread.
     """
     gd = GenericDialog("Roi-group table")
     gd.addPanel(
         self
     )  # Add current table instance (a subclass of Panel to gd panel)
     gd.showDialog()
Exemple #2
0
    def showTable(self):
        """
		Add the main panel to a GenericDialog and show it 
		"""
        gd = GenericDialog("Roi-group table")
        gd.addPanel(self)  # Add current table instance to panel
        gd.addMessage("""If you use this plugin, please cite: 
		
		Laurent Thomas. (2020, November 18). 
		LauLauThom/RoiGroupTable: ImageJ/Fiji RoiGroup Table (Version 1.0)
		Zenodo. http://doi.org/10.5281/zenodo.4279049""")
        gd.addHelp(r"https://github.com/LauLauThom/RoiGroupTable")
        gd.showDialog()

        if gd.wasOKed():
            # Update ImageJ Roi group names mapping
            stringGroup = self.tableModel.getGroupString()
            Roi.setGroupNames(stringGroup)
def choose_series(filepath, params):
	"""if input file contains more than one image series (xy position), prompt user to choose which one to use"""
	# todo: if necessary (e.g. if lots of series), can improve thumbnail visuals based loosely on https://github.com/ome/bio-formats-imagej/blob/master/src/main/java/loci/plugins/in/SeriesDialog.java
	import_opts = ImporterOptions();
	import_opts.setId(filepath);
	
	reader = ImageReader();
	ome_meta = MetadataTools.createOMEXMLMetadata();
	reader.setMetadataStore(ome_meta);
	reader.setId(filepath);
	no_series = reader.getSeriesCount();
	if no_series == 1:
		return import_opts, params;
	else:
		series_names = [ome_meta.getImageName(idx) for idx in range(no_series)];
		dialog = GenericDialog("Select series to load...");
		dialog.addMessage("There are multiple series in this file! \n" + 
						"This is probably because there are multiple XY stage positions. \n " + 
						"Please choose which series to load: ");
		thumbreader = BufferedImageReader(reader);
		cbg = CheckboxGroup();
		for idx in range(no_series):
			p = Panel();
			p.add(Box.createRigidArea(Dimension(thumbreader.getThumbSizeX(), thumbreader.getThumbSizeY())));
			ThumbLoader.loadThumb(thumbreader, idx, p, True);
			dialog.addPanel(p);
			cb = Checkbox(series_names[idx], cbg, idx==0);
			p.add(cb);

		dialog.showDialog();
		if dialog.wasCanceled():
			raise KeyboardInterrupt("Run canceled");
		if dialog.wasOKed():
			selected_item = cbg.getSelectedCheckbox().getLabel();
			selected_index = series_names.index(selected_item);
			params.setSelectedSeriesIndex(selected_index);
			for idx in range(0, no_series):
				import_opts.setSeriesOn(idx, True) if (idx==selected_index) else import_opts.setSeriesOn(idx, False);
	reader.close();
	return import_opts, params
Exemple #4
0
        self.fireTableRowsDeleted(first, last)
        self.nRows -= last - first + 1


if __name__ in ['__builtin__', '__main__']:
    '''
    Test the table model by generating a simple window with just the table
    1) Initialized a JTable with the RoiGroupTableModel
    2) Put the JTable in a JScrollPane
    3) Put the JScrollPane in a Panel
    4) Put the Panel in a Generic Dialog
    5) Display the GenericDialog
    '''
    from javax.swing import JTable, JScrollPane
    from ij.gui import GenericDialog
    from java.awt import Panel

    tableModel = TableModel()
    table = JTable(tableModel)
    tableModel.setGroupColumn("A,B,C")
    print tableModel.getGroupString()

    tablePane = JScrollPane(table)
    table.setFillsViewportHeight(True)

    gd = GenericDialog("Roi-group table")
    panel = Panel()
    panel.add(tablePane)
    gd.addPanel(panel)  # Add current table instance to panel
    gd.showDialog()
Exemple #5
0
def settings():
    """ Settings """

    # Calls potential config file to set defaults
    # for settings dialog. Sets all defaults to 0
    # if no config file exists.
    con_path = os.path.join(str(Root), "FRET_params.cfg")
    if os.path.exists(con_path):
        dflt = config_read()
        print type(dflt.get("b_sub", "Rolling ball"))
        print (dflt.get("b_sub", "Rolling ball"))
        print type(int(dflt.get("b_sub", "Rolling ball")))
        print (dflt.get("b_sub", "Rolling ball"))
    else:
        dflt = {}

    feat_model_strings = ["Translation", "Rigid", 
                          "Similarity", "Affine
                          ]
    reg_model_strings = ["Translation", "Rigid",
                         "Similarity", "Affine",
                         "Elastic", "Least Squares"
                         ]
    b_sub_strings = ["Rolling Ball", "Manual Selection"]
                         
    # Registration parameters dialog.
    gd = GenericDialog("Advanced Settings")
    gd.addMessage("REGISTRATION PARAMETERS") 
    gd.addNumericField("Steps per scale octave: ", float(dflt.get("steps", 6)), 0, 7, "")
    gd.addNumericField("Max Octave Size: ", float(dflt.get("max_oct", 1024)), 0, 7, "")
    gd.addNumericField("Feature Descriptor Size: ", float(dflt.get("fd_size", 12)), 1, 7, "")
    gd.addNumericField("Initial Sigma: ", float(dflt.get("sigma", 1.2)), 2, 7, "")  
    gd.addNumericField("Max Epsilon: ", float(dflt.get("max_eps", 15)), 1, 7, "")
    gd.addNumericField("Min Inlier Ratio: ", float(dflt.get("min_inlier", 0.05)), 3, 7, "")
    gd.addCheckbox("Use Shrinkage Constraint", ast.literal_eval(dflt.get("shrinkage", "False")))
    gd.addChoice("Feature extraction model", feat_model_strings,
                 feat_model_strings[int(dflt.get("feat_model", 1))]
                 )
    gd.addChoice("Registration model", reg_model_strings,
                 reg_model_strings[int(dflt.get("reg_model", 1))]
                 )
    
    # Background removal parameters dialog.
    gd.addPanel(Panel())
    gd.addMessage("BACKGROUND REMOVAL") 
    gd.addChoice("Subtraction method:", b_sub_strings,
                 b_sub_strings[int(dflt.get("b_sub", 0))]
                 )          
    gd.addNumericField("Rolling ball size: ", 
                       float(dflt.get("ballsize", 50)), 1, 7, "px"
                       )
    gd.addCheckbox("Create Background", ast.literal_eval(dflt.get("create_b", "False")))
    gd.addCheckbox("Light Background", ast.literal_eval(dflt.get("light_b", "False")))
    gd.addCheckbox("Use Parabaloid", ast.literal_eval(dflt.get("parab", "False")))
    gd.addCheckbox("Do Pre-smoothing", ast.literal_eval(dflt.get("smooth", "False")))
    gd.addCheckbox("Correct Corners", ast.literal_eval(dflt.get("corners", "False")))

    # Measumrent parameters dialog.
    gd.addPanel(Panel())
    gd.addMessage("MEASUREMENT PARAMETERS")
    gd.addNumericField("Max Cell Area", float(dflt.get("cell_max", 2200)), 0, 7, "px")
    gd.addNumericField("Min Cell Area", float(dflt.get("cell_min", 200)), 0, 7, "px")
    gd.addNumericField("Ratio Subtraction", float(dflt.get("subtr_ratio", 0.31)), 3, 7, "")

    # Plot parameters dialog.
    gd.addPanel(Panel())
    gd.addMessage("PLOT PARAMETERS")
    gd.addNumericField("Max y, d and aFRET", float(dflt.get("p_max", 0.65)), 2, 7, "")
    gd.addNumericField("Min y, d and aFRET", float(dflt.get("p_min", 0.0)), 2, 7, "")
    gd.addNumericField("Max y, norm. d and aFRET", float(dflt.get("p_max_n", 1.65)), 2, 7, "")
    gd.addNumericField("Min y, norm. d and aFRET", float(dflt.get("p_min_n", 0.5)), 2, 7, "")
    
    # Set location of dialog on screen.
    #gd.setLocation(0,1000)
    
    gd.showDialog()
    
    # Checks if cancel was pressed, kills script.
    if gd.wasCanceled() is True:
        sys.exit("Cancel was pressed, script terminated.")

    # Parameters dictionary.
    parameters = {"steps" : gd.getNextNumber(), 
                 "max_oct" : gd.getNextNumber(),
                 "fd_size" : gd.getNextNumber(),
                 "sigma" : gd.getNextNumber(),
                 "max_eps" : gd.getNextNumber(),
                 "min_inlier" : gd.getNextNumber(),
                 "shrinkage" : gd.getNextBoolean(),
                 "feat_model" : gd.getNextChoiceIndex(),
                 "reg_model" : gd.getNextChoiceIndex(),
                 "b_sub" : gd.getNextChoiceIndex(),
                 "ballsize" : gd.getNextNumber(),
                 "create_b" : gd.getNextBoolean(),
                 "light_b" : gd.getNextBoolean(),
                 "parab" : gd.getNextBoolean(),
                 "smooth" : gd.getNextBoolean(),
                 "corners" : gd.getNextBoolean(),
                 "cell_max" : gd.getNextNumber(),
                 "cell_min" : gd.getNextNumber(),
                 "subtr_ratio" : gd.getNextNumber(),
                 "p_max" : gd.getNextNumber(),
                 "p_min" : gd.getNextNumber(),
                 "p_max_n" : gd.getNextNumber(),
                 "p_min_n" : gd.getNextNumber()
                 }

    parameters = config_write(parameters)   

    return parameters