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)
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 #Input parameters gd = GenericDialogPlus("Input Parameters") gd.addDirectoryOrFileField("Select composite color image, 32-bit", "") gd.addNumericField("Pixel size", 4, 0) # show 3 decimals gd.addNumericField("Background color", 150, 0) # show 3 decimals gd.showDialog() directory_w = gd.getNextString() px = int(gd.getNextNumber()) bc = int(gd.getNextNumber()) #path to RGB image IJ.open(str(directory_w)) imp = IJ.getImage() IJ.run("8-bit") IJ.run("32-bit") n_slicesa = imp.getStack().getSize() L = [] for i in range(1, n_slicesa + 1): imp.setSlice(i) n = imp.getProcessor().getPixels() n2 = [int(val) for val in n] L.append(n2) imp.changes = False
#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")
#@PrefService prefs #@FormatService fs # to check that the file in the folder are indeed images from fiji.util.gui import GenericDialogPlus from ij import IJ 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"
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 gd.addChoice("Registration Params",["Jefferis, Potter 2007","Cachero, Ostrovsky 2010"],"Jefferis, Potter 2007") choicef=gd.getChoices().get(0)
#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", 0.50, 3)
# 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