def Dialog(imp):
    dpi = 300
    # a4 width in inches
    defaultWidth = 11.69
    defaultHeight = defaultWidth / ratio
    defaultAspectRatio = 1.41

    if imp:
        gd = GenericDialogPlus("Cover Maker")
        gd.addMessage("Input Options")
        gd.addFileField("Select image database", "", 20)
        gd.addMessage("Cover Maker Options")
        gd.addNumericField("tile width", 12, 0)
        gd.addNumericField("tile height", 9, 0)

        gd.showDialog()

        if gd.wasCanceled():
            print "User canceled dialog!"
            return
        databasepath = gd.getNextString()
        tilewidth = gd.getNextNumber()
        tileheight = gd.getNextNumber()

        return databasepath, imp.getWidth(), imp.getHeight(), int(
            tilewidth), int(tileheight)
    else:
        IJ.showMessage("You should have at least one image open.")
def Dialog(imp):
	dpi = 300
	# a4 width in inches
	defaultWidth = 11.69
	defaultHeight = defaultWidth/ratio
	defaultAspectRatio = 1.41

	if imp:
		gd = GenericDialogPlus("Cover Maker")
		gd.addMessage("Input Options")
		gd.addFileField("Select image database", "", 20)
		gd.addMessage("Cover Maker Options")
		gd.addNumericField("tile width", 12, 0)
		gd.addNumericField("tile height", 9, 0)

		gd.showDialog()

		if gd.wasCanceled():
			print "User canceled dialog!"
			return
		databasepath = gd.getNextString()
		tilewidth = gd.getNextNumber()
		tileheight = gd.getNextNumber()

		print 'path:', databasepath
		return databasepath, imp.getWidth(), imp.getHeight(), int(tilewidth), int(tileheight)
	else:
		IJ.showMessage( "You should have at least one image open." )
Ejemplo n.º 3
0
def run():
    gd = GenericDialogPlus("ND2 Conversion Tool")
    gd.addMessage("This plugin uses BioFormats to convert ND2 images to JPEG for further processing in ImageJ.")
    gd.addDirectoryOrFileField("Input: ", "G:\\Subdir testing\\") #srcDir
    gd.addDirectoryOrFileField("Output: ", "G:\\Subdir testing\\") #dstDir
    gd.addStringField("File name contains: ", "") #nameContains
    gd.addCheckbox("Preserve directory structure?", True) #keepDirs
    gd.addCheckbox("Run in headless mode?", True) #anneBoleyn 
    gd.addCheckbox("Overwrite existing output files?", True)
    gd.showDialog()
    if gd.wasCanceled():
        return
    srcDir = gd.getNextString()
    dstDir = gd.getNextString()
    nameContains = gd.getNextString()
    keepDirectories = gd.getNextBoolean()
    anneBoleyn = gd.getNextBoolean()
    overOut = gd.getNextBoolean()
    IJ.run("Input/Output...", "jpeg=100")
    for root, directories, filenames in os.walk(srcDir):
        for filename in filenames:
            # Check for file extension
            if not filename.endswith(".nd2"):
                continue
            # Check for file name pattern
            if nameContains not in filename:
                continue
            process(srcDir, dstDir, nameContains, root, filename, keepDirectories, anneBoleyn, overOut)
def dialog(imp2, labelColorBarImp):
	gd = GenericDialogPlus("ROI labeller")
	categories=11

	#placeholder slider variables so the class can be initiated
	slider1=0
	slider2=0	
	slider3=0
	slider4=0
	test=previewLabelerAndListeners(imp2, slider1,slider2,slider3,slider4, gd)
	

	for i in range(1,categories):
		gd.addButton("label "+str(i), test)
		
	gd.addImage(labelColorBarImp)
	#imp7.close() - causes an error as image needed for the dialog
	gd.addButton("Set top",test)
	gd.addButton("Whole stack",test)
	gd.addButton("Set bottom", test)
	

	
	gd.addSlider("Top",1, imp2.getStackSize(), 1)
	gd.addSlider("Bottom",1, imp2.getStackSize(),imp2.getStackSize())
	gd.addSlider("Minimum ROI size", 0, 9999, 0, 1)
	gd.addSlider("Maximum ROI size", 1, 10000, 10000, 1)

	slider1=gd.getSliders().get(0)
	slider2=gd.getSliders().get(1)
	test.slider1=slider1
	test.slider2=slider2
	slider3=gd.getSliders().get(2)
	slider4=gd.getSliders().get(3)
	test.slider3=slider3
	test.slider4=slider4
	slider1.addAdjustmentListener(test)  
	slider2.addAdjustmentListener(test)
	slider3.addAdjustmentListener(test)  
	slider4.addAdjustmentListener(test)

	gd.addChoice("Apply labeling to:", ["(Sub)stack", "Slice"], "(Sub)stack")



	
	gd.setLayout(GridLayout(0,2))
	
	gd.setModal(False)
	buttons=gd.getButtons()

	gd.showDialog()


	while ((not gd.wasCanceled()) and not (gd.wasOKed())):
		Thread.sleep(50)	
	return test
Ejemplo n.º 5
0
def DialogGenerate(imageBaseDir, summary):
    dpi = 300
    defaultAspectRatio = 1.33
    defaultTileWidth = 15
    defaultOriginalWidth = 150
    defaultOriginalHeight = 113
    defaultTileHeight = round(defaultTileWidth / defaultAspectRatio)

    gd = GenericDialogPlus("Cover Maker")
    gd.addMessage("Prepare Image database")
    gd.addDirectoryField("Select base directory containing images",
                         imageBaseDir, 20)
    gd.addMessage(summary)
    gd.addNumericField("Aspect ratio", defaultAspectRatio, 2)
    gd.addNumericField("Original width", defaultOriginalWidth, 0)
    gd.addNumericField("Original height", defaultOriginalHeight, 0)
    gd.addNumericField("minimal tile width", defaultTileWidth, 0)
    gd.addNumericField("maximal tile width", defaultTileWidth, 0)
    gd.addNumericField("minimal tile height", defaultTileHeight, 0)
    gd.addNumericField("maximal tile height", defaultTileHeight, 0)

    fields = gd.getNumericFields()

    aspRatio = fields.get(0)
    minw = fields.get(3)
    maxw = fields.get(4)
    minh = fields.get(5)
    maxh = fields.get(6)

    # resolution and size listener
    textListener = RatioToDim(aspRatio, minw, maxw, minh, maxh)
    aspRatio.addTextListener(textListener)
    minw.addTextListener(textListener)
    maxw.addTextListener(textListener)

    gd.showDialog()

    if gd.wasCanceled():
        print "User canceled dialog!"
        return
    imageBaseDir = gd.getNextString()
    aspectRatio = gd.getNextNumber()
    majorWidth = gd.getNextNumber()
    majorHeight = gd.getNextNumber()
    mintilewidth = gd.getNextNumber()
    maxtilewidth = gd.getNextNumber()

    return int(mintilewidth), int(maxtilewidth), imageBaseDir, float(
        aspectRatio), int(majorWidth), int(majorHeight)
def optionsDialog():
    dialog = GenericDialogPlus("Automated Weka Percentages")
    dialog.addDirectoryField("Image Directory", "")
    dialog.addFileField("Training Model", "")
    dialog.addStringField("Output Subdirectory", "output", 20)
    dialog.addStringField("Probability Threshold", "0.75", 20)
    dialog.showDialog()

    # Check if canceled
    if dialog.wasCanceled(): return None

    textVals = [x.text for x in dialog.getStringFields()]
    #boolVals = [x.getState() for x in dialog.getCheckboxes()]

    return textVals
Ejemplo n.º 7
0
def optionsDialog():
    dialog = GenericDialogPlus("Fluorescent Cell Counting")
    dialog.addDirectoryField("Image Directory", "")
    dialog.addFileField("Training Model", "")
    dialog.addStringField("Output Subdirectory", "output", 20)
    dialog.addStringField("Probability Threshold", "0.67", 20)
    dialog.addStringField("Minimum Pixel Size", "2", 20)
    dialog.showDialog()

    # Check if canceled
    if dialog.wasCanceled(): return None

    textVals = [x.text for x in dialog.getStringFields()]

    return textVals
def openMainDialogBox():
    #od = OpenDialog("Selectionner un fichier")
    #folder = od.getDirectory()
    #IJ.log(folder);
    #filename = od.getFileName() #intérêt de récupérer le nom du fichier -> récupérer l'extension
    #extension = od.getFileName().split('.').pop() #Array.pop(). Pratique pour faire une fonction getExtension()
    #IJ.log(folder+filename)

    # Create an instance of GenericDialogPlus
    mainDialogBox = GenericDialogPlus("Restack Tiff deconvolved images from Huygens")
    mainDialogBox.addMessage("Ne fonctionnera correctement que si les noms des fichiers images de sortie de Huygens ont ete laisses intacts. Ne pas les modifier.")
    #mainDialogBox.addButton("Ouvrir image", imageSelectionListener())
    mainDialogBox.addMessage("------------------------------------------")
    mainDialogBox.addDirectoryField("Choisir un repertoire-cible", "None")
    mainDialogBox.addMessage("------------------------------------------")
    mainDialogBox.addDirectoryField("Choisir un repertoire pour deposer les piles d'images", "None")
    mainDialogBox.addMessage("------------------------------------------")

    #Select File Type
    choixType = ["1 fichier par canal (NOM_FICHIER_chXX.tif)", "1 fichier par canal + temps (NOM_FICHIER_tXX_chXX.tif)", "1 fichier par canal et par profondeur (NOM_FICHIER_zXX_chXX.tif)", "1 fichier par canal et par profondeur + temps (NOM_FICHIER_tXX_zXX_chXX.tif)"]
    selectionType = choixType[0]
    mainDialogBox.addChoice("Selectionner type de fichiers",choixType,selectionType)
    mainDialogBox.addMessage("------------------------------------------")

    choixDisplayMode = ["Color", "Greyscale", "Composite"]
    selectionDisplayModeDefaut = choixDisplayMode[0]
    mainDialogBox.addChoice("Color Display Mode",choixDisplayMode,selectionDisplayModeDefaut)
    mainDialogBox.addMessage("------------------------------------------")
    #Affichage de la boîte de dialogue
    mainDialogBox.showDialog();

    #Récupération choix
    folder = mainDialogBox.getNextString()
    save_folder = mainDialogBox.getNextString()
    vecteurChoix=mainDialogBox.getChoices()
    selectionTypeFichier = vecteurChoix[0]
    valeurSelectionTypeFichier = str(selectionTypeFichier.getSelectedItem())
    selectionDisplayMode = vecteurChoix[1]
    valeurSelectionDisplayMode = str(selectionDisplayMode.getSelectedItem())

    if mainDialogBox.wasCanceled() == True:
        print("Canceled, Values set to None")
        folder = None
        save_folder = None
        valeurSelectionTypeFichier = None
        valeurSelectionDisplayMode = None

    return folder, save_folder, valeurSelectionTypeFichier, valeurSelectionDisplayMode
Ejemplo n.º 9
0
def optionsDialog():
    dialog = GenericDialogPlus("Cilia Sizes")
    dialog.addDirectoryField("Image Directory", DEFAULT_DIR)
    dialog.addFileField("Training Model", DEFAULT_TRAIN)
    dialog.addStringField("Output Subdirectory", "output", 20)
    dialog.addStringField("Confocal Channel", "1", 20)
    dialog.addStringField("Probability Threshold", "0.67", 20)
    dialog.addStringField("Minimum Pixel Size", "2", 20)
    dialog.showDialog()

    # Check if canceled
    if dialog.wasCanceled(): return None

    textVals = [x.text for x in dialog.getStringFields()]

    return textVals
def DialogAnalyze():
	dpi = 300
	defaultAspectRatio = 1.41

	gd = GenericDialogPlus("Cover Maker")
	gd.addMessage("Prepare Image database")
	gd.addDirectoryField("Select base directory containing images", "", 20)

	gd.showDialog()

	if gd.wasCanceled():
		print "User canceled dialog!"
		return
	imageBaseDir = gd.getNextString()

	return imageBaseDir
Ejemplo n.º 11
0
def DialogAnalyze():
    dpi = 300
    defaultAspectRatio = 1.41

    gd = GenericDialogPlus("Cover Maker")
    gd.addMessage("Prepare Image database")
    gd.addDirectoryField("Select base directory containing images", "", 20)

    gd.showDialog()

    if gd.wasCanceled():
        print "User canceled dialog!"
        return
    imageBaseDir = gd.getNextString()

    return imageBaseDir
def DialogGenerate(imageBaseDir, summary):
	dpi = 300
	defaultAspectRatio = 1.33
	defaultTileWidth = 15
	defaultOriginalWidth = 150
	defaultOriginalHeight = 113
	defaultTileHeight = round(defaultTileWidth/defaultAspectRatio)

	gd = GenericDialogPlus("Cover Maker")
	gd.addMessage("Prepare Image database")
	gd.addDirectoryField("Select base directory containing images", imageBaseDir, 20)
	gd.addMessage(summary)
	gd.addNumericField("Aspect ratio", defaultAspectRatio, 2)
	gd.addNumericField("Original width", defaultOriginalWidth, 0)
	gd.addNumericField("Original height", defaultOriginalHeight, 0)
	gd.addNumericField("minimal tile width", defaultTileWidth, 0)
	gd.addNumericField("maximal tile width", defaultTileWidth, 0)
	gd.addNumericField("minimal tile height", defaultTileHeight, 0)
	gd.addNumericField("maximal tile height", defaultTileHeight, 0)

	fields = gd.getNumericFields()

	aspRatio = fields.get(0)
	minw = fields.get(3)
	maxw = fields.get(4)
	minh = fields.get(5)
	maxh = fields.get(6)

	# resolution and size listener
	textListener = RatioToDim(aspRatio, minw, maxw, minh, maxh)
	aspRatio.addTextListener(textListener)
	minw.addTextListener(textListener)
	maxw.addTextListener(textListener)

	gd.showDialog()

	if gd.wasCanceled():
		print "User canceled dialog!"
		return
	imageBaseDir = gd.getNextString()
	aspectRatio = gd.getNextNumber()
	majorWidth = gd.getNextNumber()
	majorHeight = gd.getNextNumber()
	mintilewidth = gd.getNextNumber()
	maxtilewidth = gd.getNextNumber()

	return int(mintilewidth), int(maxtilewidth), imageBaseDir, float(aspectRatio), int(majorWidth), int(majorHeight)
Ejemplo n.º 13
0
def get_parameters(p):
  gd = GenericDialogPlus("Please enter parameters")

  for k in p['expose_to_gui']['value']:
    if p[k]['type'] == 'boolean':
      gd.addCheckbox(k, p[k]['value'])
    elif p[k]['type'] == 'folder':
      gd.addDirectoryField(k, p[k]['value'], 100)	
    elif p[k]['type'] == 'file':
      gd.addFileField(k, p[k]['value'], 100)	
    elif p[k]['type'] == 'string':
      if p[k]['choices']:
        gd.addChoice(k, p[k]['choices'], p[k]['value'])	
      else:
        gd.addStringField(k, p[k]['value'])	 
    elif p[k]['type'] == 'int':
      if p[k]['choices']:
        gd.addChoice(k, p[k]['choices'], p[k]['value'])	
      else:
        gd.addNumericField(k, p[k]['value'], 0)	 
    elif p[k]['type'] == 'float':
      gd.addNumericField(k, p[k]['value'], 2)
  
  gd.showDialog()
  if gd.wasCanceled():
    return

  for k in p['expose_to_gui']['value']:
    if p[k]['type'] == 'boolean':
      p[k]['value'] = gd.getNextBoolean()
    elif p[k]['type'] == 'folder' or p[k]['type'] == 'file':
      p[k]['value'] = gd.getNextString()
    elif p[k]['type'] == 'string':
      if p[k]['choices']:
        p[k]['value'] = gd.getNextChoice()	
      else:
        p[k]['value'] = gd.getNextString()	 
    elif p[k]['type'] == 'int':
      if p[k]['choices']:
        p[k]['value'] = int(gd.getNextChoice())	
      else:
        p[k]['value'] = int(gd.getNextNumber()) 
    elif p[k]['type'] == 'float':
        p[k]['value'] = gd.getNextNumber()
    
  return p
def SaveDialog(imp):
    dpi = 300
    # a4 width in inches
    defaultWidth = 11.69
    defaultHeight = defaultWidth / ratio
    defaultAspectRatio = 1.41

    if imp:
        gd = GenericDialogPlus("Cover Maker")
        gd.addMessage("Saving options")
        gd.addNumericField("resolution (dpi)", dpi, 0)
        gd.addNumericField("width (pixels)", defaultWidth * dpi, 0)
        gd.addNumericField("height (pixels)", defaultHeight * dpi, 0)
        gd.addNumericField("width (inches)", defaultWidth, 2)
        gd.addNumericField("height (inches)", defaultHeight, 2)
        gd.addFileField("Select Originals database", "", 20)

        fields = gd.getNumericFields()

        resField = fields.get(0)
        widthPixels = fields.get(1)
        heightPixels = fields.get(2)
        widthInches = fields.get(3)
        heightInches = fields.get(4)

        # resolution and size listener
        textListener = ResolutionListener(resField, widthPixels, heightPixels,
                                          widthInches, heightInches)
        resField.addTextListener(textListener)
        widthInches.addTextListener(textListener)
        heightInches.addTextListener(textListener)

        gd.showDialog()

        if gd.wasCanceled():
            print "User canceled dialog!"
            return

        newres = gd.getNextNumber()
        newwidth = gd.getNextNumber()
        newheight = gd.getNextNumber()
        originalspath = gd.getNextString()

        return int(newwidth), int(newheight), newres, originalspath
    else:
        IJ.showMessage("You should have at least one image open.")
Ejemplo n.º 15
0
def SaveDialog(imp):
	dpi = 300
	# a4 width in inches
	defaultWidth = 11.69
	defaultHeight = defaultWidth/ratio
	defaultAspectRatio = 1.41

	if imp:
		gd = GenericDialogPlus("Cover Maker")
		gd.addMessage("Saving options")
		gd.addNumericField("resolution (dpi)", dpi, 0)
		gd.addNumericField("width (pixels)", defaultWidth*dpi, 0)
		gd.addNumericField("height (pixels)", defaultHeight*dpi, 0)
		gd.addNumericField("width (inches)", defaultWidth, 2)
		gd.addNumericField("height (inches)", defaultHeight, 2)
		gd.addFileField("Select Originals database", "", 20)

		fields = gd.getNumericFields()

		resField = fields.get(0)
		widthPixels = fields.get(1)
		heightPixels = fields.get(2)
		widthInches = fields.get(3)
		heightInches = fields.get(4)

		# resolution and size listener
		textListener = ResolutionListener(resField, widthPixels, heightPixels, widthInches, heightInches)
		resField.addTextListener(textListener)
		widthInches.addTextListener(textListener)
		heightInches.addTextListener(textListener)

		gd.showDialog()

		if gd.wasCanceled():
			print "User canceled dialog!"
			return

		newres = gd.getNextNumber()
		newwidth = gd.getNextNumber()
		newheight = gd.getNextNumber()
		originalspath = gd.getNextString()

		return int(newwidth), int(newheight), newres, originalspath
	else:
		IJ.showMessage( "You should have at least one image open." )
Ejemplo n.º 16
0
    def getSettings(self):
        gd = GenericDialogPlus("Settings")
        gd.addNumericField("Distance in pixel", 600, 0)
        gd.addNumericField("Distance in cm", 2.54, 2)
        gd.addNumericField("Min. size (cm^2)", 0.5, 2)
        gd.addDirectoryField("Directory", IJ.getDirectory("home"))
        gd.addStringField("File extension", "*.jpg", 8)
        gd.showDialog()

        if gd.wasCanceled():
            sys.exit()
        else:
            distPixel = gd.getNextNumber()
            distCm = gd.getNextNumber()
            minSize = gd.getNextNumber() * (distPixel / distCm) ** 2
            imageDir = gd.getNextString()
            ext = gd.getNextString()

        return (distPixel, distCm, minSize, imageDir, ext)
Ejemplo n.º 17
0
def make_dialog():

	parameters = {}

	gd = GenericDialogPlus("Grid Stitch SDC Data")
	gd.addMessage(  "Warning!\n"\
					"In order to display a fused image upon completion of stitching\n"\
					"please disable Fiji's ImageJ2 options. When enabled an ImageJ\n"\
					"exception will be displayed upon completion. This exception can\n"
					"be safely ignored.")
	gd.addMessage(  "Information\n"\
					"This plugin is a wrapper around the Fiji 'Grid Stitching' plugin.\n"\
					"It allows tiles generated in SlideBook to be directly stitched by\n"\
					"by first writing out the individual tiles, executing the 'Grid Stitching'\n"\
					"plugin and writing the fused image to disk.")
	gd.addMessage("")										
	gd.addNumericField("grid_size_x", 3, 0)
	gd.addNumericField("grid_size_y", 3, 0)
	gd.addCheckbox("Select channel",False)
	gd.addNumericField("", 0, 0)		
	gd.addCheckbox("Are the Z slices separate files?",False)
	gd.addDirectoryField("directory", "", 50)
	
	gd.showDialog()
	if (gd.wasCanceled()): return
		
	parameters['gridX'] = int(math.ceil(gd.getNextNumber()))
	parameters['gridY'] = int(math.ceil(gd.getNextNumber()))
	parameters['select_channel'] = gd.getNextBoolean()
	parameters['channel'] = None
	if parameters['select_channel']:
		parameters['channel'] = int(gd.getNextNumber())
	parameters['separate_z'] = gd.getNextBoolean()
	directory = str(gd.getNextString())	
	if directory is None:
	# User canceled the dialog
		return None
	else:
		directory = os.path.abspath(directory)
		parameters['directory'] = directory + os.path.sep

	return parameters
def get_parameters(p):
  gd = GenericDialogPlus("Please enter parameters")

  for k in p['expose_to_gui']['value']:
    if p[k]['type'] == 'folder':
      gd.addDirectoryField(k, p[k]['value'], 100)	
    if p[k]['type'] == 'file':
      gd.addFileField(k, p[k]['value'], 100)	
    elif p[k]['type'] == 'string':
      if p[k]['choices']:
        gd.addChoice(k, p[k]['choices'], p[k]['value'])	
      else:
        gd.addStringField(k, p[k]['value'], 50)	 
    elif p[k]['type'] == 'int':
      if p[k]['choices']:
        gd.addChoice(k, p[k]['choices'], p[k]['value'])	
      else:
        gd.addNumericField(k, p[k]['value'], 0)	 
    elif p[k]['type'] == 'float':
      gd.addNumericField(k, p[k]['value'], 2)
  
  gd.showDialog()
  if gd.wasCanceled():
    return(0)

  for k in p['expose_to_gui']['value']:
    if p[k]['type'] == 'folder' or p[k]['type'] == 'file':
      p[k]['value'] = gd.getNextString()
    elif p[k]['type'] == 'string':
      if p[k]['choices']:
        p[k]['value'] = gd.getNextChoice()	
      else:
        p[k]['value'] = gd.getNextString()	 
    elif p[k]['type'] == 'int':
      if p[k]['choices']:
        p[k]['value'] = int(gd.getNextChoice())	
      else:
        p[k]['value'] = int(gd.getNextNumber()) 
    elif p[k]['type'] == 'float':
        p[k]['value'] = gd.getNextNumber()
    
  return(p)
Ejemplo n.º 19
0
def optionsDialog():
	dialog = GenericDialogPlus("Automated Size Analysis")
	dialog.addDirectoryField("Image Directory", "")
	dialog.addStringField("Output Subdirectory", "output", 20)
	dialog.addStringField("Minimum Pixel Size", "50000", 20)
	dialog.addStringField("Minimum Roundness", "0.4", 20)
	dialog.addStringField("Gaussian Blur", "6", 20)
	dialog.addStringField("Rotation Steps", "3", 20)
        dialog.addStringField("Thresholds", ",".join(THRESHOLDS), 20)
	dialog.addCheckbox("Rotate Images", True)
	dialog.addCheckbox("Multiple Thresholds", True)
	dialog.showDialog()

	# Check if canceled
	if dialog.wasCanceled(): return None

	textVals = [x.text for x in dialog.getStringFields()]
	boolVals = [x.getState() for x in dialog.getCheckboxes()]

	return textVals + boolVals
def selectionDialog(categories,labelColorBarImp):
	gd = GenericDialogPlus("ROI labeller -image picking")
	imps = WM.getImageTitles()
	nonimages=WM.getNonImageTitles()
	
	gd.addChoice("Image to quantify", imps, imps[0])
	try:
		gd.addChoice("FRETENTATOR results table", nonimages, nonimages[0])
		fail=0
	except:
		gd.addMessage("No results table open")
		fail=1
	gd.addImage(labelColorBarImp)
	for i in range(categories):
		gd.addStringField("Label "+str(i) +" name:", "Label "+str(i))

	gd.addChoice("Quantify an open image or add labels to open results table?", ["Image", "Results table"], "Results table")
	
	#quantImp= IJ.getImage(gd.getNextChoice())
	
	
	gd.setModal(False)
	gd.showDialog()
	while ((not gd.wasCanceled()) and not (gd.wasOKed())):
		Thread.sleep(50)


	names=dict()
	
	for i in range(categories):
		names[i]=str(gd.getNextString())
	imageName=gd.getNextChoice()
	if fail==0:	
		resultsName=gd.getNextChoice()
		imageOrTable=gd.getNextChoice()
	else:
		imageOrTable="Image"
		resultsName=0
	return names, imageName, resultsName, imageOrTable
Ejemplo n.º 21
0
    outsuffixf = gd.getStringFields().get(3)

    gd.addStringField("(Further) Registration Params", "", 50)
    regparamf = gd.getStringFields().get(4)
    gd.addStringField("Additional Arguments to munger.pl", "", 50)

    regrootf.addTextListener(RegRootListener())
    imgdirf.addTextListener(ImageDirListener())
    outsuffixf.addTextListener(OuputSuffixListener())
    choicef.addItemListener(RegParamListener())
    # used for errors etc
    gd.addMessage(
        "Start by choosing a registration directory or images directory!")
    statusf = gd.getMessage()
    gd.showDialog()
    if gd.wasCanceled():
        sys.exit("User cancelled!")
    # Process Dialog Choices
    rootDir = gd.getNextString()
    os.chdir(rootDir)
    refBrain = gd.getNextString()
    image = gd.getNextString()
    image = relpath(image, rootDir)
    print refBrain
    refBrain = relpath(refBrain, rootDir)
    print refBrain

    affine = gd.getNextBoolean()
    ch01 = gd.getNextBoolean()
    warp = gd.getNextBoolean()
    ch02 = gd.getNextBoolean()
def previewDialog(imp):
    gd = GenericDialogPlus("Nuclear segmentation and quantification v1.01")

    #create a list of the channels in the provided imagePlus
    types = []
    for i in xrange(1, imp.getNChannels() + 1):
        types.append(str(i))

    #user can pick which channel to base the segmentation on
    gd.addChoice("Channel number to use for segmentation", types, types[0])
    gd.addChoice("Channel to quantify", types, types[0])
    methods = [
        "Otsu", "Default", "Huang", "Intermodes", "IsoData", "IJ_IsoData",
        "Li", "MaxEntropy", "Mean", "MinError", "Minimum", "Moments",
        "Percentile", "RenyiEntropy", "Shanbhag", "Triangle", "Yen"
    ]
    gd.addChoice("Autosegmentation method", methods, methods[0])
    intensities = ["254", "4094", "65534"]
    gd.addChoice("Max Intensity", intensities, intensities[-1])
    gd.addSlider("Small DoG sigma", 0.5, 10, 1, 0.1)
    gd.addSlider("Large DoG sigma", 0.5, 20, 5, 0.1)
    gd.addCheckbox("TopHat background subtraction? (Slower, but better) ",
                   True)
    gd.addSlider("TopHat sigma", 5, 20, 8, 0.1)
    gd.setModal(False)
    gd.addCheckbox("Manually set threshold? ", False)
    gd.addSlider("Manual threshold", 10, 65534, 2000, 1)

    gd.hideCancelButton()
    gd.showDialog()

    cal = imp.getCalibration()
    pixelAspect = (cal.pixelDepth / cal.pixelWidth)

    originalTitle = imp1.getTitle()

    choices = gd.getChoices()
    print choices
    sliders = gd.getSliders()
    checkboxes = gd.getCheckboxes()
    segmentChannel = int(choices.get(0).getSelectedItem())
    quantChannel = int(choices.get(1).getSelectedItem())
    thresholdMethod = choices.get(2).getSelectedItem()
    maxIntensity = int(choices.get(3).getSelectedItem())
    gaussianSigma = sliders.get(0).getValue() / 10.0
    largeDoGSigma = gd.sliders.get(1).getValue() / 10.0
    topHat = gd.checkboxes.get(0).getState()
    topHatSigma = gd.sliders.get(2).getValue() / 10.0

    manualSegment = gd.checkboxes.get(1).getState()
    manualThreshold = gd.sliders.get(3).getValue()

    segmentChannelOld = segmentChannel
    thresholdMethodOld = thresholdMethod
    maxIntensityOld = maxIntensity
    gaussianSigmaOld = gaussianSigma
    largeDoGSigmaOld = largeDoGSigma
    topHatOld = topHat
    topHatSigmaOld = topHatSigma
    manualSegmentOld = manualSegment
    manualThresholdOld = manualThreshold

    clij2.clear()

    segmentImp = extractChannel(imp1, segmentChannel, 0)

    try:
        gfx1 = clij2.push(segmentImp)
        gfx2 = clij2.create(gfx1)
        gfx3 = clij2.create(gfx1)
        gfx4 = clij2.create(gfx1)
        gfx5 = clij2.create(gfx1)
        gfx7 = clij2.create([imp.getWidth(), imp.getHeight()])
    except:
        try:

            Thread.sleep(500)
            IJ.log(
                "Succeeded to sending to graphics card on the second time...")
            gfx1 = clij2.push(segmentImp)
            gfx2 = clij2.create(gfx1)
            gfx3 = clij2.create(gfx1)
            gfx4 = clij2.create(gfx1)
            gfx5 = clij2.create(gfx1)
            gfx7 = clij2.create([imp.getWidth(), imp.getHeight()])
        except:
            errorDialog(
                """Could not send image to graphics card, it may be too large!
		
			Easy solutions: Try	processing as 8-bit, cropping or scaling the image, or
			select a different CLIJ2 GPU.

			This issue is often intermittent, so trying again may also work! 

			See the "Big Images on x graphics cards' notes at:
			https://clij2.github.io/clij2-docs/troubleshooting for more solutions
			
			""" + str(clij2.reportMemory()))

    gfx1, gfx2, gfx3, gfx4, gfx5 = segment(gfx1, gfx2, gfx3, gfx4, gfx5,
                                           gaussianSigma, thresholdMethod,
                                           maxIntensity, largeDoGSigma,
                                           pixelAspect, originalTitle, topHat,
                                           topHatSigma, manualSegment,
                                           manualThreshold)
    clij2.maximumZProjection(gfx5, gfx7)

    labelPrevImp = clij2.pull(gfx7)
    IJ.setMinAndMax(labelPrevImp, 0, clij2.getMaximumOfAllPixels(gfx7))
    labelPrevImp.setTitle("Preview segmentation")
    labelPrevImp.show()

    IJ.run("glasbey_inverted")

    while ((not gd.wasCanceled()) and not (gd.wasOKed())):

        segmentChannel = int(choices.get(0).getSelectedItem())
        quantChannel = int(choices.get(1).getSelectedItem())
        thresholdMethod = choices.get(2).getSelectedItem()
        maxIntensity = int(choices.get(3).getSelectedItem())
        gaussianSigma = sliders.get(0).getValue() / 10.0
        largeDoGSigma = gd.sliders.get(1).getValue() / 10.0
        topHat = gd.checkboxes.get(0).getState()
        topHatSigma = gd.sliders.get(2).getValue() / 10.0

        manualSegment = gd.checkboxes.get(1).getState()
        manualThreshold = gd.sliders.get(3).getValue()

        if (segmentChannelOld != segmentChannel
                or thresholdMethodOld != thresholdMethod
                or maxIntensityOld != maxIntensity
                or gaussianSigmaOld != gaussianSigma
                or largeDoGSigmaOld != largeDoGSigma or topHatOld != topHat
                or topHatSigmaOld != topHatSigma
                or manualSegmentOld != manualSegment
                or manualThresholdOld != manualThreshold):

            if segmentChannelOld != segmentChannel:
                clij2.clear()
                segmentImp = extractChannel(imp1, segmentChannel, 0)
                gfx1 = clij2.push(segmentImp)
                gfx2 = clij2.create(gfx1)
                gfx3 = clij2.create(gfx1)
                gfx4 = clij2.create(gfx1)
                gfx5 = clij2.create(gfx1)
                gfx7 = clij2.create([imp.getWidth(), imp.getHeight()])
            gfx1, gfx2, gfx3, gfx4, gfx5 = segment(
                gfx1, gfx2, gfx3, gfx4, gfx5, gaussianSigma, thresholdMethod,
                maxIntensity, largeDoGSigma, pixelAspect, originalTitle,
                topHat, topHatSigma, manualSegment, manualThreshold)
            clij2.maximumZProjection(gfx5, gfx7)
            labelPrevImp.close()
            labelPrevImp = clij2.pull(gfx7)
            IJ.setMinAndMax(labelPrevImp, 0, clij2.getMaximumOfAllPixels(gfx7))
            labelPrevImp.setTitle("Preview segmentation")
            labelPrevImp.show()

            IJ.run("glasbey_inverted")

        segmentChannelOld = segmentChannel
        thresholdMethodOld = thresholdMethod
        maxIntensityOld = maxIntensity
        gaussianSigmaOld = gaussianSigma
        largeDoGSigmaOld = largeDoGSigma
        topHatOld = topHat
        topHatSigmaOld = topHatSigma

        manualSegmentOld = manualSegment
        manualThresholdOld = manualThreshold

        Thread.sleep(200)
    labelPrevImp.close()

    return segmentChannel, quantChannel, thresholdMethod, maxIntensity, gaussianSigma, largeDoGSigma, topHat, topHatSigma, manualSegment, manualThreshold
Ejemplo n.º 23
0
def previewDialog(imp):
	gd = GenericDialogPlus("FRETENATOR")

	#create a list of the channels in the provided imagePlus
	types = []
	for i in xrange(1, imp.getNChannels()+1):
		types.append(str(i))
	gd.addMessage("""Rowe, J. H, Rizza, A., Jones A. M. (2022) Quantifying phytohormones
	in vivo with FRET biosensors and the FRETENATOR analysis toolset
	Methods in Molecular Biology
	Rowe, JH., Grangé-Guermente, M., Exposito-Rodriguez, M.,Wimalasekera, R., Lenz, M.,
	Shetty, K., Cutler, S., Jones, AM., Next-generation ABACUS biosensors reveal cellular
	ABA dynamics driving root growth at low aerial humidity
	""")
	#user can pick which channel to base the segmentation on
	if len(types)>2:
		gd.addChoice("Channel number to use for segmentation", types, types[2])
		gd.addChoice("Channel number to use for donor", types, types[0])
		gd.addChoice("Channel number to use for acceptor (FRET)", types, types[1])
		gd.addChoice("Channel number to use for acceptor", types, types[2])
		#print('YAY')
	else:
		gd.addChoice("Channel number to use for segmentation", types, types[-1])
		gd.addChoice("Channel number to use for donor", types, types[0])
		gd.addChoice("Channel number to use for acceptor (FRET)", types, types[-2])
		gd.addChoice("Channel number to use for acceptor", types, types[-1])
	
	methods=["Otsu","Default", "Huang", "Intermodes", "IsoData", "IJ_IsoData", "Li", "MaxEntropy", "Mean", "MinError", "Minimum", "Moments", "Percentile", "RenyiEntropy", "Shanbhag", "Triangle", "Yen"]
	gd.addChoice("Autosegmentation method", methods, methods[0])
	intensities=["254", "4094", "65534"]
	gd.addChoice("Max Intensity", intensities, intensities[-1])
	gd.addSlider("Small DoG sigma", 0.5, 10, 0.8, 0.1)
	gd.addSlider("Large DoG sigma", 0.5, 20, 4 ,0.1)
	gd.addCheckbox("TopHat background subtraction? (Slower, but better) ", False)
	gd.addSlider("TopHat sigma", 5, 20, 8 ,0.1)
	gd.setModal(False)
	gd.addCheckbox("Manually set threshold? ", False)
	gd.addSlider("Manual threshold", 10, 65534, 2000, 1)
	dilationOptions=["0", "1", "2","3", "4", "5", "6"]
	gd.addChoice("Dilation?", dilationOptions, "0")
	gd.addCheckbox("Size exclusion of ROI? ", False)
	gd.addSlider("Minimum ROI size", 0, 9999, 20, 1)
	gd.addSlider("Maximum ROI size", 1, 10000, 10000, 1)
	gd.addCheckbox("Create nearest point projection with outlines (SLOW)? ", True)
	gd.addCheckbox("Watershed object splitting? ", True)
	gd.showDialog()

		
	cal = imp.getCalibration()
	pixelAspect=(cal.pixelDepth/cal.pixelWidth)
	
	originalTitle=imp1.getTitle()
	
	choices=gd.getChoices()
	sliders=gd.getSliders()
	checkboxes=gd.getCheckboxes()		
	segmentChannel=int(choices.get(0).getSelectedItem())
	donorChannel=int(choices.get(1).getSelectedItem())
	acceptorChannel=int(choices.get(2).getSelectedItem())
	acceptorChannel2=int(choices.get(3).getSelectedItem())
	thresholdMethod=choices.get(4).getSelectedItem()
	maxIntensity=int(choices.get(5).getSelectedItem())
	gaussianSigma=sliders.get(0).getValue()/10.0
	largeDoGSigma = gd.sliders.get(1).getValue()/10.0
	topHat=gd.checkboxes.get(0).getState()
	topHatSigma=gd.sliders.get(2).getValue()/10.0
	
	manualSegment = gd.checkboxes.get(1).getState()
	manualThreshold=gd.sliders.get(3).getValue()
	dilation=int(choices.get(6).getSelectedItem())
	sizeExclude=gd.checkboxes.get(2).getState()
	minSize = gd.sliders.get(4).getValue()
	maxSize = gd.sliders.get(5).getValue()
	watershed = gd.checkboxes.get(4).getState()
	#print dir(gd.sliders.get(5))
	#print maxSize
	
	segmentChannelOld=segmentChannel
	thresholdMethodOld=thresholdMethod
	maxIntensityOld=maxIntensity
	gaussianSigmaOld=gaussianSigma
	largeDoGSigmaOld= largeDoGSigma
	topHatOld=topHat
	topHatSigmaOld=topHatSigma
	manualSegmentOld= manualSegment
	manualThresholdOld=manualThreshold
	dilationOld=dilation
	sizeExcludeOld=sizeExclude
	minSizeOld=minSize
	maxSizeOld=maxSize
	watershedOld=watershed
	clij2.clear()
	
	segmentImp=extractChannel(imp1, segmentChannel, 0)

	try:
		gfx1=clij2.push(segmentImp)
		gfx2=clij2.create(gfx1)
		gfx3=clij2.create(gfx1)
		gfx4=clij2.create(gfx1)
		gfx5=clij2.create(gfx1)
		gfx7=clij2.create([imp.getWidth(), imp.getHeight()])
	except:	
		try:
		
			Thread.sleep(500)
			print("Succeeded to sending to graphics card on the second time...")
			gfx1=clij2.push(segmentImp)
			gfx2=clij2.create(gfx1)
			gfx3=clij2.create(gfx1)
			gfx4=clij2.create(gfx1)
			gfx5=clij2.create(gfx1)
			gfx7=clij2.create([imp.getWidth(), imp.getHeight()])
		except:
			errorDialog("""Could not send image to graphics card, it may be too large!
		
			Easy solutions: Try	processing as 8-bit, cropping or scaling the image, or
			select a different CLIJ2 GPU.

			This issue is often intermittent, so trying again may also work! 

			See the "Big Images on x graphics cards' notes at:
			https://clij2.github.io/clij2-docs/troubleshooting for more solutions
			
			"""	+ str(clij2.reportMemory()) )


	gfx1,gfx2,gfx3,gfx4,gfx5 = segment(gfx1,gfx2,gfx3,gfx4,gfx5, gaussianSigma, thresholdMethod,maxIntensity, largeDoGSigma, pixelAspect, originalTitle, topHat, topHatSigma , manualSegment, manualThreshold, dilation,sizeExclude, minSize, maxSize, watershed)
	clij2.maximumZProjection(gfx5, gfx7)

	labelPrevImp= clij2.pull(gfx7)
	IJ.setMinAndMax(labelPrevImp, 0,clij2.getMaximumOfAllPixels(gfx7))
	labelPrevImp.setTitle("Preview segmentation")
	labelPrevImp.show()
	
	IJ.run("glasbey_inverted")
	
	while ((not gd.wasCanceled()) and not (gd.wasOKed())):
		

		segmentChannel=int(choices.get(0).getSelectedItem())
		donorChannel=int(choices.get(1).getSelectedItem())
		acceptorChannel=int(choices.get(2).getSelectedItem())
		acceptorChannel2=int(choices.get(3).getSelectedItem())
		thresholdMethod=choices.get(4).getSelectedItem()
		maxIntensity=int(choices.get(5).getSelectedItem())
		gaussianSigma=sliders.get(0).getValue()/10.0
		largeDoGSigma = gd.sliders.get(1).getValue()/10.0
		topHat=gd.checkboxes.get(0).getState()
		topHatSigma=gd.sliders.get(2).getValue()/10.0

		manualSegment = gd.checkboxes.get(1).getState()
		manualThreshold = gd.sliders.get(3).getValue()
		
		dilation=int(choices.get(6).getSelectedItem())
		
		sizeExclude=gd.checkboxes.get(2).getState()
		minSize = gd.sliders.get(4).getValue()
		maxSize = gd.sliders.get(5).getValue()
		watershed = gd.checkboxes.get(4).getState()
			
	
		if (segmentChannelOld !=segmentChannel or
		thresholdMethodOld !=thresholdMethod or
		maxIntensityOld !=maxIntensity or
		gaussianSigmaOld !=gaussianSigma or
		largeDoGSigmaOld != largeDoGSigma or
		topHatOld !=topHat or
		topHatSigmaOld !=topHatSigma or
		manualSegmentOld != manualSegment or
		manualThresholdOld !=manualThreshold or
		dilation != dilationOld or
		sizeExcludeOld!=sizeExclude or
		minSizeOld!=minSize or
		maxSizeOld!=maxSize or
		watershedOld!=watershed
		):
			if minSizeOld!=minSize:
				if minSize>=maxSize:
					maxSize=minSize+1
					gd.sliders.get(5).setValue(maxSize)
			if maxSizeOld!=maxSize:
				if minSize>=maxSize:
					minSize=maxSize-1
					gd.sliders.get(4).setValue(minSize)
			if segmentChannelOld!=segmentChannel:
					clij2.clear()
					segmentImp=extractChannel(imp1, segmentChannel, 0)
					gfx1=clij2.push(segmentImp)
					gfx2=clij2.create(gfx1)
					gfx3=clij2.create(gfx1)
					gfx4=clij2.create(gfx1)
					gfx5=clij2.create(gfx1)
					gfx7=clij2.create([imp.getWidth(), imp.getHeight()])
			gfx1,gfx2,gfx3,gfx4,gfx5 = segment(gfx1,gfx2,gfx3,gfx4,gfx5, gaussianSigma, thresholdMethod,maxIntensity, largeDoGSigma, pixelAspect, originalTitle, topHat,topHatSigma, manualSegment, manualThreshold, dilation,sizeExclude, minSize, maxSize, watershed)
			clij2.maximumZProjection(gfx5, gfx7)
			labelPrevImp.close()
			labelPrevImp= clij2.pull(gfx7)
			IJ.setMinAndMax(labelPrevImp, 0,clij2.getMaximumOfAllPixels(gfx7))
			labelPrevImp.setTitle("Preview segmentation")
			labelPrevImp.show()
			
			IJ.run("glasbey_inverted")
		
		segmentChannelOld=segmentChannel
		thresholdMethodOld=thresholdMethod
		maxIntensityOld=maxIntensity
		gaussianSigmaOld=gaussianSigma
		largeDoGSigmaOld = largeDoGSigma
		topHatOld=topHat
		topHatSigmaOld=topHatSigma
		manualSegmentOld= manualSegment
		manualThresholdOld=manualThreshold
		dilationOld=dilation
		sizeExcludeOld=sizeExclude
		minSizeOld=minSize
		maxSizeOld=maxSize
		watershedOld=watershed
		Thread.sleep(200)
	labelPrevImp.close()
	makeNearProj = gd.checkboxes.get(3).getState()
	return segmentChannel, donorChannel, acceptorChannel, acceptorChannel2, thresholdMethod, maxIntensity, gaussianSigma, largeDoGSigma, topHat, topHatSigma, manualSegment, manualThreshold, makeNearProj, dilation, sizeExclude, minSize, maxSize, watershed
Ejemplo n.º 24
0
gd.addStringField("Output folder suffix","",20)
outsuffixf = gd.getStringFields().get(3)

gd.addStringField("(Further) Registration Params","",50);
regparamf = gd.getStringFields().get(4)
gd.addStringField("Additional Arguments to munger.pl","",50);

regrootf.addTextListener(RegRootListener())
imgdirf.addTextListener(ImageDirListener())
outsuffixf.addTextListener(OuputSuffixListener())
choicef.addItemListener(RegParamListener())
# used for errors etc
gd.addMessage("Start by choosing a registration directory or images directory!")
statusf=gd.getMessage()
gd.showDialog()
if gd.wasCanceled():
	sys.exit("User cancelled!")
# Process Dialog Choices
rootDir=gd.getNextString()
os.chdir(rootDir)
refBrain=gd.getNextString()
image=gd.getNextString()
image=relpath(image,rootDir)
print refBrain
refBrain=relpath(refBrain,rootDir)
print refBrain

affine=gd.getNextBoolean()
ch01=gd.getNextBoolean()
warp=gd.getNextBoolean()
ch02=gd.getNextBoolean()
doRigidTransformCheckbox = gdp.getCheckboxes().get(1);
translationXSlider = gdp.getSliders().get(2);
translationYSlider = gdp.getSliders().get(3);
translationZSlider = gdp.getSliders().get(4);

rotationXSlider = gdp.getSliders().get(5);
rotationYSlider = gdp.getSliders().get(6);
rotationZSlider = gdp.getSliders().get(7);

doSpotDetectionCheckbox = gdp.getCheckboxes().get(2);
toleranceSlider = gdp.getSliders().get(8);
thresholdSlider = gdp.getSliders().get(9);

# loop until user closed the dialog
stillValid = False;
while ((not gdp.wasCanceled()) and not (gdp.wasOKed())):

	# reserve memory for input and output images
	if (input is None):
		input = clijx.create([
			(long)(imp.getWidth() * scaleX), 
			(long)(imp.getHeight() * scaleY), 
			(long)(imp.getNSlices() * scaleZ)], clijx.Float);
				
		temp1 = clijx.create(input);
		temp2 = clijx.create(input);
		dog = clijx.create(input);
		transformed = clijx.create(input);
		reslicedFromTop = clijx.create([input.getWidth(), input.getDepth(), input.getHeight()], input.getNativeType());
		cylinderProjection = clijx.create([(long)(input.getWidth() * 0.75), input.getHeight(), 540], input.getNativeType());