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." )
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 get_user_params(event): """ Allows user to select file and user parameters Parameters ---------- event : Event Waits for get_user_params_JB JButton to be pressed Returns ------- dict Dict containing filename, number of Gaussians to fit, % of dataset to import, whether to specify grey value limits, minimum grey value and maximum grey value to consider (optional) """ # Open user dialog gui = GenericDialogPlus("Define user parameters") gui.addFileField("Image filename", "Select image file") gui.addNumericField("Number of Gaussians to fit: ", 2, 0) gui.addNumericField("Percentage of dataset to import: ", 15, 0) gui.addCheckbox("Specify grey value limits?", False) gui.addNumericField("Min grey value (optional): ", 0, 0) gui.addNumericField("Max grey value (optional): ", 255, 0) gui.showDialog() # Extract user parameters if gui.wasOKed(): user_params = {} # empty dict user_params['img_fname'] = str(gui.getNextString()) user_params['n_gaussians'] = int(gui.getNextNumber()) user_params['pct_stack_import'] = float(gui.getNextNumber()) user_params['specify_gv'] = gui.getNextBoolean() user_params['min_gv'] = float(gui.getNextNumber()) user_params['max_gv'] = float(gui.getNextNumber()) # Create results directory results_dir = os.path.splitext(user_params['img_fname'])[0] + "_results" if os.path.isdir(results_dir) == False: os.mkdir(results_dir) print("Results directory: {}".format(results_dir)) # Write user parameters to text file user_params_fname = os.path.join(results_dir, "Users_Params.csv") with open(user_params_fname, "wb") as f: w = csv.DictWriter(f, user_params.keys()) w.writeheader() w.writerow(user_params) # Write directory to look for user params to text file in main/ temp_user_dir = os.path.join(os.path.dirname(__file__), "temp_user_dir.txt") if os.path.isfile(temp_user_dir) == True: os.remove(temp_user_dir) # delete temp_user_dir.txt if present f = open(temp_user_dir, "w") f.write(user_params_fname) f.close() return user_params
def getOptions(): gui = GenericDialogPlus("Options for Moving TIFF files") gui.addMessage("Select the number of imput files to be used per stitched image") gui.addSlider("", 2, 10, 2) gui.addFileField("Select csv file", "") gui.addMessage("Add key values and corresponding genotype, when finished, leave fields empty") gui.addStringField("Key :", prefs.get(None, "key1", "p")) gui.addToSameRow() gui.addStringField("Genotype :", prefs.get(None, "genotype1", "PROM-1_HA")) gui.addStringField("Key :", prefs.get(None, "key2", "p")) gui.addToSameRow() gui.addStringField("Genotype :", prefs.get(None, "genotype2", "PROM-1_HA")) gui.addStringField("Key :", prefs.get(None, "key3", "p")) gui.addToSameRow() gui.addStringField("Genotype :", prefs.get(None, "genotype3", "PROM-1_HA")) gui.addStringField("Key :", prefs.get(None, "key4", "p")) gui.addToSameRow() gui.addStringField("Genotype :", prefs.get(None, "genotype4", "PROM-1_HA")) gui.addStringField("Key :", prefs.get(None, "key5", "p")) gui.addToSameRow() gui.addStringField("Genotype :", prefs.get(None, "genotype5", "PROM-1_HA")) gui.showDialog() if gui.wasOKed(): tiffs_per_image = int(gui.getNextNumber()) csv_file = str(gui.getNextString()) genotypes = {} for i in range(5): key = str(gui.getNextString()) value = str(gui.getNextString()) if key != "": genotypes[key] = value else: return if len(genotypes) > 0: a = list(genotypes.items())[0] prefs.put(None, "key1", a[0]) prefs.put(None, "genotype1", a[1]) if len(genotypes) > 1: a = list(genotypes.items())[1] prefs.put(None, "key2", a[0]) prefs.put(None, "genotype2", a[1]) if len(genotypes) > 2: a = list(genotypes.items())[2] prefs.put(None, "key3", a[0]) prefs.put(None, "genotype3", a[1]) if len(genotypes) > 3: a = list(genotypes.items())[3] prefs.put(None, "key4", a[0]) prefs.put(None, "genotype4", a[1]) if len(genotypes) > 4: a = list(genotypes.items())[4] prefs.put(None, "key5", a[0]) prefs.put(None, "genotype5", a[1]) return tiffs_per_image, csv_file, genotypes
def getPaths(): """Dialog box for user to select illumination intensity and dark image files. Illumination intensity file should be a .nd file pointing to the timelapse tifs, and dark image file should be a single tif""" gd = GenericDialogPlus('File selection') gd.addFileField('Illumination stability timelapse (.nd file): ', None) gd.addFileField('Dark image (TIF): ', None) gd.showDialog() stackpath = gd.getNextString() darkpath = gd.getNextString() return stackpath, darkpath
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
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 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 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.")
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." )
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)
from ij.gui import Roi from os import listdir from os.path import join, isfile, isdir #import time ## Home-Made module from Template_Matching.MatchTemplate_Module import getHit_Template, CornerToCenter from Template_Matching.NonMaximaSupression_Py2 import NMS ## Create GUI Win = GenericDialogPlus("Multiple Template Matching") Win.addDirectoryOrFileField("Template file or templates folder", prefs.get("TemplatePath", "template(s)")) Win.addDirectoryOrFileField("Image file or images folder", prefs.get("ImagePath", "image(s)")) Win.addFileField("Rectangular_search_ROI (optional)", prefs.get("RoiPath", "searchRoi")) # Template pre-processing Win.addCheckbox("Flip_template_vertically", prefs.getInt("FlipV", False)) Win.addCheckbox("Flip_template_horizontally", prefs.getInt("FlipH", False)) Win.addStringField("Rotate template by ..(comma-separated)", prefs.get("Angles", "")) # Template matchign parameters Win.addChoice("Matching_method", [ "Normalised Square Difference", "Normalised cross-correlation", "Normalised 0-mean cross-correlation" ], prefs.get("Method", "Normalised 0-mean cross-correlation")) Win.addNumericField("Number_of_templates expected", prefs.getInt("N_hit", 1), 0) Win.addMessage("If more than 1 template expected :")
"Set Measurements...", "area integrated area_fraction limit display scientific redirect=None decimal=3" ) IJ.setForegroundColor(0, 0, 0) IJ.setBackgroundColor(255, 255, 255) #User Input Dialoge analyses = ["Counts", "ATP"] yn = ["YES", "NO"] gdp = GenericDialogPlus("Ex Vivo Granule Analysis") gdp.addMessage("Choose a UNIQUE directory to save analysis files") gdp.addDirectoryOrFileField("Output Directory", "D:/Samantha/") gdp.addMessage("IMPORTANT: Files are tracked based on input order") gdp.addMessage("Select input files (.tiff)...") gdp.addFileField("Wildtype", "D:/Samantha/test/VLEwt.tif") gdp.addFileField("DIC", "D:/Samantha/test/dic.tif") gdp.addFileField("Mutant", "D:/Samantha/test/ddmut.tif") gdp.addFileField("Background (DAPI)", "D:/Samantha/test/bg.tif") gdp.addChoice("Select analysis type", analyses, "Counts") gdp.addMessage("Choose variable conditions:") gdp.addNumericField( "Minimum Threshold. Choose value (0-1) as a percent of maximum threshold", 0.20, 2) gdp.addNumericField("Minimum granule size (pixel^2)", 20, 0) gdp.addNumericField( "Minimum granule circularity/shape. 1.0 = perfect cirlce, 0.5 = ellipse, 0.0 = rod", 0.50, 3) gdp.addNumericField("Maximum granule circularity", 1.00, 3) gdp.addNumericField( "Minimum percent overlap between images (0 = no overlap required, 100 = perfect overlap)",
boldFont = Font("SansSerif", Font.BOLD, 13) fret_fura = [] fret_fura.append("C1/C2 (FURA)") fret_fura.append("C2/C1 (FRET)") dest = IJ.getDirectory("image") bck_path = 'optional' gdp = GenericDialogPlus("FRET Assay, Version 3.4") gdp.addDirectoryField("Output Location:", dest, 40) gdp.addStringField("Processed Folder:", 'Processed_FRET', 40) gdp.addStringField("FRET Outfile:", 'FRET_Outfile.csv', 40) gdp.addStringField("Selection Radius:", '3', 10) gdp.addStringField("Image interval (sec):", '4', 10) gdp.addStringField("ZeroDivisionErorVal:", 'NA', 10) gdp.addRadioButtonGroup("", fret_fura, 1, 2, "C1/C2 (FURA)") #gdp.addCheckbox("Set Background to value:", False) gdp.addFileField("background file:", bck_path, 40) gdp.addToSameRow() gdp.addStringField("", '0', 5) gdp.addCheckbox("Apply Gaussian blur? Input sigma value:", False) gdp.addToSameRow() gdp.addStringField("", '4', 5) gdp.addMessage(" ") gdp.addMessage("Set R0 range (timepoint position x1 to x2):", boldFont) gdp.addStringField("x1:", '2', 3) gdp.addToSameRow() gdp.addStringField(" x2:", '8', 3) gdp.addMessage("Set output file headers:", boldFont) gdp.addStringField("Channel 1:", 'A', 8) gdp.addToSameRow() gdp.addStringField("Channel 2:", 'B', 8)
import csv from ij.gui import Roi, PolygonRoi, GenericDialog, TextRoi, NonBlockingGenericDialog import os from fiji.util.gui import GenericDialogPlus import re gdp=GenericDialogPlus("File Derandomizer") gdp.addFileField("'Key' path :", " ") gdp.addFileField("Data file :", " ") gdp.addDirectoryField("Derandomized path", "(optional)") gdp.addDirectoryField("Processed Image Folder", " ") gdp.addCheckbox("Derandomize Data File", True) gdp.addCheckbox("Derandomize Image Folder", False) gdp.showDialog() if gdp.wasOKed(): key_path = gdp.getNextString().strip() data_path = gdp.getNextString().strip() deR_path = gdp.getNextString().strip() pi_path= gdp.getNextString().strip() ddf=gdp.getNextBoolean() dif=gdp.getNextBoolean() if deR_path == "(optional)": deR_path = os.path.dirname(data_path) else: exit() # function to return key for any value def get_key(val): for key, value in random.items():
# 0.1) Identify path to CMTK binaries bindir=cmtkgui.install_dir() print 'bindir is ' + bindir # 0.1) Identify path to munger.pl script #munger='/Users/jefferis/bin/munger.pl' munger=cmtkgui.tool_path('munger') print 'munger is ' + munger gd.addHelp("http://flybrain.mrc-lmb.cam.ac.uk/dokuwiki/doku.php?id=warping_manual:registration_gui") dirFieldWidth=50 gdMargin=130 gd.addDirectoryField("Registration Folder",None,dirFieldWidth) regrootf = gd.getStringFields().get(0) # reference brain gd.addFileField("Reference Brain", "",dirFieldWidth) # input directory/image gd.addDirectoryOrFileField("Input Image or Image Directory",None,dirFieldWidth) imgdirf = gd.getStringFields().get(2) gd.setInsets(10,gdMargin,10) gd.addMessage("Output folders:") outputf=gd.getMessage() # what to do: affine/warp/reformat gd.setInsets(10,200,10) gd.addCheckboxGroup(3,2,["affine","01","warp","02","reformat","03"],[True,True,True,True,True,True],["Registration Actions","Reformat Channels"]) #gd.addCheckboxGroup(1,3,["01","02","03"],[True,True,True],["Reformat Channels"]) # Registration options # Jefferis,Potter 2007, Cachero,Ostrovsky 2010, Manual
bindir = cmtkgui.install_dir() print 'bindir is ' + bindir # 0.1) Identify path to munger.pl script #munger='/Users/jefferis/bin/munger.pl' munger = cmtkgui.tool_path('munger') print 'munger is ' + munger gd.addHelp( "http://flybrain.mrc-lmb.cam.ac.uk/dokuwiki/doku.php?id=warping_manual:registration_gui" ) dirFieldWidth = 50 gdMargin = 130 gd.addDirectoryField("Registration Folder", None, dirFieldWidth) regrootf = gd.getStringFields().get(0) # reference brain gd.addFileField("Reference Brain", "", dirFieldWidth) # input directory/image gd.addDirectoryOrFileField("Input Image or Image Directory", None, dirFieldWidth) imgdirf = gd.getStringFields().get(2) gd.setInsets(10, gdMargin, 10) gd.addMessage("Output folders:") outputf = gd.getMessage() # what to do: affine/warp/reformat gd.setInsets(10, 200, 10) gd.addCheckboxGroup(3, 2, ["affine", "01", "warp", "02", "reformat", "03"], [True, True, True, True, True, True], ["Registration Actions", "Reformat Channels"]) #gd.addCheckboxGroup(1,3,["01","02","03"],[True,True,True],["Reformat Channels"])