本文整理汇总了Python中ij.measure.ResultsTable.getResultsTable方法的典型用法代码示例。如果您正苦于以下问题:Python ResultsTable.getResultsTable方法的具体用法?Python ResultsTable.getResultsTable怎么用?Python ResultsTable.getResultsTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.measure.ResultsTable
的用法示例。
在下文中一共展示了ResultsTable.getResultsTable方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: containsRoot_
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
def containsRoot_(self):
IJ.run("Clear Results")
IJ.run("Measure")
table = RT.getResultsTable()
if RT.getValue(table, "Max", 0) == 0:
return False
return True
示例2: run_straighten
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
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: __NbFoci
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
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()
示例4: measure_growth
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
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: straighten_roi_rotation
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
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")
示例6: measureSkeletonTotalLength
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
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
示例7: analyse
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
def analyse(imp, root, filename, thresholds):
closeAllImageWindows()
imp.show()
print ""
print(imp.getTitle())
print "**********************************"
IJ.run("Set Measurements...", "integrated redirect=None decimal=2");
# get image calibration info
IJ.run(imp, "Properties...", "unit=pixel pixel_width=1 pixel_height=1");
# convert to 8-bit
IJ.setMinAndMax(imp, 0, 65535);
IJ.run(imp, "8-bit", "");
thresholds = [(x / 65535 * 255) for x in thresholds]
# Nuclei
#closeAllNoneImageWindows()
iChannel = 1
imp.setSlice(iChannel)
IJ.run(imp, "Gaussian Blur...", "sigma=2 slice");
IJ.setThreshold(imp, thresholds[iChannel-1], 1000000000)
IJ.run(imp, "Convert to Mask", "method=Default background=Dark only black");
IJ.run(imp, "Measure", "");
rt = ResultsTable.getResultsTable()
values = rt.getColumnAsDoubles(rt.getColumnIndex("RawIntDen"))
print("Area Nuclei (pixel^2) =",values[-1]/255)
# Dots
#closeAllNoneImageWindows()
iChannel = 3
imp.setSlice(iChannel)
IJ.run(imp, "Gaussian Blur...", "sigma=1 slice");
IJ.run(imp, "Find Maxima...", "noise="+str(thresholds[iChannel-1])+" output=Count");
rt = ResultsTable.getResultsTable()
values = rt.getColumnAsDoubles(rt.getColumnIndex("Count"))
print("Number of Dots =",values[-1])
示例8: process
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
def process(srcDir, currentDir, fileName):
image = IJ.openImage(os.path.join(currentDir, fileName))
IJ.run("Clear Results")
#set lowerbound threshold here
IJ.setThreshold(image, 200, 10000)
# Change (1,25) below to (1,n+1) where n is the number of frames
for slice in range(1,(image.getNSlices()+1),1):
image.setSlice(slice)
IJ.run(image, "Select All", "")
IJ.run(image, "Measure", "")
rt = ResultsTable.getResultsTable()
# this line calculates the baseline
baseline = (rt.getValue("IntDen",1) + rt.getValue("IntDen",2) + rt.getValue("IntDen",3))/3.0
for result in range(0,rt.getCounter()):
cur_intensity = rt.getValue("IntDen",result)
ratio = cur_intensity/baseline
rt.setValue("RawIntDen",result,ratio)
rt.updateResults()
image.close()
示例9: run
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
def run():
srcDir = srcFile.getAbsolutePath()
IJ.run("Set Measurements...", "integrated limit redirect=None decimal=3")
for dirName, subdirs, filenames in os.walk(srcDir):
if len(subdirs)==0:
finalResults = []
for filename in filenames:
# Check for file extension
if not filename.endswith(ext):
continue
process(srcDir, dirName, filename)
rt = ResultsTable.getResultsTable()
colRaw = rt.getColumnIndex("IntDen")
colRatio = rt.getColumnIndex("RawIntDen")
finalResults.append(rt.getColumn(colRaw))
finalResults.append(rt.getColumn(colRatio))
with open(os.path.join(dirName, dirName+'.csv'), 'wb') as csvfile:
writer = csv.writer(csvfile, delimiter=",")
for row in zip(*finalResults):
writer.writerow(row)
示例10: run_comdet
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
def run_comdet(image):
IJ.run(image,"Detect Particles", " two=[Detect in both channels independently] ch1a="+str(ch1size) + " ch1s=" + str(ch1thresh) + " ch2a="+str(ch2size) + " ch2s=" + str(ch2thresh) + " calculate max=" + str(coloc) + " add=Nothing")
rt = ResultsTable.getResultsTable()
return rt
示例11: range
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
options = "radius=%d cutoff=%d percentile=%f" % (radius, cutoff, percentile)
thread = thr.currentThread()
original_name = thread.getName()
thread.setName("Run$_my_batch_process")
Macro.setOptions(thr.currentThread(), options)
pt = IJ.runPlugIn(imp, "de.embl.cmci.pt3d.Dot_Detector_3D", "")
impdimA = imp.getDimensions()
ims = imp.createEmptyStack()
for i in range(impdimA[3]):
ims.addSlice(None, ByteProcessor(impdimA[0], impdimA[1]))
imp2 = ImagePlus("test", ims)
nSlices = imp2.getNSlices()
rt = ResultsTable.getResultsTable()
xindex = rt.getColumnIndex("x")
yindex = rt.getColumnIndex("y")
zindex = rt.getColumnIndex("z")
xA = rt.getColumn(xindex)
yA = rt.getColumn(yindex)
zA = rt.getColumn(zindex)
neighbornumA = NeighborChecker(xA, yA, zA, True)
for i in range(len(xA)):
print xA[i], yA[i], zA[i], " .. Neighbor", neighbornumA[i]
# if xA[i] > 0:
if neighbornumA[i] == 0:
cslice=Math.round(zA[i])+1
if cslice > 0 and cslice <= nSlices:
示例12: coordinates
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
# IJ BAR snippet https://github.com/tferr/Scripts/tree/master/Snippets
#
# Calculates the closest pair of points from a 2D/3D list of centroid coordinates (opened in the IJ
# 'Results' table) calling another BAR script to plot the frequencies of nearest neighbor distances.
#
# TF 20150101
import math, sys
from ij import IJ, Menus
import ij.measure.ResultsTable as RT
# Specify column headings listing x,y,z positions
xHeading, yHeading, zHeading = "X", "Y", "Z"
# Retrieve Results Table
rt = RT.getResultsTable()
# Retrive x,y positions
try:
x = rt.getColumn(rt.getColumnIndex(xHeading))
y = rt.getColumn(rt.getColumnIndex(yHeading))
except:
x = y = None
if not None in (x, y):
# Retrive z positions. Ignore positions if column is not found
try:
z = rt.getColumn(rt.getColumnIndex(zHeading))
except:
IJ.log("Z-column not found: Assuming 2D distances...")
示例13: run
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
def run():
mask_ip = impSkel.getProcessor()
part_ip = impPart.getProcessor()
if not mask_ip.isBinary():
error(impSkel.getTitle() + " is not a binary mask.")
return
# Mask grayscale image and skeletonize mask
try:
mask_pixels = mask_ip.getPixels()
part_pixels = part_ip.getPixels()
for i in xrange(len(part_pixels)):
if mask_pixels[i] == 0:
part_pixels[i] = 0
part_ip.setPixels(part_pixels)
except IndexError:
error("Chosen images are not the same size.")
skeletonize(impSkel)
# Get skeleton features
end_points, junctions, junction_voxels, total_len = skeleton_properties(impSkel)
if not end_points and not junction_voxels:
error(impSkel.getTitle() + " does not seem a valid skeleton.")
return
# Retrieve centroids from IJ1
threshold_lower = get_threshold(impPart, thres_method)
cx, cy, n_particles = get_centroids(impPart, threshold_lower)
if None in (cx, cy):
error("Verify parameters: No particles detected.")
return
# Loop through each centroids and categorize its position
# according to its distance to skeleton features
n_bp = n_tip = n_none = n_both = 0
overlay = cleanse_overlay(impPart.getOverlay())
for i in range(n_particles):
j_dist = ep_dist = sys.maxint
# Retrieve the distance between this particle and the closest junction voxel
for jvoxel in junction_voxels:
dist = distance(cx[i], cy[i], jvoxel.x, jvoxel.y)
if (dist <= cutoff_dist and dist < j_dist):
j_dist = dist
# Retrieve the distance between this particle and the closest end-point
for end_point in end_points:
dist = distance(cx[i], cy[i], end_point.x, end_point.y)
if (dist <= cutoff_dist and dist < ep_dist):
ep_dist = dist
roi_id = str(i).zfill(len(str(n_particles)))
roi_name = "Unknown:" + roi_id
roi_color = Color.ORANGE
roi_type = 2 # dot
# Is particle associated with neither junctions nor end-points?
if j_dist > cutoff_dist and ep_dist > cutoff_dist:
roi_name = "Unc:" + roi_id
#n_none += 1
# Is particle associated with both?
elif abs(j_dist - ep_dist) <= pixel_size(impPart) / 2:
roi_name = "J+T:" + roi_id
roi_color = Color.CYAN
#roi_type = 1 # crosshair
n_both += 1
# Is particle associated with an end-point?
elif ep_dist < j_dist:
roi_name = "Tip:" + roi_id
roi_color = Color.GREEN
#roi_type = 0 # hybrid
n_tip += 1
# Is particle associated with a junction?
elif ep_dist > j_dist:
roi_name = "Junction:" + roi_id
roi_color = Color.MAGENTA
#roi_type = 3 # circle
n_bp += 1
roi = PointRoi(cx[i], cy[i])
roi.setName(roi_name)
roi.setStrokeColor(roi_color)
roi.setPointType(roi_type)
roi.setSize(2) # medium
overlay.add(roi)
# Display result
impSkel.setOverlay(overlay)
impPart.setOverlay(overlay)
# Output some measurements
if "table" in output:
t = ResultsTable.getResultsTable() if "IJ1" in output else DefaultGenericTable()
addToTable(t, "Part. image", "%s (%s)" % (impPart.getTitle(), impPart.getCalibration().getUnits()))
addToTable(t, "Skel. image", "%s (%s)" % (impSkel.getTitle(), impSkel.getCalibration().getUnits()))
#.........这里部分代码省略.........
示例14: import_and_straighten
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getResultsTable [as 别名]
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"