コード例 #1
0
def run_straighten(roiWindowsize = 4):
    """ Original straightening function based on Nick's macro. Used in final version.
    Returns coordinate string used to make centerline. """
    IJ.run("Set Measurements...", "mean min center redirect=None decimal=3")
    IJ.runMacro("//setTool(\"freeline\");")
    IJ.run("Line Width...", "line=80");
    numPoints = 512/roiWindowsize
    xvals = []
    yvals = []
    maxvals = []
    counter = 0

    for i in range(0, 512, roiWindowsize):
        IJ.run("Clear Results")
        IJ.makeRectangle(i, 0, roiWindowsize, 512)
        IJ.run("Measure")
        table = RT.getResultsTable()
        xvals.append(i + roiWindowsize/2)
        yvals.append(RT.getValue(table, "YM", 0))
        maxvals.append((RT.getValue(table, "Max", 0)))

        if maxvals[counter] == 0 and counter > 0:
            yvals[counter] = yvals[counter - 1]

        counter += 1

    coords = ""
    for i in range(numPoints - 1):
        coords += str(xvals[i]) + ", " + str(yvals[i]) +", "
    coords += str(xvals[numPoints-1]) + ", " + str(yvals[numPoints-1])

    IJ.runMacro("makeLine("+coords+")")
    IJ.run("Straighten...", "line = 80")
    return coords
コード例 #2
0
def run_straighten(roiWindowsize=4):
    """ Original straightening function based on Nick's macro. Used in final version.
    Returns coordinate string used to make centerline. """
    IJ.run("Set Measurements...", "mean min center redirect=None decimal=3")
    IJ.runMacro("//setTool(\"freeline\");")
    IJ.run("Line Width...", "line=80")
    numPoints = 512 / roiWindowsize
    xvals = []
    yvals = []
    maxvals = []
    counter = 0

    for i in range(0, 512, roiWindowsize):
        IJ.run("Clear Results")
        IJ.makeRectangle(i, 0, roiWindowsize, 512)
        IJ.run("Measure")
        table = RT.getResultsTable()
        xvals.append(i + roiWindowsize / 2)
        yvals.append(RT.getValue(table, "YM", 0))
        maxvals.append((RT.getValue(table, "Max", 0)))

        if maxvals[counter] == 0 and counter > 0:
            yvals[counter] = yvals[counter - 1]

        counter += 1

    coords = ""
    for i in range(numPoints - 1):
        coords += str(xvals[i]) + ", " + str(yvals[i]) + ", "
    coords += str(xvals[numPoints - 1]) + ", " + str(yvals[numPoints - 1])

    IJ.runMacro("makeLine(" + coords + ")")
    IJ.run("Straighten...", "line = 80")
    return coords
コード例 #3
0
def measure_growth(imgDir, filename = "Fiji_Growth.txt"):
    """ Collects measurement data in pixels and writes to a file. Uses straightened binary images"""
    f = open(imgDir + filename, 'w')
    f.write("Img number\tEnd point (pixels)\n")
    IJ.run("Set Measurements...", "area mean min center redirect=None decimal=3")
    index = "000000000"
    filename = imgDir + "/binary" + "/img_" + index + "__000-padded.tif"
    while path.exists(filename):
		imp = IJ.openImage(filename)
		imp.show()
		IJ.run("Clear Results")
		for i in xrange(800): #hard coded to target length for now
			IJ.makeRectangle(i, 0, 1, 80)
			IJ.run("Measure")
			table = RT.getResultsTable()
			#print "i:", i, "counter:", table.getCounter()
			maxi = RT.getValue(table, "Max", i)
			if maxi == 0:
				f.write(str(int(index)) + "\t" + str(i) + "\n")
				break

		IJ.runMacro("while (nImages>0) {selectImage(nImages);close();}")
		index = to_9_Digits(str(int(index)+1))
		filename = imgDir + "/padded" + "/img_" + index + "__000-padded.tif"
    f.close()
コード例 #4
0
def main_noninteractive():
    """The main routine for running non-interactively."""
    global imcftpl
    args = parse_arguments()
    set_loglevel(args.verbose)
    log.info('Running in non-interactive mode.')
    log.debug('Python FluoView package file: %s' % fv.__file__)
    base = dirname(args.mosaiclog)
    fname = basename(args.mosaiclog)
    mosaics = fv.FluoViewMosaic(join(base, fname))
    log.warn(gen_mosaic_details(mosaics))
    if args.templates is not None:
        imcftpl = args.templates
    code = imagej.gen_stitching_macro_code(mosaics, 'templates/stitching',
                                           path=base, tplpath=imcftpl)
    if not args.dryrun:
        log.info('Writing stitching macro.')
        imagej.write_stitching_macro(code, fname='stitch_all.ijm', dname=base)
        log.info('Writing tile configuration files.')
        imagej.write_all_tile_configs(mosaics, fixsep=True)
        log.info('Launching stitching macro.')
        IJ.runMacro(flatten(code))
    else:
        log.info('Dry-run was selected. Printing generated macro:')
        log.warn(flatten(code))
コード例 #5
0
def makeSpline(*points):
    macrocode = 'makeLine('
    for x, y in points:
        macrocode += str(int(x)) + ", " + str(int(y)) + ", "
    macrocode = macrocode[:-2] + ');'
    #print macrocode
    IJ.runMacro(macrocode)
コード例 #6
0
def measure_growth(imgDir, filename="Fiji_Growth.txt"):
    """ Collects measurement data in pixels and writes to a file. Uses straightened binary images"""
    f = open(imgDir + filename, 'w')
    f.write("Img number\tEnd point (pixels)\n")
    IJ.run("Set Measurements...",
           "area mean min center redirect=None decimal=3")
    index = "000000000"
    filename = imgDir + "/binary" + "/img_" + index + "__000-padded.tif"
    while path.exists(filename):
        imp = IJ.openImage(filename)
        imp.show()
        IJ.run("Clear Results")
        for i in xrange(800):  #hard coded to target length for now
            IJ.makeRectangle(i, 0, 1, 80)
            IJ.run("Measure")
            table = RT.getResultsTable()
            #print "i:", i, "counter:", table.getCounter()
            maxi = RT.getValue(table, "Max", i)
            if maxi == 0:
                f.write(str(int(index)) + "\t" + str(i) + "\n")
                break

        IJ.runMacro("while (nImages>0) {selectImage(nImages);close();}")
        index = to_9_Digits(str(int(index) + 1))
        filename = imgDir + "/padded" + "/img_" + index + "__000-padded.tif"
    f.close()
コード例 #7
0
ファイル: chess_.py プロジェクト: Mverp/fiji
def path(i, j, array):
    macro = "makePolygon("
    for k in range(0, len(array), 2):
        if k > 0:
            macro = macro + ", "
        macro = macro + str(i * w + array[k]) + ", " + str(j * h + array[k + 1])
    macro += ");"
    IJ.runMacro(macro)
コード例 #8
0
def straighten_roi_rotation(roiWindowsize = 8):
    """ Root straightening function that rotates ROI to follow root slope.
    Does not work properly.
    """
    IJ.run("Set Measurements...", "mean standard min center redirect=None decimal=3")
    IJ.runMacro("//setTool(\"freeline\");")
    IJ.run("Line Width...", "line=80");
    #numPoints = 512/roiWindowsize
    xvals = []
    yvals = []
    maxvals = []
    counter = 0
    maxIters = 800/roiWindowsize
    minIters = 10

    imp = IJ.getImage().getProcessor()

    rm = RoiManager()
    if find_first_pixel(0,imp) == None or find_last_pixel(0,imp)[1] == None:
        return
    y = (find_first_pixel(0,imp)[1]+find_last_pixel(0,imp)[1])/2
    roi = roiWindow_(imp, center = (roiWindowsize/2,y), width = roiWindowsize, height = 512)
    xvals.append(roiWindowsize/2)
    yvals.append(y)
    maxvals.append(0)
    roi.findTilt_()
    i = 0
    while i < maxIters and roi.containsRoot_():
    	roi.advance_(roiWindowsize)
        IJ.run("Clear Results")
        IJ.run("Measure")
        table = RT.getResultsTable()

        x  = RT.getValue(table, "XM", 0)
        y = RT.getValue(table, "YM", 0)
        if imp.getPixel(int(x),int(y)) != 0:
            xvals.append(x)
            yvals.append(y)
            maxvals.append((RT.getValue(table, "Max", 0)))


        #roi.advance_(roiWindowsize)
        print "here"
        roi.unrotateRoot_()
        IJ.run("Clear Results")
        IJ.run("Measure")
        roi.restoreCenter_(RT.getValue(table, "XM", 0), RT.getValue(table, "YM", 0))
        #exit(1)
        sleep(.5)
        roi.findTilt_()
        i += 1
    coords = ""
    for i in range(len(xvals)-1):
        coords += str(xvals[i]) + ", " + str(yvals[i]) +", "
    coords += str(xvals[len(xvals)-1]) + ", " + str(yvals[len(xvals)-1])

    IJ.runMacro("makeLine("+coords+")")
    IJ.run("Straighten...", "line = 80")
コード例 #9
0
def path(i, j, array):
    macro = 'makePolygon('
    for k in range(0, len(array), 2):
        if k > 0:
            macro = macro + ', '
        macro = macro + str(i * w + array[k]) + ', ' + str(j * h +
                                                           array[k + 1])
    macro += ');'
    IJ.runMacro(macro)
コード例 #10
0
ファイル: chess_.py プロジェクト: Mverp/fiji
def square(i, j, currentX, currentY):
    IJ.runMacro("makeRectangle(" + str(w * i) + ", " + str(h * j) + ", " + str(w) + ", " + str(h) + ");")
    if i == currentX and j == currentY:
        color = "orange"
    elif (i + j) & 1 == 1:
        color = "black"
    else:
        color = "white"
    setColor(color)
    IJ.run("Fill")
コード例 #11
0
def preProcess_(imp):
    """ Noise filtering step. Removes particles other than the root after segmentation.
    Takes a pointer to an ImagePlus, returns pointer to new ImagePlus. """
    IJ.runMacro("//setThreshold(1, 255);")
    IJ.runMacro("run(\"Convert to Mask\");")
    IJ.run("Analyze Particles...", "size=400-Infinity show=Masks")
    filteredImp = IJ.getImage()
    #imp.close()
    #IJ.run("Invert")
    IJ.run("Invert LUT")
    return filteredImp
コード例 #12
0
def preProcess_(imp):
    """ Noise filtering step. Removes particles other than the root after segmentation.
    Takes a pointer to an ImagePlus, returns pointer to new ImagePlus. """
    IJ.runMacro("//setThreshold(1, 255);")
    IJ.runMacro("run(\"Convert to Mask\");")
    IJ.run("Analyze Particles...", "size=400-Infinity show=Masks")
    filteredImp = IJ.getImage()
    #imp.close()
    #IJ.run("Invert")
    IJ.run("Invert LUT")
    return filteredImp
コード例 #13
0
def square(i, j, currentX, currentY):
    IJ.runMacro('makeRectangle(' + str(w * i) + ', ' + str(h * j) + ', ' +
                str(w) + ', ' + str(h) + ');')
    if i == currentX and j == currentY:
        color = 'orange'
    elif (i + j) & 1 == 1:
        color = 'black'
    else:
        color = 'white'
    setColor(color)
    IJ.run('Fill')
コード例 #14
0
def straighten_with_centerpoints(roiWindowsize = 4):
    """ Failed straightening method utilizing ROI rotation. """
    IJ.run("Set Measurements...", "mean min center redirect=None decimal=3")
    IJ.runMacro("//setTool(\"freeline\");")
    IJ.run("Line Width...", "line=80");
    numPoints = 512/(roiWindowsize)
    xvals = []
    yvals = []
    maxvals = []

    imp = IJ.getImage().getProcessor()

    for i in range(0, 512, roiWindowsize):
        topLeft = find_first_pixel(i, imp)
        bottomLeft = find_last_pixel(i, imp)
        #print "topLeft:", topLeft, "bottomLeft:", bottomLeft
        #sleep(.2)

        if not topLeft == None and not bottomLeft == None:
            xvals.append(i)
            yvals.append((topLeft[1] + bottomLeft[1])/2)

        topRight = find_first_pixel(i + roiWindowsize, imp)
        bottomRight = find_last_pixel(i + roiWindowsize, imp)

        if not topRight == None and not bottomRight == None:
            xvals.append(i + roiWindowsize)
            yvals.append((topRight[1] + bottomRight[1])/2)

    coords = ""
    #print "xvals:", xvals
    #print "yvals:", yvals
    for i in range(len(xvals)-1):
        coords += str(xvals[i]) + ", " + str(yvals[i]) +", "
    coords += str(xvals[len(xvals)-1]) + ", " + str(yvals[len(xvals)-1])

    IJ.runMacro("makeLine("+coords+")")
    IJ.run("Straighten...", "line = 80")
コード例 #15
0
def straighten_with_centerpoints(roiWindowsize=4):
    """ Failed straightening method utilizing ROI rotation. """
    IJ.run("Set Measurements...", "mean min center redirect=None decimal=3")
    IJ.runMacro("//setTool(\"freeline\");")
    IJ.run("Line Width...", "line=80")
    numPoints = 512 / (roiWindowsize)
    xvals = []
    yvals = []
    maxvals = []

    imp = IJ.getImage().getProcessor()

    for i in range(0, 512, roiWindowsize):
        topLeft = find_first_pixel(i, imp)
        bottomLeft = find_last_pixel(i, imp)
        #print "topLeft:", topLeft, "bottomLeft:", bottomLeft
        #sleep(.2)

        if not topLeft == None and not bottomLeft == None:
            xvals.append(i)
            yvals.append((topLeft[1] + bottomLeft[1]) / 2)

        topRight = find_first_pixel(i + roiWindowsize, imp)
        bottomRight = find_last_pixel(i + roiWindowsize, imp)

        if not topRight == None and not bottomRight == None:
            xvals.append(i + roiWindowsize)
            yvals.append((topRight[1] + bottomRight[1]) / 2)

    coords = ""
    #print "xvals:", xvals
    #print "yvals:", yvals
    for i in range(len(xvals) - 1):
        coords += str(xvals[i]) + ", " + str(yvals[i]) + ", "
    coords += str(xvals[len(xvals) - 1]) + ", " + str(yvals[len(xvals) - 1])

    IJ.runMacro("makeLine(" + coords + ")")
    IJ.run("Straighten...", "line = 80")
コード例 #16
0
def showMessage(mssg):
    IJ.runMacro('showMessage("' + mssg + '")')
コード例 #17
0
def wait(msecs):
    IJ.runMacro('wait(' + str(msecs) + ')')
コード例 #18
0
def waitForUser(mssg):
    IJ.runMacro('waitForUser("' + mssg + '")')
コード例 #19
0
def import_and_straighten(imgDir):
    """
    Core function. Opens images in given directory in series and calls a straightening function.
    Thresholds using weka if stddev of pixel intensities is too high (bright field), otherwise uses
    histogram based segmentation.
    """
    targetWidth = 800 #adjustable
    make_directory(imgDir)
    index = "000000000"
    filename = imgDir + "/img_" + index + "__000.tif"
    if path.exists(filename):
        weka = Weka_segmentor(IJ.openImage(filename))
    while path.exists(filename):
        IJ.run("Set Measurements...", "mean standard min center redirect=None decimal=3")
        IJ.run("Clear Results")
        imp = IJ.openImage(filename)
        imp.show()
        IJ.run("Rotate 90 Degrees Left")
        IJ.run("Measure")
        table = RT.getResultsTable()
        stddev = RT.getValue(table, "StdDev", 0)

        if stddev < 20:
            segmented = weka.getThreshold(imp)
            segmented.show()
            IJ.run("8-bit")
            IJ.run("Invert")
            imp.close()
            imp = segmented

        else:
            IJ.run(imp, "Auto Threshold", "method=Li white") #threshold

        imp = preProcess_(imp)

        #straighten_roi_rotation()
        coords = run_straighten()

        newImp = IJ.getImage()
        """
        fs = FileSaver(newImp)
        fs.saveAsTiff(imgDir + "/straightened" + "/img_" + index + "__000-straight.tif")
        """

        IJ.run("Image Padder", "pad_right="+str(targetWidth - newImp.getWidth()))
        paddedImp = IJ.getImage()
        fs = FileSaver(paddedImp)
        fs.saveAsTiff(imgDir + "/binary" + "/img_" + index + "__000-padded.tif")

        IJ.runMacro("while (nImages>0) {selectImage(nImages);close();}")

        #use same centerline for original greyscale image
        imp = IJ.openImage(filename)
        imp.show()
        IJ.run("Rotate 90 Degrees Left")
        IJ.run("8-bit")
        IJ.runMacro("makeLine("+coords+")")
        IJ.run("Straighten...", "line = 80")
        newImp = IJ.getImage()
        IJ.run("Image Padder", "pad_right="+str(targetWidth - newImp.getWidth()))
        paddedImp = IJ.getImage()
        IJ.run("8-bit")
        fs = FileSaver(paddedImp)
        fs.saveAsTiff(imgDir + "/greyscale" + "/img_" + index + "__000-padded.tif")
        IJ.runMacro("while (nImages>0) {selectImage(nImages);close();}")

        index = to_9_Digits(str(int(index)+1))
        filename = filename = imgDir + "/img_" + index + "__000.tif"
コード例 #20
0
The parameters "Seed Dynamics", "Intensity threshold" and "peak flooding" can be made optional

function Signature
	resultImage = op.run("H_Watershed", inputImage, hMin, threshold, peakFlooding, outputMask, allowSplitting)
	
All parameters beyond inputImage are optional. They can be replaced by null or if at the end of the
list they can be remove completely. If the parameter is detected as missing a sensible default is used

hMin = 5(max-min)/100
threshold = min
peakflooding = 100
outputMask = False (default is to output a label image)
allowsplitting = True (default is to allow threshold to create new peaks)
"""

IJ.runMacro("close(\"\\\\Others\")")

hMin = 0
thresh = 100
peakFlooding = 50

result0 = ops.run("H_Watershed", imp)

result1 = ops.run("H_Watershed", imp, hMin)

result2 = ops.run("H_Watershed", imp, hMin, thresh)

outputMask = True
allowSplit = False
result3 = ops.run("H_Watershed", imp, hMin, thresh, peakFlooding, outputMask,
                  allowSplit)
コード例 #21
0
ファイル: Myxo_Track.py プロジェクト: leec13/MorphoBactPy
#imprgb=ImagePlus("rgbStack", rgbstack)
#imprgb.show()
#IJ.selectWindow("rgbStack")
#IJ.run("Hide Overlay", "")


imp.show()
IJ.selectWindow(imp.getTitle())
imp.setOverlay(overlay)
IJ.run("Show Overlay", "")


for i in range(len(cles)) :
	pos=dicPos[cles[i]]
	command = 'Overlay.drawString("'+cles[i]+'", '+str(pos[0][0])+', '+str(pos[0][1])+')'
	IJ.runMacro(command)


f2 = open(rootdir+now+"-R2-MT.txt", "w")
f3 = open(rootdir+now+"-R3-MT.txt", "w")
f4 = open(rootdir+now+"-R4-MT.txt", "w")

tab="\t"

line2 = ["sens"+cle+tab+"speed"+cle+tab+"cumul"+cle+tab+"fluoA"+cle+tab+"fluoB"+cle for cle in cles]
line3 = ["scalA"+cle+tab+"scalB"+cle+tab+"oriX"+cle+tab+"oriY"+cle for cle in cles]
line4 = ["midaxis"+cle+tab+"Feret"+cle+tab+"fluoA"+cle+tab+"fluoB"+cle for cle in cles]

f2.write(tab.join(line2)+"\n")
f3.write(tab.join(line3)+"\n")
f4.write(tab.join(line4)+"\n")
コード例 #22
0
 def translate_(self, dx, dy):
     IJ.runMacro("roiManager(\"translate\", " + str(dx) + ", " + str(dy) +
                 ")")
     self.center = (self.center[0] + dx, self.center[1] + dy)
コード例 #23
0
def selectWindow(name):
    IJ.runMacro('selectWindow("' + name + '")')
コード例 #24
0
ファイル: close_others.py プロジェクト: zvtrung/tips
def close_others():
    IJ.runMacro("close(\"\\\\Others\")")
コード例 #25
0
ファイル: test_3d.py プロジェクト: fiji/fiji-historical
from ij import IJ, ImageJ

ImageJ()
IJ.run("MRI Stack (528K)")
IJ.runMacro("setVoxelSize(1, 1, 4, 'mm')")
IJ.run("3D Viewer",
       "display=Volume color=None threshold=0 resampling=1 red green blue")
コード例 #26
0
def close():
    IJ.runMacro("close()")
コード例 #27
0
 def unrotateRoot_(self):  # dTheta):
     IJ.runMacro("run(\"Rotate...\",\"  angle=" + str((-1) * self.dTheta) +
                 "\");")
コード例 #28
0
def import_and_straighten(imgDir):
    """
    Core function. Opens images in given directory in series and calls a straightening function.
    Thresholds using weka if stddev of pixel intensities is too high (bright field), otherwise uses
    histogram based segmentation.
    """
    targetWidth = 800  #adjustable
    make_directory(imgDir)
    index = "000000000"
    filename = imgDir + "/img_" + index + "__000.tif"
    if path.exists(filename):
        weka = Weka_segmentor(IJ.openImage(filename))
    while path.exists(filename):
        IJ.run("Set Measurements...",
               "mean standard min center redirect=None decimal=3")
        IJ.run("Clear Results")
        imp = IJ.openImage(filename)
        imp.show()
        IJ.run("Rotate 90 Degrees Left")
        IJ.run("Measure")
        table = RT.getResultsTable()
        stddev = RT.getValue(table, "StdDev", 0)

        if stddev < 20:
            segmented = weka.getThreshold(imp)
            segmented.show()
            IJ.run("8-bit")
            IJ.run("Invert")
            imp.close()
            imp = segmented

        else:
            IJ.run(imp, "Auto Threshold", "method=Li white")  #threshold

        imp = preProcess_(imp)

        #straighten_roi_rotation()
        coords = run_straighten()

        newImp = IJ.getImage()
        """
        fs = FileSaver(newImp)
        fs.saveAsTiff(imgDir + "/straightened" + "/img_" + index + "__000-straight.tif")
        """

        IJ.run("Image Padder",
               "pad_right=" + str(targetWidth - newImp.getWidth()))
        paddedImp = IJ.getImage()
        fs = FileSaver(paddedImp)
        fs.saveAsTiff(imgDir + "/binary" + "/img_" + index +
                      "__000-padded.tif")

        IJ.runMacro("while (nImages>0) {selectImage(nImages);close();}")

        #use same centerline for original greyscale image
        imp = IJ.openImage(filename)
        imp.show()
        IJ.run("Rotate 90 Degrees Left")
        IJ.run("8-bit")
        IJ.runMacro("makeLine(" + coords + ")")
        IJ.run("Straighten...", "line = 80")
        newImp = IJ.getImage()
        IJ.run("Image Padder",
               "pad_right=" + str(targetWidth - newImp.getWidth()))
        paddedImp = IJ.getImage()
        IJ.run("8-bit")
        fs = FileSaver(paddedImp)
        fs.saveAsTiff(imgDir + "/greyscale" + "/img_" + index +
                      "__000-padded.tif")
        IJ.runMacro("while (nImages>0) {selectImage(nImages);close();}")

        index = to_9_Digits(str(int(index) + 1))
        filename = filename = imgDir + "/img_" + index + "__000.tif"
コード例 #29
0
def straighten_roi_rotation(roiWindowsize=8):
    """ Root straightening function that rotates ROI to follow root slope.
    Does not work properly.
    """
    IJ.run("Set Measurements...",
           "mean standard min center redirect=None decimal=3")
    IJ.runMacro("//setTool(\"freeline\");")
    IJ.run("Line Width...", "line=80")
    #numPoints = 512/roiWindowsize
    xvals = []
    yvals = []
    maxvals = []
    counter = 0
    maxIters = 800 / roiWindowsize
    minIters = 10

    imp = IJ.getImage().getProcessor()

    rm = RoiManager()
    if find_first_pixel(0, imp) == None or find_last_pixel(0, imp)[1] == None:
        return
    y = (find_first_pixel(0, imp)[1] + find_last_pixel(0, imp)[1]) / 2
    roi = roiWindow_(imp,
                     center=(roiWindowsize / 2, y),
                     width=roiWindowsize,
                     height=512)
    xvals.append(roiWindowsize / 2)
    yvals.append(y)
    maxvals.append(0)
    roi.findTilt_()
    i = 0
    while i < maxIters and roi.containsRoot_():
        roi.advance_(roiWindowsize)
        IJ.run("Clear Results")
        IJ.run("Measure")
        table = RT.getResultsTable()

        x = RT.getValue(table, "XM", 0)
        y = RT.getValue(table, "YM", 0)
        if imp.getPixel(int(x), int(y)) != 0:
            xvals.append(x)
            yvals.append(y)
            maxvals.append((RT.getValue(table, "Max", 0)))

    #roi.advance_(roiWindowsize)
        print "here"
        roi.unrotateRoot_()
        IJ.run("Clear Results")
        IJ.run("Measure")
        roi.restoreCenter_(RT.getValue(table, "XM", 0),
                           RT.getValue(table, "YM", 0))
        #exit(1)
        sleep(.5)
        roi.findTilt_()
        i += 1
    coords = ""
    for i in range(len(xvals) - 1):
        coords += str(xvals[i]) + ", " + str(yvals[i]) + ", "
    coords += str(xvals[len(xvals) - 1]) + ", " + str(yvals[len(xvals) - 1])

    IJ.runMacro("makeLine(" + coords + ")")
    IJ.run("Straighten...", "line = 80")
コード例 #30
0
def main_interactive():
    """The main routine for running interactively."""
    log.info('Running in interactive mode.')
    (base, fname) = ui_get_input_file()
    if (base is None):
        return
    log.warn("Parsing project file: %s" % (base + fname))
    IJ.showStatus("Parsing experiment file...")
    mosaics = fv.FluoViewMosaic(join(base, fname), runparser=False)
    IJ.showStatus("Parsing mosaics...")
    progress = 0.0
    count = len(mosaics.mosaictrees)
    step = 1.0 / count
    for subtree in mosaics.mosaictrees:
        IJ.showProgress(progress)
        mosaics.add_mosaic(subtree)
        progress += step
    IJ.showProgress(progress)
    IJ.showStatus("Parsed %i mosaics." % len(mosaics))
    dialog = GenericDialog('FluoView OIF / OIB Stitcher')
    if len(mosaics) == 0:
        msg = ("Couldn't find any (valid) mosaics in the project file.\n"
               " \n"
               "Please make sure to have all files available!\n"
               " \n"
               "Will stop now.\n")
        log.warn(msg)
        dialog.addMessage(msg)
        dialog.showDialog()
        return
    msg = "------------------------ EXPORT OPTIONS ------------------------"
    dialog.addMessage(msg)
    formats = ["OME-TIFF", "ICS/IDS"]
    dialog.addChoice("Export Format", formats, formats[0])
    dialog.addCheckbox("separate files by Z slices (OME-TIFF only)?", False)
    msg = "------------------------ EXPORT OPTIONS ------------------------"
    dialog.addMessage(msg)
    dialog.addMessage("")
    dialog.addMessage("")
    msg = gen_mosaic_details(mosaics)
    log.warn(msg)
    msg += "\n \nPress [OK] to write tile configuration files\n"
    msg += "and continue with running the stitcher."
    dialog.addMessage(msg)
    dialog.showDialog()

    opts = {}
    if dialog.getNextChoice() == 'ICS/IDS':
        opts['export_format'] = '".ids"'
    else:
        opts['export_format'] = '".ome.tif"'
        if dialog.getNextBoolean() == True:
            opts['split_z_slices'] = 'true'
    code = imagej.gen_stitching_macro_code(mosaics, 'templates/stitching',
                                           path=base, tplpath=imcftpl, opts=opts)
    log.warn("============= generated macro code =============")
    log.warn(flatten(code))
    log.warn("============= end of generated  macro code =============")

    if dialog.wasOKed():
        log.warn('Writing stitching macro.')
        imagej.write_stitching_macro(code, fname='stitch_all.ijm', dname=base)
        log.warn('Writing tile configuration files.')
        imagej.write_all_tile_configs(mosaics, fixsep=True)
        log.warn('Launching stitching macro.')
        IJ.runMacro(flatten(code))
コード例 #31
0
 def rotate_(self):  # dTheta):
     IJ.runMacro("run(\"Rotate...\",\"  angle=" + str(self.dTheta) + "\");")
コード例 #32
0
def selectionType(named=False):
    i = int(IJ.runMacro("return toString(selectionType());"))
    if not named:
        return i
    else:
        return SELECTION_TYPES[i]
コード例 #33
0
ファイル: chess_.py プロジェクト: Mverp/fiji
def drawCoord(coord, array, color):
    (i, j) = parseCoord(coord)
    draw(i, j, array, color)


def erase():
    i = WindowManager.getImageCount()
    while i > 0:
        WindowManager.getImage(WindowManager.getNthImageID(i)).close()
        i = i - 1


erase()

IJ.runMacro('newImage("Chess", "RGB", ' + str(w * 8) + ", " + str(h * 8) + ", 1);")


def initial_field():
    return [
        "Rb",
        "Nb",
        "Bb",
        "Qb",
        "Kb",
        "Bb",
        "Nb",
        "Rb",
        "Pb",
        "Pb",
        "Pb",
コード例 #34
0
def rename(newname):
    IJ.runMacro('rename("' + newname + '")')
コード例 #35
0
from ij import IJ, Menus

from java.lang import System, Thread

from os import makedirs, rename, stat

from os.path import exists, isdir

from sys import stderr

from time import sleep

import urllib

# force initialization
IJ.runMacro("", "")

menu = User_Plugins.getMenuItem('File>Open Samples')
commands = Menus.getCommands()
plugin = 'ij.plugin.URLOpener("'
samples = System.getProperty('ij.dir') + '/samples'


class FileSizeReporter(Thread):
    def __init__(self, name, path):
        self.name = name
        self.path = path
        self.canceled = False

    def run(self):
        while self.canceled == False:
コード例 #36
0
from ij import IJ, Menus

from java.lang import System, Thread

from os import makedirs, rename, stat

from os.path import exists, isdir

from sys import stderr

from time import sleep

import urllib

# force initialization
IJ.runMacro("", "")

menu = User_Plugins.getMenuItem('File>Open Samples')
commands = Menus.getCommands()
plugin = 'ij.plugin.URLOpener("'
samples = System.getProperty('fiji.dir') + '/samples'

class FileSizeReporter(Thread):
	def __init__(self, name, path):
		self.name = name
		self.path = path
		self.canceled = False

	def run(self):
		while self.canceled == False:
			if exists(self.path):
コード例 #37
0
 def translate_(self, dx, dy):
     IJ.runMacro("roiManager(\"translate\", " +str(dx) + ", " + str(dy) + ")")
     self.center = (self.center[0] + dx, self.center[1] +dy)
コード例 #38
0
def drawCoord(coord, array, color):
    (i, j) = parseCoord(coord)
    draw(i, j, array, color)


def erase():
    i = WindowManager.getImageCount()
    while i > 0:
        WindowManager.getImage(WindowManager.getNthImageID(i)).close()
        i = i - 1


erase()

IJ.runMacro('newImage("Chess", "RGB", ' + str(w * 8) + ', ' + str(h * 8) +
            ', 1);')


def initial_field():
    return [
        'Rb', 'Nb', 'Bb', 'Qb', 'Kb', 'Bb', 'Nb', 'Rb', 'Pb', 'Pb', 'Pb', 'Pb',
        'Pb', 'Pb', 'Pb', 'Pb', '', '', '', '', '', '', '', '', '', '', '', '',
        '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
        '', '', 'Pw', 'Pw', 'Pw', 'Pw', 'Pw', 'Pw', 'Pw', 'Pw', 'Rw', 'Nw',
        'Bw', 'Qw', 'Kw', 'Bw', 'Nw', 'Rw'
    ]


def get_array(name):
    if name == 'P':
        return Pawn
コード例 #39
0
 def rotate_(self): # dTheta):
     IJ.runMacro("run(\"Rotate...\",\"  angle=" +str(self.dTheta)+"\");")
コード例 #40
0
print(sys.path)
# extend the search path by $FIJI_ROOT/bin/
path.append('/home/ehrenfeu/.local/lib/python2.7')
path.append('/home/ehrenfeu/.local/lib/python2.7/site-packages/volpy')
# path.append('C:\\Devel\\imcf_toolbox\\lib\\python2.7')
# path.append('C:\\Devel\\imcf_toolbox\\lib\\python2.7\\volpy')

import fluoview as fv
from log import log, set_loglevel

# set_loglevel(1)

infile = OpenDialog("Choose a 'MATL_Mosaic.log' file", '*.log')
print(infile.getDirectory())
print(infile.getFileName())

# dc = DirectoryChooser("Choose a directory with a 'MATL_Mosaic.log' file")
# base = dc.getDirectory()

mf = base + 'MATL_Mosaic.log'

mosaic = fv.FluoViewMosaic(mf)
mosaic.write_all_tile_configs(fixpath=True)
code = mosaic.gen_stitching_macro_code('stitching', base)
flat = ""
for line in code:
	flat += line

#print flat
IJ.runMacro(flat)
コード例 #41
0
    def unrotateRoot_(self): # dTheta):
		IJ.runMacro("run(\"Rotate...\",\"  angle=" +str((-1)*self.dTheta)+"\");")