Example #1
0
def createListfiles() : 

	IJ.showMessage("Select a folder with the .tif files")
	selectdir=IJ.getDirectory("image")
	selectdir=IJ.getDirectory("")

	listfiles=glob.glob(selectdir+"*.tif")

	#fullprefix = str.rsplit(str(listfiles[0]), "/", 1)
	fullprefix = os.path.split(listfiles[0])
	root = fullprefix[0]
	lastprefix = str.split(fullprefix[1], "_")

	del(listfiles)


	gdselectfiles = NonBlockingGenericDialog("List files Choice")
	gdselectfiles.addMessage("")
	gdselectfiles.addStringField("Prefix ?", lastprefix[0], 32)
	gdselectfiles.addStringField("Filter (w00001DIA) ?", "1DIA")
	gdselectfiles.addStringField("Positions (s0001) ?", "1-2")
	gdselectfiles.addStringField("Temps (t0001) ?", "1-11")
	#gdselectfiles.addStringField("Files pattern", "*DIA_s*1_t*.tif", 32)
	gdselectfiles.showDialog()

	prefix = str(gdselectfiles.getNextString())
	channel = str(gdselectfiles.getNextString())
	temppositions = str(gdselectfiles.getNextString())
	positions = str.split(temppositions, "-")
	temptimes = str(gdselectfiles.getNextString())
	times = str.split(temptimes, "-")

	if channel != "" : channel = "_w000"+channel

	positionslist=[]
	if positions[0] != "" : 
		for p in range(int(positions[0]), int(positions[1])+1, 1) : 
			positionslist.append("_s"+"%04i"%(p))
	else : positionslist.append("")

	timeslist=[]		
	if times[0] != "" : 
		for t in range(int(times[0]), int(times[1])+1, 1) : 
			timeslist.append("_t"+"%04i"%(t))
	else : timeslist.append("")
	
	patterns=[]
	listfiles = []
	for p in positionslist :
		files = []
		for t in timeslist :
			patterns.append(channel+p+t+".tif")
			tempfilename = os.path.join(root, prefix+patterns[-1])
			files.append(tempfilename)
			#files.append(root+"/"+prefix+patterns[-1])
		listfiles.append(files)

	if len(listfiles)>1 : return (prefix, patterns, listfiles, positionslist)
	else : return (prefix, patterns, files, "_s0001")
Example #2
0
def runGUI(defaultTargetChannel=2,
           defaultdt=1.0,
           defaultRadius=0.3,
           defaultThreshold=16,
           defaultFrameGap=0.01,
           defaultLinkingMax=0.01,
           defaultClosingMax=0.01):
    gd = NonBlockingGenericDialog("ZedMate - v0.18 beta")
    gd.addMessage(
        "\tZedMate is a TrackMate-based 3D prticle analyzer \n\t\t\t\t\t\t\t\t\t\t\t(copyright Artur Yakimovich 2018-19)\n\n"
    )
    gd.addStringField("File_extension", ".tif")
    gd.addStringField("File_name_contains", "")
    gd.addNumericField("Target_Channel", defaultTargetChannel, 0)
    gd.addNumericField("dt", defaultdt, 2)
    gd.addNumericField("Radius", defaultRadius, 2)
    gd.addNumericField("Threshold", defaultThreshold, 2)
    gd.addNumericField("Frame_Gap", defaultFrameGap, 0)
    gd.addNumericField("Linking_Max", defaultLinkingMax, 2)
    gd.addNumericField("Closing_Max", defaultClosingMax, 2)
    gd.addMessage("\t\t\t\t\t\t_______________________________________")
    gd.addCheckbox("Preview Parameters on the First Image Only", 0)
    gd.addMessage("\t\t\t\t\t(Doesn't save results. Re-opens this Dialog).")
    gd.addMessage("\t\t\t\t\t\t_______________________________________")
    gd.addCheckbox("Save MNIST mimicry embedding (beta)", 0)
    gd.showDialog()

    if gd.wasCanceled():
        return
    extension = gd.getNextString()
    containString = gd.getNextString()
    targetChannel = int(gd.getNextNumber())
    dt = gd.getNextNumber()
    radius = gd.getNextNumber()
    threshold = gd.getNextNumber()
    frameGap = int(gd.getNextNumber())
    linkingMax = gd.getNextNumber()
    closingMax = gd.getNextNumber()
    testMode = gd.getNextBoolean()
    mimicryEmbd = gd.getNextBoolean()

    inputDir = IJ.getDirectory("Input_directory")
    if not inputDir:
        return
    if not testMode:
        outputDir = IJ.getDirectory("Output_directory")
        if not outputDir:
            return
    else:
        outputDir = inputDir  # for the case of test

    #if not os.path.exists(outputDir):
    #	os.makedirs(outputDir)

    runBatch(inputDir, outputDir, extension, containString, targetChannel, dt, radius, threshold, frameGap,\
       linkingMax, closingMax, testMode, mimicryEmbd)
def showGui(par, title):
    """Updated version discriminates between string and numeric outputs to treat them accordingly"""
    numflags = {}

    gd = NonBlockingGenericDialog(title)
    s_keys = sorted(par.keys())
    for nm in s_keys:
        if isinstance(par[nm], (int, float, long)):
            gd.addNumericField(nm, par[nm], 1)
            numflags[nm] = True
        else:
            gd.addStringField(nm, par[nm])
            numflags[nm] = False
    gd.setOKLabel("Go on!")
    gd.setCancelLabel("Recompute..")
    gd.centerDialog(False)
    gd.setLocation(50, 100)
    gd.showDialog()

    if gd.wasCanceled():
        rep = True
    else:
        rep = False

    for nm in s_keys:
        if numflags[nm]:
            par[nm] = gd.getNextNumber()
        else:
            par[nm] = gd.getNextString().encode("ascii", "replace")
    return par, rep
	gd.addNumericField("Size_threshold",100,0)
	gd.addChoice("Process_filter",["None","Min","Median"],"None")
	gd.addCheckbox("Operate_on_tile_subset",False)
	gd.addStringField("Which_tile_subset","1-4,9,11",12)
	gd.showDialog()

	## Parses the information from the dialog box
	if (gd.wasOKed()):
		analysisChannel = gd.getNextChoiceIndex()+1
		bleedingChannel = gd.getNextChoiceIndex()
		refChannel = gd.getNextChoiceIndex()
		intThreshold = gd.getNextNumber()
		sizeThreshold = gd.getNextNumber()
		processFilter = gd.getNextChoiceIndex()
		doSubset = gd.getNextBoolean()
		whichTiles = gd.getNextString()
		tileList = []
		parsingFailed = False
		if doSubset:
			try: 
				whichTilesDespaced = whichTiles.replace(" ","")
				tilesListed = whichTilesDespaced.split(",")
				for tile in tilesListed:
					tilesExpanded = tile.split("-")
					tilesExpanded = map(int,tilesExpanded)
					if (len(tilesExpanded) == 2):
						tilesExpanded = range(tilesExpanded[0],tilesExpanded[1]+1)
					tileList = tileList + tilesExpanded
				tileList = list(set(tileList))
				tileList = filter(lambda x: True if x<nTiles+1 else False,tileList)
				print tileList
Example #5
0
from ij.measure import Measurements
from ij.gui import NonBlockingGenericDialog
from ij.gui import WaitForUserDialog

# Get input and output directories

dc = DirectoryChooser("Choose an input directory")
inputDirectory = dc.getDirectory()

dc = DirectoryChooser("Choose an output directory")
outputDirectory = dc.getDirectory()

gd = NonBlockingGenericDialog("Channel Options")
gd.addStringField("Enter your name: ", "")
gd.showDialog()
name = gd.getNextString()

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

# Finds all the subfolders in the main directory

with open(outputDirectory + "annotations_" + name + ".csv", "w") as log:

    subfolders = []

    #	for subfolder in os.listdir(inputDirectory):
    #		if os.path.isdir(inputDirectory + subfolder):
    #			subfolders.append(subfolder)

    #	for subfolder in subfolders:
    # user interface
    nbgd = NonBlockingGenericDialog("ER Selection")
    nbgd.addStringField("Selection radius: ", str(radius), 5)
    nbgd.hideCancelButton()
    imp = IJ.getImage()
    overlay = Overlay()
    overlay = imp.getOverlay()
    nbgd.showDialog()

    if mean_max_det is True:
        IJ.setTool("polygon")
    else:
        IJ.setTool("rectangle")

    radius = int(nbgd.getNextString().strip())
    imp = IJ.getImage()
    # set variables
    all_x = []
    all_y = []
    ER_measurements = []

    # function
    ER_points(all_x, all_y, overlay, ER_measurements)

    # set more variables
    ER = []

    # merges the x and y lists such that x,y are  pairs in a list
    x_y = list(zip(all_x, all_y))
    # loops through x,y coordinate pairs, draw a circle and measures the average intensity.