本文整理汇总了Python中ij.measure.ResultsTable类的典型用法代码示例。如果您正苦于以下问题:Python ResultsTable类的具体用法?Python ResultsTable怎么用?Python ResultsTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ResultsTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: anaParticles
def anaParticles(imp, minSize, maxSize, minCirc, bHeadless=True):
"""anaParticles(imp, minSize, maxSize, minCirc, bHeadless=True)
Analyze particles using a watershed separation. If headless=True, we cannot
redirect the intensity measurement to the original immage becuae it is never
displayed. If we display the original, we can and get the mean gray level. We
may then compute the particle contrast from the measured Izero value for the image.
No ability here to draw outlines on the original."""
strName = imp.getShortTitle()
imp.setTitle("original")
ret = imp.duplicate()
IJ.run(ret, "Enhance Contrast", "saturated=0.35")
IJ.run(ret, "8-bit", "")
IJ.run(ret, "Threshold", "method=Default white")
IJ.run(ret, "Watershed", "")
rt = ResultsTable()
# strSetMeas = "area mean modal min center perimeter bounding fit shape feret's redirect='original' decimal=3"
# N.B. redirect will not work without a displayed image, so we cannot use a gray level image
if bHeadless == True:
strSetMeas = "area mean modal min center perimeter bounding fit shape feret's decimal=3"
else:
imp.show()
strSetMeas = "area mean modal min center perimeter bounding fit shape feret's redirect='original' decimal=3"
IJ.run("Set Measurements...", strSetMeas)
# note this doies not get passed directly to ParticleAnalyzer, so
# I did this, saved everything and looked for the measurement value in ~/Library/Preferences/IJ_Prefs.txt
# measurements=27355
# meas = Measurements.AREA + Measurements.CIRCULARITY + Measurements.PERIMETER + Measurements.SHAPE_DESCRIPTORS
# didn't work reliably
meas = 27355
pa = ParticleAnalyzer(0, meas, rt, minSize, maxSize, minCirc, 1.0);
pa.analyze(ret);
rt.createTableFromImage(ret.getProcessor())
return [ret, rt]
示例2: containsRoot_
def containsRoot_(self):
IJ.run("Clear Results")
IJ.run("Measure")
table = RT.getResultsTable()
if RT.getValue(table, "Max", 0) == 0:
return False
return True
示例3: run_straighten
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
示例4: measure_growth
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()
示例5: new_Table
def new_Table():
"""Creates a new ResultsTable padded with float("nan"), ie, all
empty cells will be filled with Java's String.valueOf(Double.NaN)
"""
new_rt = RT()
new_rt.setNaNEmptyCells(True);
new_rt.showRowNumbers(False);
return new_rt
示例6: writeCSV
def writeCSV(filePath, results, header):
""" Write a table as an csv file """
rt = ResultsTable()
for i in range(len(results[1])):
rt.incrementCounter()
for j in range(len(results)):
rt.addValue(str(header[j]), results[j][i])
rt.show("Results")
rt.saveAs(filePath);
示例7: measure
def measure(self):
imp = IJ.openImage(self.filename)
IJ.log("Input file: %s" % self.filename)
ImageConverter(imp).convertToGray8()
res = Auto_Threshold().exec(imp, self.myMethod, self.noWhite, self.noBlack, self.doIwhite, self.doIset, self.doIlog, self.doIstackHistogram)
rt = ResultsTable()
rt.showRowNumbers(False)
pa = PA(self.options, PA.AREA + PA.PERIMETER + PA.CIRCULARITY, rt, self.MINSIZE, self.MAXSIZE)
pa.analyze(imp)
self.result = self.rtToResult(rt)
self.mask = imp
示例8: __localwand
def __localwand(self, x, y, ip, seuil, method, light):
self.__image.killRoi()
ip.snapshot()
if method == "mean" :
peak=ip.getPixel(x,y)
tol = (peak - self.getMean())*seuil
w = Wand(ip)
w.autoOutline(x, y, tol, Wand.EIGHT_CONNECTED)
#print "method=", method, tol, peak
elif method == "background" :
radius = self.getMinF()/4
bs = BackgroundSubtracter()
#rollingBallBackground(ImageProcessor ip, double radius, boolean createBackground, boolean lightBackground, boolean useParaboloid, boolean doPresmooth, boolean correctCorners)
bs.rollingBallBackground(ip, radius, False, light, False, True, False)
peak=ip.getPixel(x,y)
tol = peak*seuil
w = Wand(ip)
w.autoOutline(x, y, tol, Wand.EIGHT_CONNECTED)
ip.reset()
#print "method=", method, tol, radius, peak
else :
peak=ip.getPixel(x,y)
tol = peak*seuil
w = Wand(ip)
w.autoOutline(x, y, tol, Wand.EIGHT_CONNECTED)
#print "method=", method, tol
peak=ip.getPixel(x,y)
temproi=PolygonRoi(w.xpoints, w.ypoints, w.npoints, PolygonRoi.POLYGON)
self.__image.setRoi(temproi)
#self.__image.show()
#time.sleep(1)
#peakip=self.__image.getProcessor()
#stats=peakip.getStatistics()
temprt = ResultsTable()
analyser = Analyzer(self.__image, Analyzer.AREA+Analyzer.INTEGRATED_DENSITY+Analyzer.FERET, temprt)
analyser.measure()
#temprt.show("temprt")
rtValues=temprt.getRowAsString(0).split("\t")
area=float(rtValues[1])
intDen=float(rtValues[4])
feret=float(rtValues[2])
mean=intDen/area
#time.sleep(2)
temprt.reset()
self.__image.killRoi()
return [peak, area, mean, intDen, feret]
示例9: __NbFoci
def __NbFoci(self):
self.__boolFoci=True
self.__image.killRoi()
self.__image.setRoi(self.__contour)
self.__ip=self.__image.getProcessor()
rt=ResultsTable.getResultsTable()
rt.reset()
mf=MaximumFinder()
mf.findMaxima(self.__ip, self.__noise, 0, MaximumFinder.LIST, True, False)
self.__listMax[:]=[]
#feret=self.getFercoord()
#xc=feret[0]-((feret[0]-feret[2])/2.0)
#yc=feret[1]-((feret[1]-feret[3])/2.0)
#print xc, yc
xc=self.getXC()
yc=self.getYC()
#print xc, yc
for i in range(rt.getCounter()):
x=int(rt.getValue("X", i))
y=int(rt.getValue("Y", i))
size=self.__localwand(x, y, self.__ip, self.__seuilPeaks, self.__peaksMethod, self.__light)
coord=[(1, xc, x), (1, yc, y)]
d=self.distMorph(coord,"Euclidean distance")
d=( d / (self.getMaxF()/2) )*100
self.__listMax.append((x, y, size[0], size[1], size[2], size[3], size[4], d))
rt.reset()
示例10: __Measures
def __Measures(self):
self.__boolmeasures=True
if (self.__contour is not None) and (self.__contour.getType() not in [9,10]):
self.__image.killRoi()
self.__image.setRoi(self.__contour)
self.__ip=self.__image.getProcessor()
self.__rt= ResultsTable()
analyser= Analyzer(self.__image, Analyzer.AREA+Analyzer.CENTER_OF_MASS+Analyzer.CENTROID+Analyzer.ELLIPSE+Analyzer.FERET+Analyzer.INTEGRATED_DENSITY+Analyzer.MEAN+Analyzer.KURTOSIS+Analyzer.SKEWNESS+Analyzer.MEDIAN+Analyzer.MIN_MAX+Analyzer.MODE+Analyzer.RECT+Analyzer.SHAPE_DESCRIPTORS+Analyzer.SLICE+Analyzer.STACK_POSITION+Analyzer.STD_DEV, self.__rt)
analyser.measure()
#self.__rt.show("myRT")
else:
self.__rt = ResultsTable()
analyser = Analyzer(self.__image, Analyzer.AREA+Analyzer.CENTER_OF_MASS+Analyzer.CENTROID+Analyzer.ELLIPSE+Analyzer.FERET+Analyzer.INTEGRATED_DENSITY+Analyzer.MEAN+Analyzer.KURTOSIS+Analyzer.SKEWNESS+Analyzer.MEDIAN+Analyzer.MIN_MAX+Analyzer.MODE+Analyzer.RECT+Analyzer.SHAPE_DESCRIPTORS+Analyzer.SLICE+Analyzer.STACK_POSITION+Analyzer.STD_DEV, self.__rt)
analyser.measure()
#self.__rt.show("myRT")
maxValues=self.__rt.getRowAsString(0).split("\t")
heads=self.__rt.getColumnHeadings().split("\t")
for val in heads: self.__rt.setValue(val, 0, Float.NaN)
示例11: measureSkeletonTotalLength
def measureSkeletonTotalLength(imp, root):
IJ.run(imp,"Analyze Skeleton (2D/3D)", "prune=none")
totalLength = 0
nBranches = 0
rt = ResultsTable.getResultsTable()
avgLengths = rt.getColumn(rt.getColumnIndex("Average Branch Length"))
for i in range(len(avgLengths)):
totalLength = totalLength + rt.getValue("# Branches", i) * rt.getValue("Average Branch Length", i)
nBranches = nBranches + rt.getValue("# Branches", i)
print root,",",imp.getTitle(),",",totalLength,",",nBranches
示例12: countParticles
def countParticles(imp, roim, minSize, maxSize, minCircularity, maxCircularity):
# Create a table to store the results
table = ResultsTable()
# Create the particle analyzer
pa = ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER, Measurements.AREA|Measurements.MEAN, table, minSize, maxSize, minCircularity, maxCircularity)
#pa = ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER, Measurements.AREA|Measurements.MEAN, table, 10, Double.POSITIVE_INFINITY, 0.5, 1.0)
#pa = ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER, Measurements.AREA|Measurements.MEAN, table, 5, 6, 0.5, 1.0)
pa.setRoiManager(roim)
pa.setHideOutputImage(True)
if pa.analyze(imp):
print "All ok"
else:
print "There was a problem in analyzing", blobs
areas = table.getColumn(0)
intensities = table.getColumn(1)
if ( (areas!=None) and (intensities!=None)):
for area, intensity in zip(areas,intensities): print str(area)+": "+str(intensity)
示例13: getParticleCenters
def getParticleCenters(imp):
# Create a table to store the results
rt = ResultsTable()
paOpts = PA.SHOW_OUTLINES \
+ PA.INCLUDE_HOLES \
+ PA.EXCLUDE_EDGE_PARTICLES
measurements = PA.CENTROID + PA.CENTER_OF_MASS
MINSIZE = 1000
MAXSIZE = Double.POSITIVE_INFINITY
pa = PA(paOpts,measurements, rt, MINSIZE, MAXSIZE)
pa.setHideOutputImage(True)
if not pa.analyze(imp):
print "There was a problem in analyzing", imp
# The measured centroids are listed in the first column of the results table, as a float array:
centroids_x = rt.getColumn(rt.X_CENTROID)
centroids_y = rt.getColumn(rt.Y_CENTROID)
coms_x = rt.getColumn(rt.X_CENTER_OF_MASS)
coms_y = rt.getColumn(rt.Y_CENTER_OF_MASS)
return (centroids_x,centroids_y, coms_x, coms_y)
示例14: __init__
def __init__(self):
self.imp = None
self.preview = None
self.createMainWindow()
self.cells = None
self.files = []
self.results = ResultsTable()
ImagePlus.addImageListener(self)
self.selectInputDir()
self.selectOutputDir()
self.pairs = []
self.methods = []
self.processNextFile()
示例15: straighten_roi_rotation
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")