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
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 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 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)
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
- IJ-OpenCV update site ''' #import time #@PrefService prefs from fiji.util.gui import GenericDialogPlus ## 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
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
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)
#This creates a sparse approximation w of a signal X provided a dictionary D. #||X-Dw|| #Requires mpv2 package: http://www.ux.uis.no/~karlsk/dle/mpv2-class.zip #Improvements to come in the next version from ij import IJ, ImagePlus from ij.plugin import ImageCalculator from ij.process import ImageProcessor from ij.process import FloatProcessor from fiji.util.gui import GenericDialogPlus from mpv2 import MatchingPursuit as MP, JamaMatrix as Matrix, SymmetricMatrix as SM #Input parameters gd = GenericDialogPlus("Sparse Approximation, Input Parameters") gd.addDirectoryOrFileField("Select dictionary", "") gd.addChoice("Greedy algorithm type", ["MP", "OMP", "ORMP"], "OMP") gd.addNumericField("Number of non-zero elements", 3, 0) # show 3 decimals gd.showDialog() directory_w = gd.getNextString() t_w = int(gd.getNextNumber()) Rt = gd.getNextChoice() imp2 = IJ.getImage() IJ.run("32-bit") imp2 = IJ.getImage() #path to lighting directions IJ.run("Text Image... ", "open=" + str(directory_w)) imp = IJ.getImage() imp.setTitle("Dictionary Atoms")
# 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") font=Font("SansSerif",Font.BOLD,12) # Advanced options gd.setInsets(25,100,10) gd.addMessage("Advanced Options:",font) advancedoptionsf=gd.getMessage() ncores=Runtime.getRuntime().availableProcessors() defaultCores=1 if ncores >=8:
__dict__ = globals() try: with open("savedSettings.json") as f: thing = json.load(f) for k, v in thing.iteritems(): __dict__[k] = v print(thing) except Exception as e: print(e) gd = GenericDialog("Analysis parameters") gd.addDirectoryField("Image folder location", folderPath ) gd.addStringField("Image filename pattern", formatString, 70) gd.addStringField("Group By", groupBy, 70) gd.addStringField("Nuclear Stain Channel Name", nucChannel, 70) gd.addStringField("Cardiomyocyte Image Channel Name", cmChannel, 70) gd.addCheckbox("Are images stitched by well", stitched) gd.addChoice("Nuclear thresholding method", methodsList, nucMethod) gd.addCheckbox("Threshold nuclei by stack?", analyzeNucStack) gd.addCheckbox("Are the cardiomyocyte images brightfield?", brightfield) gd.addChoice("Cardiomyocyte thresholding method", methodsList, cmMethod) gd.addCheckbox("Threshold cardiomyocyes by stack?", analyzeCmStack) gd.addNumericField("Rows per well", rowNo, 0) gd.addNumericField("Columns per well", colNo, 0) gd.addNumericField("Nuclear minimum size (pixels)", nucMinSize, 0) gd.addNumericField("Cardiomyocyte minimum size (pixels)", cmMinSize, 0) gd.showDialog() folderPath = gd.getNextString() + "/" formatString = gd.getNextString() groupBy = re.findall(r"\w+", gd.getNextString()) nucChannel = gd.getNextString() cmChannel = gd.getNextString() stitched = gd.getNextBoolean()
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)
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) gdp.addCheckbox("Always Select Golgi", golgi_select_def)
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
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)", 25, 0) gdp.addChoice( "Exclude particles on outside perimeter? Recommended for ATP analysis", yn, "NO")
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 (Experimental)"], "Write Script") font = Font("SansSerif", Font.BOLD, 12) # Advanced options gd.setInsets(25, 100, 10) gd.addMessage("Advanced Options:", font) advancedoptionsf = gd.getMessage() ncores = Runtime.getRuntime().availableProcessors()