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 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(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 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 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 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)
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 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
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
# rest of imports below on purpose (otherwise searchRoi lost) ## Create GUI Win = GenericDialogPlus("Multiple Template Matching") Win.addImageChoice("Template", prefs.get("Template", "Choice")) Win.addImageChoice("Image", prefs.get("Image", "Choice")) 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", "")) 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_objects expected", prefs.getInt("N_hit", 1), 0) Win.addMessage("If more than 1 object expected :") Win.addSlider("Score_Threshold", 0, 1, prefs.getFloat("Score_Threshold", 0.5), 0.1) #Win.addNumericField("Min_peak_height relative to neighborhood ([0-1], decrease to get more hits)", prefs.getFloat("Tolerance",0.1), 2) Win.addSlider("Maximal_overlap between Bounding boxes", 0, 1, prefs.getFloat("MaxOverlap", 0.4), 0.1) Win.addMessage("Outputs") Win.addCheckbox("Add_ROI detected to ROI manager", prefs.getInt("AddRoi", True)) Win.addCheckbox("Show_result table", prefs.getInt("ShowTable", False)) Win.addMessage("Version 1.1.2") Win.addMessage("""If you use this plugin please cite : Thomas, L.S.V., Gehrig, J. Multi-template matching: a versatile tool for object-localization in microscopy images. BMC Bioinformatics 21, 44 (2020). https://doi.org/10.1186/s12859-020-3363-7""") Win.addHelp(
Requirements: - IJ-OpenCV update site ''' #import time #from timeit import default_timer as timer #@PrefService prefs from Template_Matching.Version import version from fiji.util.gui import GenericDialogPlus # rest of imports below on purpose (otherwise searchRoi lost) ## Create GUI Win = GenericDialogPlus("Multiple Template Matching") Win.addImageChoice("Template", prefs.get("Template", "Choice")) Win.addImageChoice("Image", prefs.get("Image", "Choice")) Win.addMessage("# 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", "")) Win.addMessage("# Detection 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_objects expected", prefs.getInt("N_hit", 1), 0) Win.addMessage("# Non-Maxima Suppression (if N_object > 1)") Win.addSlider("Score_Threshold", 0, 1, prefs.getFloat("Score_Threshold", 0.5), 0.1) #Win.addNumericField("Min_peak_height relative to neighborhood ([0-1], decrease to get more hits)", prefs.getFloat("Tolerance",0.1), 2) Win.addSlider("Maximal_overlap between Bounding boxes", 0, 1,
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 gd.addChoice("Registration Params",["Jefferis, Potter 2007","Cachero, Ostrovsky 2010"],"Jefferis, Potter 2007") choicef=gd.getChoices().get(0) print choicef.getSelectedItem() # final Action (Test, Run, Write Script) gd.addChoice("Action",["Test","Write Script","Run"],"Write Script")
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) gdp.addStringField("Channel Z/Channel W:", 'C', 8) gdp.addToSameRow() gdp.addStringField("R/R0:", 'D', 8) gdp.showDialog() if gdp.wasOKed(): dest = gdp.getNextString().strip() ProFolder = gdp.getNextString().strip()
cmtkgui.movefile(frompath,target_dir) print("Cleaning up!") try: shutil.rmtree(td) except OSError: print("Failed to remove temporary directory: "+td+"\n") pass download_urls=cmtkgui.downloads() # download_urls=['http://www.nitrc.org/frs/download.php/4814/CMTK-2.2.3-CYGWIN-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4812/CMTK-2.2.3-Linux-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4820/CMTK-2.2.3-MacOSX-10.4-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4822/CMTK-2.2.3-MacOSX-10.5-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4824/CMTK-2.2.3-MacOSX-10.6-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4604/CMTK-2.2.1-CYGWIN-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4596/CMTK-2.2.1-Linux-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4608/CMTK-2.2.1-MacOSX-10.4-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4610/CMTK-2.2.1-MacOSX-10.5-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4611/CMTK-2.2.1-MacOSX-10.6-x86_64.tar.gz'] download_files=map(os.path.basename,download_urls) download_dict=dict(zip(download_files,download_urls)) print cmtkgui.install_dir() gd = GenericDialogPlus('Install CMTK') gd.addMessage('Currently installed CMTK version: '+cmtkgui.installed_version()) recommended_file=cmtkgui.recommended_file(download_files) if recommended_file is None: recommended_file = download_files[0] gd.addChoice("Download file",download_files,recommended_file) gd.addMessage('By downloading this file you agree to the following (if you '+ 'do not agree to this, please press "Cancel" below):') gd.addMessage('Core CMTK code is licensed under the GPLv3.\nBundled software'+ ' may be licensed under different terms - see licences/ directory for details') gd.showDialog() if gd.wasOKed(): download_file=gd.getNextChoice() # nb url has a suffix to indicate that user agreed to license download_url=download_dict[download_file]+'/?i_agree=1&download_now=1' print "Downloading "+download_file+' from url '+download_url+' to '+cmtkgui.install_dir() cmtkgui.download_and_untar_url(download_url,cmtkgui.install_dir(),untar_binaries,download_file)
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
os.chdir(dest) json_selected = os.path.join(dest, json_selected) json_selected = json_selected+'/' # Writing to sample.json with open(json_selected, "w") as outfile: outfile.write(json_object) # sets up a generic dialog box to start the script. dest = IJ.getDirectory("image") gdp = GenericDialogPlus("Transport Assay - "+version) gdp.addDirectoryField("Image Folder:", dest, 40) gdp.addStringField("Processed Image Folder:", ProFolder_def, 40) gdp.addStringField("Transport Output:", Quant_def, 40) gdp.addStringField("Mean_Max Output:", Quant_MM_def, 40) gdp.addMessage("------------------------------------------------------------", italicFont) gdp.addChoice("Transport Channel:", channels_available, tran_def) gdp.addToSameRow() gdp.addStringField("File Type: ", file_def, 5) gdp.addChoice(" Golgi Channel:", channels_available, golgi_def) gdp.addToSameRow() gdp.addStringField("Processed File Extension: ", ext_def, 5) gdp.addMessage(" ", italicFont) gdp.addToSameRow() gdp.addMessage(" ", italicFont) gdp.addChoice(" Zoom: ", zoom, zoom_def) gdp.addToSameRow() gdp.addStringField("ER Selection Radius: ", radius_def, 5) gdp.addChoice("View Mode:", color_options, color_def) gdp.addMessage("------------------------------------------------------------", italicFont) gdp.addMessage(" Advanced Options: ", italicFont)
print("Cleaning up!") try: shutil.rmtree(td) except OSError: print("Failed to remove temporary directory: " + td + "\n") pass download_urls = cmtkgui.downloads() # download_urls=['http://www.nitrc.org/frs/download.php/4814/CMTK-2.2.3-CYGWIN-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4812/CMTK-2.2.3-Linux-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4820/CMTK-2.2.3-MacOSX-10.4-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4822/CMTK-2.2.3-MacOSX-10.5-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4824/CMTK-2.2.3-MacOSX-10.6-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4604/CMTK-2.2.1-CYGWIN-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4596/CMTK-2.2.1-Linux-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4608/CMTK-2.2.1-MacOSX-10.4-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4610/CMTK-2.2.1-MacOSX-10.5-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4611/CMTK-2.2.1-MacOSX-10.6-x86_64.tar.gz'] download_files = map(os.path.basename, download_urls) download_dict = dict(zip(download_files, download_urls)) print cmtkgui.install_dir() gd = GenericDialogPlus('Install CMTK') gd.addMessage('Currently installed CMTK version: ' + cmtkgui.installed_version()) recommended_file = cmtkgui.recommended_file(download_files) if recommended_file is None: recommended_file = download_files[0] gd.addChoice("Download file", download_files, recommended_file) gd.addMessage('By downloading this file you agree to the following (if you ' + 'do not agree to this, please press "Cancel" below):') gd.addMessage( 'Core CMTK code is licensed under the GPLv3.\nBundled software' + ' may be licensed under different terms - see licences/ directory for details' ) gd.showDialog() if gd.wasOKed(): download_file = gd.getNextChoice() # nb url has a suffix to indicate that user agreed to license download_url = download_dict[download_file] + '/?i_agree=1&download_now=1'
rm = RoiManager().getInstance() #Set some defaults IJ.run( "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",
shutil.move(os.path.join(td,subdir),target_dir) try: download_url='https://github.com/jefferis/fiji-cmtk-gui/tarball/master' # check date installed_version='NA' local_version_info=cmtkgui.gui_local_versioninfo() if local_version_info.has_key('date'): installed_version=local_version_info['date'] github_version_info=cmtkgui.gui_github_versioninfo() update_available=cmtkgui.gui_update_available(github_version_info) gd = GenericDialogPlus('Update CMTK GUI') if update_available: gd.addMessage('CMTK GUI update available') gd.setOKLabel("Download") else: gd.addMessage('CMTK GUI is up to date') gd.addMessage('Currently installed CMTK GUI version: '+installed_version) gd.showDialog() if gd.wasOKed() and update_available: # nb url has a suffix to indicate that user agreed to license from ij import IJ IJ.showStatus('Downloading CMTK GUI') cmtkgui.download_and_untar_url(download_url,cmtkgui.gui_install_dir(),untar_github_archive) cmtkgui.gui_write_local_versioninfo(github_version_info) except SystemExit, e: from ij import IJ
"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 gd.addChoice("Registration Params", ["Jefferis, Potter 2007", "Cachero, Ostrovsky 2010"], "Jefferis, Potter 2007") choicef = gd.getChoices().get(0)
calib = imp.getCalibration(); scaleX = calib.pixelWidth / calib.pixelDepth * zoom; scaleY = calib.pixelHeight / calib.pixelDepth * zoom; scaleZ = 1.0 * zoom; # initialize state input = None; formerT = None; resultCylinderMaxProjection = None; resultMaxProjection = None; spots = None; circles = None; blobs = None; # build up user interface gdp = GenericDialogPlus("Spot detection workflow"); gdp.addMessage("Noise and background subtraction (DoG)"); gdp.addCheckbox("Do noise and background subtraction ", formerDoNoiseAndBackgroundRemoval); gdp.addSlider("Sigma 1 (in 0.1 pixel)", 0, 100, formerSigma1); gdp.addSlider("Sigma 2 (in 0.1 pixel)", 0, 100, formerSigma2); gdp.addMessage("Rigid transform"); gdp.addCheckbox("Do rigid transformation", formerDoRigidTransform); gdp.addSlider("Translation X (in pixel)", -100, 100, formerTranslationX); gdp.addSlider("Translation Y (in pixel)", -100, 100, formerTranslationY); gdp.addSlider("Translation Z (in pixel)", -100, 100, formerTranslationZ); gdp.addSlider("Rotation X (in degrees)", -180, 180, formerRotationX); gdp.addSlider("Rotation Y (in degrees)", -180, 180, formerRotationY); gdp.addSlider("Rotation Z (in degrees)", -180, 180, formerRotationZ); gdp.addMessage("Spot detection") gdp.addCheckbox("Do spot detection", formerDoSpotDetection); gdp.addSlider("Tolerance", 0, 100, formerTolerance);
# define some variables # EM = electron microscopic image # rLM = real light microscopic image (ground truth) with chromatin channel # pLM = predictet light microscopic image # c1LM, c2LM, c3LM ... = channels of interest (COI) # define input (java.io.File to string) EMfilepath = EMfilepath.toString() rLMfilepath = rLMfilepath.toString() workdir = workdir.toString() # check if workdir is empty if len(os.listdir(workdir)) != 0: gd = GenericDialogPlus("Options") gd.addMessage("Working directory must be empty!") gd.addMessage( "Please delete all files in the working directory, or choose another working directory and restart the Deep CLEM Plugin." ) gd.showDialog() if len(os.listdir(workdir)) != 0: sys.exit() # create a couple of folder in workdir # for registration registration_inputdir = os.path.join(workdir, "registration_input") os.mkdir(registration_inputdir) registration_outputdir = os.path.join(workdir, "registration_output") os.mkdir(registration_outputdir)
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
def errorDialog(message): gd = GenericDialogPlus("Error") gd.addMessage(message) gd.showDialog() return
## Create GUI Win = GenericDialogPlus("Multiple Template Matching") Win.addImageChoice("Template", prefs.get("Template", "Choice")) Win.addImageChoice("Image", prefs.get("Image", "Choice")) 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", "")) 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 :") Win.addNumericField("Score_Threshold [0-1]", prefs.getFloat("Score_Threshold", 0.5), 2) #Win.addNumericField("Min_peak_height relative to neighborhood ([0-1], decrease to get more hits)", prefs.getFloat("Tolerance",0.1), 2) Win.addNumericField("Maximal_overlap between Bounding boxes [0-1]", prefs.getFloat("MaxOverlap", 0.4), 2) Win.addMessage("Outputs") Win.addCheckbox("Add_ROI detected to ROI manager", prefs.getInt("AddRoi", True)) Win.addCheckbox("Show_result table", prefs.getInt("ShowTable", False)) Win.addMessage("""If you use this plugin please cite : Laurent SV Thomas, Jochen Gehrig bioRxiv 619338; doi: https://doi.org/10.1101/619338""") Win.addHelp( "https://github.com/multi-template-matching/MultiTemplateMatching-Fiji/wiki" )
shutil.move(os.path.join(td, subdir), target_dir) try: download_url = 'https://github.com/jefferis/fiji-cmtk-gui/tarball/master' # check date installed_version = 'NA' local_version_info = cmtkgui.gui_local_versioninfo() if local_version_info.has_key('date'): installed_version = local_version_info['date'] github_version_info = cmtkgui.gui_github_versioninfo() update_available = cmtkgui.gui_update_available(github_version_info) gd = GenericDialogPlus('Update CMTK GUI') if update_available: gd.addMessage('CMTK GUI update available') gd.setOKLabel("Download") else: gd.addMessage('CMTK GUI is up to date') gd.addMessage('Currently installed CMTK GUI version: ' + installed_version) gd.showDialog() if gd.wasOKed() and update_available: # nb url has a suffix to indicate that user agreed to license from ij import IJ IJ.showStatus('Downloading CMTK GUI') cmtkgui.download_and_untar_url(download_url, cmtkgui.gui_install_dir(), untar_github_archive) cmtkgui.gui_write_local_versioninfo(github_version_info) except SystemExit, e: