Exemple #1
0
def start_masking_menu():

    wlist = WindowManager.getImageTitles()
    gd = GenericDialog('Masking - Setup')
    gd.setCancelLabel('Exit')

    gd.addChoice('Create mask from', wlist, wlist[0])
    gd.addNumericField("Gaussian blur:", 0, 1)
    gd.addNumericField("Fixed threshold:", 0, 0)
    gd.addCheckbox('Use automatic thresholding', False)
    gd.addChoice('Method', ['Default', 'Huang', 'Otsu', 'Yen'], 'Default')

    gd.showDialog()

    if gd.wasCanceled():
        return False

    pdic = {}

    pdic['sel_win'] = gd.getNextChoice()
    pdic['sigma'] = gd.getNextNumber()
    pdic['threshold'] = gd.getNextNumber()
    pdic['use_auto'] = gd.getNextBoolean()
    pdic['thresh_method'] = gd.getNextChoice()

    return pdic
Exemple #2
0
def perform_manual_qc(imp, rois, important_channel=1):
    """given cell rois generated by automatic methods, allow user to delete/add/redraw as appropriate"""
    for ch in range(imp.getNChannels()):
        imp.setC(ch + 1)
        sat_frac = 0.99 if (ch + 1) == important_channel else 0.01
        IJ.run(imp, "Enhance Contrast", "saturated={}".format(sat_frac))

    imp.setC(important_channel)
    IJ.setTool("freehand")
    proceed = False
    roim = RoiManager()
    roim.runCommand("Show all with labels")
    for roi in rois:
        roim.addRoi(roi)
    auto_rois_only = rois
    while not proceed:
        dialog = NonBlockingGenericDialog("Perform manual segmentation")
        dialog.setOKLabel("Proceed to next image...")
        dialog.addMessage("Perform manual correction of segmentation: ")
        dialog.addMessage(
            "Draw around cells and add to the region of interest manager (Ctrl+T). "
        )
        dialog.addMessage("Delete and redraw cells as appropriate. ")
        dialog.addMessage(
            "Then press \"proceed to next image\" when all cells have been added. "
        )
        dialog.showDialog()
        if dialog.wasCanceled():
            print("Manual segmentation canceled")
            return auto_rois_only
        elif dialog.wasOKed():
            if roim.getCount() == 0:
                rois = []
                confirm_dialog = GenericDialog("Continue?")
                confirm_dialog.addMessage(
                    "No rois selected in this FOV. Are you sure you want to proceed?"
                )
                confirm_dialog.setOKLabel("Yes, proceed")
                confirm_dialog.setCancelLabel("No, not yet")
                confirm_dialog.showDialog()
                if confirm_dialog.wasOKed():
                    proceed = True
            else:
                rois = roim.getRoisAsArray()
                proceed = True
    roim.reset()
    roim.close()
    for ch in range(imp.getNChannels()):
        imp.setC(ch + 1)
        IJ.run(imp, "Enhance Contrast", "saturated={}".format(0.35))
    imp.setC(important_channel)
    return rois
def warning_dialog(message):
	"""show a warning dialog with a user-defined message"""
	dialog = GenericDialog("Warning!");
	dialog.setCancelLabel("Cancel analysis");
	if type(message) is list:
		for line in message:
			dialog.addMessage(line);
	else:
		dialog.addMessage(message);
	dialog.showDialog();
	if dialog.wasCanceled():
		raise KeyboardInterrupt("Run canceled");
	return;
Exemple #4
0
def get_image(info, default_path, used_files):
	"""handle getting image from file"""
	check_for_file_overlap_OK = False;
	while not check_for_file_overlap_OK:
		info.set_input_file_path(file_location_chooser(default_path));
		if info.get_input_file_path() in used_files:
			dlg = GenericDialog("Image already used...");
			dlg.addMessage("This image has already been used in this analysis run.  \n " + 
					"Continue with this image, or choose a new one?");
			dlg.setOKLabel("Continue");
			dlg.setCancelLabel("Choose again...");
			dlg.showDialog();
			check_for_file_overlap_OK = False if dlg.wasCanceled() else True;
		else:
			check_for_file_overlap_OK = True;
	import_opts, info = choose_series(info.get_input_file_path(), info)

	imps = bf.openImagePlus(import_opts);
	imp = imps[0];
	
	try:
		memory_usage = IJ.currentMemory()/IJ.maxMemory();
		print("memory usage = " +str(memory_usage));
		# arbitrary limit...
		if memory_usage > 0.95: 
			IJ.run(imp, "8-bit", "");
			print("WARNING - IMAGE CONVERTED TO 8 BIT TO CONSERVE MEMORY!");
		info.set_metadata_file_path(os.path.splitext(info.get_input_file_path())[0] + ".txt");
		metadata = import_iq3_metadata(info.get_metadata_file_path());
		IJ.run(imp, "Properties...", "channels=" + str(int(metadata['n_channels'])) + 
										" slices=" + str(int(metadata['z_pixels'])) + 
										" frames=1 unit=" + str(metadata['x_unit']) + 
										" pixel_width=" + str(metadata['x_physical_size']) + 
										" pixel_height=" + str(metadata['y_physical_size']) + 
										" voxel_depth=" + str(metadata['z_extent']/metadata['z_pixels']));
		info.set_xy_pixel_size_um(metadata['x_physical_size']);
		info.set_z_plane_spacing_um(metadata['z_extent']/metadata['z_pixels']);
		info = parse_info_from_filename(info);
	except e as Exception:
		print(e.message);
	finally:
		if imp is not None:
			imp.close();
	return imp, info;
from ij.gui import GenericDialog

import sys
from java.lang.System import getProperty

sys.path.append(getProperty("fiji.dir") + "/plugins/CMTK_Registration")

gd = GenericDialog('About CMTK')
gd.addMessage(
    'CMTK Registration suite is open source software released under GPLv3', )
gd.addMessage('Currently installed CMTK version: ' +
              cmtkgui.installed_version())
gd.addMessage('CMTK binary directory: ' + cmtkgui.bin_dir())
gd.setCancelLabel("CMTK Web Page")
gd.showDialog()
if gd.wasCanceled():
    from ij import IJ
    IJ.runPlugIn("ij.plugin.BrowserLauncher",
                 "http://www.nitrc.org/projects/cmtk/")
Exemple #6
0
from ij.gui import GenericDialog

import sys
from java.lang.System import getProperty
sys.path.append(getProperty("fiji.dir") + "/plugins/CMTK_Registration")

gd = GenericDialog('About CMTK')
gd.addMessage('CMTK Registration suite is open source software released under GPLv3',)
gd.addMessage('Currently installed CMTK version: '+cmtkgui.installed_version())
gd.addMessage('CMTK binary directory: '+cmtkgui.bin_dir())
gd.setCancelLabel("CMTK Web Page")
gd.showDialog()
if gd.wasCanceled():
	from ij import IJ
	IJ.runPlugIn("ij.plugin.BrowserLauncher", "http://www.nitrc.org/projects/cmtk/")