本文整理汇总了Python中ij.measure.ResultsTable.incrementCounter方法的典型用法代码示例。如果您正苦于以下问题:Python ResultsTable.incrementCounter方法的具体用法?Python ResultsTable.incrementCounter怎么用?Python ResultsTable.incrementCounter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.measure.ResultsTable
的用法示例。
在下文中一共展示了ResultsTable.incrementCounter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: writeCSV
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import incrementCounter [as 别名]
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);
示例2: MandersPlugin
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import incrementCounter [as 别名]
#.........这里部分代码省略.........
image = self.imp
mode3D = self.checkbox3D.isSelected()
if image is not None and cell is not None and mode3D:
roi = cell.slices[selectedSlice].roi
if (image.z - 1 != selectedSlice):
image.z = selectedSlice + 1
image.setRoi(roi, True)
if self.preview is not None and not mode3D:
self.preview.setRoi(cell.roi, True)
def updateSlice(self, event):
if self.checkbox3D.isSelected():
self.updateSlice3D(self.imp)
else:
self.updateSlice2D(self.preview)
def updateSlice3D(self, imp):
selectedCell = self.cellList.selectedIndex
selectedSlice = self.sliceList.selectedIndex
if selectedCell >= 0 and selectedSlice >= 0 and imp is not None:
cell = self.cells[selectedCell]
impRoi = imp.getRoi()
if cell is not None and impRoi is not None:
index = selectedSlice + 1
roi = ShapeRoi(impRoi, position = index)
cell.mode3D = True
cell.name = "Cell %i (3D)" % cell.n
cell.slices[selectedSlice].roi = roi
if (index + 1 <= len(cell.slices)):
imp.z = index + 1
self.cellList.repaint(self.cellList.getCellBounds(selectedCell, selectedCell))
self.sliceList.repaint(self.sliceList.getCellBounds(selectedSlice, selectedSlice))
def updateSlice2D(self, imp):
selectedCell = self.cellList.selectedIndex
if selectedCell >= 0 and imp is not None:
cell = self.cells[selectedCell]
impRoi = imp.getRoi()
if cell is not None and impRoi is not None:
roi = ShapeRoi(impRoi, position = 1)
cell.mode3D = False
cell.name = "Cell %i (2D)" % cell.n
cell.roi = roi
self.cellList.repaint(self.cellList.getCellBounds(selectedCell, selectedCell))
def imageOpened(self, imp):
pass
def imageClosed(self, imp):
pass
def imageUpdated(self, imp):
if self.checkbox3D.isSelected():
if imp is not None:
selectedCell = self.cellList.selectedIndex
selectedSlice = imp.z - 1
if imp == self.imp and selectedSlice != self.sliceList.selectedIndex:
self.sliceList.selectedIndex = selectedSlice
def doneSelecting(self, event):
oluts = self.imp.luts
luts = []
channels = []
for c, method in enumerate(self.methods):
if method != "None":
luts.append(oluts[c])
channels.append(c)
for cell in self.cells:
manders = self.getManders(self.imp, cell)
if manders is not None:
chimps, thrimps, thrs, raws, thrds = manders
index = self.cells.index(cell) + 1
title = "Cell_%i-" % index + self.imp.title
self.saveMultichannelImage(title, chimps, oluts)
title = "Cell_%i_thrd-" % index + self.imp.title
self.saveMultichannelImage(title, thrimps, luts)
self.results.incrementCounter()
row = self.results.getCounter() - 1
for i, thr in enumerate(thrs):
if thr is not None:
self.results.setValue("Threshold %i" % (i + 1), row, int(thr))
for i, pair in enumerate(self.pairs):
self.results.setValue("%i-%i M1 raw" % pair, row, float(raws[i].m1))
self.results.setValue("%i-%i M2 raw" % pair, row, float(raws[i].m2))
self.results.setValue("%i-%i M1 thrd" % pair, row, float(thrds[i].m1))
self.results.setValue("%i-%i M2 thrd" % pair, row, float(thrds[i].m2))
self.closeImage()
if not self.processNextFile():
print "All done - happy analysis!"
self.results.show("Manders collocalization results")
self.exit()
def windowClosing(self, e):
print "Closing plugin - BYE!!!"
self.exit()
def exit(self):
ImagePlus.removeImageListener(self)
self.closeImage()
self.closeMainWindow()
示例3: OvalRoi
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import incrementCounter [as 别名]
ipch3 = impch3.getImageStack().getProcessor(int(zA[i]) + 1)
dotRoi = OvalRoi(int(yA[i] - xyoffset), int(xA[i] - xyoffset), thdist, thdist)
ipch2.setRoi(dotRoi)
#stats = IS.getStatistics(ip, options, imp.getCalibration())
stats = IS.getStatistics(ipch2, options, cal)
ipch3.setRoi(dotRoi)
statsch3 = IS.getStatistics(ipch3, options, cal)
print "dot", i
print "...ch2 TotalInt ", stats.area * stats.mean
print "...ch2 Area ", stats.area
print "...ch2 mean ", stats.mean
print ".."
print "...ch3 TotalInt ", statsch3.area * statsch3.mean
print "...ch3 Area ", statsch3.area
print "...ch3 mean ", statsch3.mean
rt.incrementCounter()
rt.setValue("DotID", ct, i)
rt.setValue("DotX", ct, yA[i])
rt.setValue("DotY", ct, xA[i])
rt.setValue("DotZ", ct, zA[i])
rt.setValue("Ch2_TotalIntensity", ct, stats.area * stats.mean)
rt.setValue("Ch2_MeanIntensity", ct, stats.mean)
rt.setValue("Ch3_TotalIntensity", ct, statsch3.area * statsch3.mean)
rt.setValue("Ch3_meanIntensity", ct, statsch3.mean)
ct += 1
rt.show("Dot Intensity")
#AREA, AREA_FRACTION, CENTER_OF_MASS, CENTROID, CIRCULARITY, ELLIPSE, FERET,
#INTEGRATED_DENSITY, INVERT_Y, KURTOSIS, LABELS, LIMIT, MAX_STANDARDS, MEAN,
#MEDIAN, MIN_MAX, MODE, PERIMETER, RECT, SCIENTIFIC_NOTATION, SHAPE_DESCRIPTORS,
示例4: open_Octopus_file
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import incrementCounter [as 别名]
#.........这里部分代码省略.........
if targetfile:
filenums.append( int(targetfile.group(1)) )
# sort the file numbers
sorted_filenums = sorted(filenums)
# make a file stats string
file_stats_str = file_stem + '\n' + str(fi.width) +'x' + str(fi.height) + 'x' + \
str(len(sorted_filenums)) +' ('+str(bit_depth)+'-bit)\n' + file_timestamp
# now open a dialog to let the user set options
dlg = GenericDialog("Load Octopus Stream (v"+__version__+")")
dlg.addMessage(file_stats_str)
dlg.addStringField("Title: ", file_stem)
dlg.addNumericField("Start: ", 1, 0);
dlg.addNumericField("End: ", len(sorted_filenums), 0)
dlg.addCheckbox("Open headers", True)
dlg.addCheckbox("Contiguous stream?", False)
dlg.addCheckbox("8-bit unsigned", bit_depth==8)
dlg.showDialog()
# if we cancel the dialog, exit here
if dlg.wasCanceled():
return
# set some params
file_title = dlg.getNextString()
file_start = dlg.getNextNumber()
file_end = dlg.getNextNumber()
DISPLAY_HEADER = bool( dlg.getNextBoolean() )
# check the ranges
if file_start > file_end:
file_start, file_end = file_end, file_start
if file_start < 1:
file_start = 1
if file_end > len(sorted_filenums):
file_end = len(sorted_filenums)
# now set these to the actual file numbers in the stream
file_start = sorted_filenums[int(file_start)-1]
file_end = sorted_filenums[int(file_end)-1]
files_to_open = [n for n in sorted_filenums if n>=file_start and n<=file_end]
# if we've got too many, truncate the list
if (len(files_to_open) * fi.nImages * fi.width * fi.height) > (MAX_FRAMES_TO_IMPORT*512*512):
dlg = GenericDialog("Warning")
dlg.addMessage("This may use a lot of memory. Continue?")
dlg.showDialog()
if dlg.wasCanceled(): return False
IJ.log( "Opening file: " + op.getDirectory() + op.getFileName() )
IJ.log( file_stats_str + "\nFile range: " + str(files_to_open[0]) + \
"-" + str(files_to_open[-1]) +"\n" )
# make a results table for the metadata
# NOTE: horrible looping at the moment, but works
if DISPLAY_HEADER:
rt = ResultsTable()
# ok now we can put the files together into the stack
for i in files_to_open:
# open the original .dat file and get the stack
fi.fileName = get_Octopus_filename( op.getDirectory(), file_stem, i)
if os.path.isfile( fi.fileName ):
fo = FileOpener(fi)
imp = fo.open(False).getStack()
# put the slices into the stack
for im_slice in xrange( imp.getSize() ):
ip = imp.getProcessor( im_slice+1 )
if bit_depth == 8:
bi = ip.getBufferedImage()
else:
bi = ip.get16BitBufferedImage()
stack.addSlice( file_title, ip )
if DISPLAY_HEADER:
header = get_Octopus_header(op.getDirectory(), file_stem, i)
for n in xrange(len(header['N'])):
rt.incrementCounter()
for k in header.keys():
rt.addValue(k, parse_header( header[k][n] ) )
else:
break
# done!
output = ImagePlus('Octopus ('+file_stem+')', stack)
output.show()
if DISPLAY_HEADER:
rt.show("Octopus header metadata")
return True
示例5: calculateThreshold
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import incrementCounter [as 别名]
thr1, thrimp1 = calculateThreshold(imp1, roi, methods[0])
thr2, thrimp2 = calculateThreshold(imp2, roi, methods[1])
cursor = TwinCursor(img1.randomAccess(), img2.randomAccess(), Views.iterable(mask).localizingCursor())
rtype = img1.randomAccess().get().createVariable()
raw = manders.calculateMandersCorrelation(cursor, rtype)
rthr1 = rtype.copy()
rthr2 = rtype.copy()
rthr1.set(thr1)
rthr2.set(thr2)
cursor.reset()
thrd = manders.calculateMandersCorrelation(cursor, rthr1, rthr2, ThresholdMode.Above)
print "Results are: %f %f %f %f" % (raw.m1, raw.m2, thrd.m1, thrd.m2)
results.incrementCounter()
rowno = results.getCounter() - 1
results.setValue("Cell", rowno, int(rowno))
results.setValue("Threshold 1", rowno, int(thr1))
results.setValue("Threshold 2", rowno, int(thr2))
results.setValue("M1 raw", rowno, float(raw.m1))
results.setValue("M2 raw", rowno, float(raw.m2))
results.setValue("M1 thrd", rowno, float(thrd.m1))
results.setValue("M2 thrd", rowno, float(thrd.m2))
thrimp = RGBStackMerge.mergeChannels([thrimp1, thrimp2], False)
saver = FileSaver(thrimp)
saver.saveAsTiffStack(outputDir + "Cell_%i-" % results.getCounter() + title + ".tif")
thrimp.close()
results.show("Colocalization results")
示例6: run
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import incrementCounter [as 别名]
#.........这里部分代码省略.........
branch_lengths = []
summed_lengths = []
graphs = skel_result.getGraph()
for graph in graphs:
summed_length = 0.0
edges = graph.getEdges()
for edge in edges:
length = edge.getLength()
branch_lengths.append(length)
summed_length += length
summed_lengths.append(summed_length)
output_parameters["branch length mean"] = eztables.statistical.average(branch_lengths)
output_parameters["branch length median"] = eztables.statistical.median(branch_lengths)
output_parameters["branch length stdevp"] = eztables.statistical.stdevp(branch_lengths)
output_parameters["summed branch lengths mean"] = eztables.statistical.average(summed_lengths)
output_parameters["summed branch lengths median"] = eztables.statistical.median(summed_lengths)
output_parameters["summed branch lengths stdevp"] = eztables.statistical.stdevp(summed_lengths)
branches = list(skel_result.getBranches())
output_parameters["network branches mean"] = eztables.statistical.average(branches)
output_parameters["network branches median"] = eztables.statistical.median(branches)
output_parameters["network branches stdevp"] = eztables.statistical.stdevp(branches)
# Create/append results to a ResultsTable...
status.showStatus("Display results...")
if "Mito Morphology" in list(WindowManager.getNonImageTitles()):
rt = WindowManager.getWindow("Mito Morphology").getTextPanel().getOrCreateResultsTable()
else:
rt = ResultsTable()
rt.incrementCounter()
for key in output_order:
rt.addValue(key, str(output_parameters[key]))
# Add user comments intelligently
if user_comment != None and user_comment != "":
if "=" in user_comment:
comments = user_comment.split(",")
for comment in comments:
rt.addValue(comment.split("=")[0], comment.split("=")[1])
else:
rt.addValue("Comment", user_comment)
rt.show("Mito Morphology")
# Create overlays on the original ImagePlus and display them if 2D...
if imp.getNSlices() == 1:
status.showStatus("Generate overlays...")
IJ.run(skeleton, "Green", "")
IJ.run(binary, "Magenta", "")
skeleton_ROI = ImageRoi(0,0,skeleton.getProcessor())
skeleton_ROI.setZeroTransparent(True)
skeleton_ROI.setOpacity(1.0)
binary_ROI = ImageRoi(0,0,binary.getProcessor())
binary_ROI.setZeroTransparent(True)
binary_ROI.setOpacity(0.25)
overlay = Overlay()
overlay.add(binary_ROI)
overlay.add(skeleton_ROI)
imp.setOverlay(overlay)
示例7: ResultsTable
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import incrementCounter [as 别名]
resultsTable = ResultsTable()
resultsTable.showRowNumbers(False)
for i in range(0, len(results)):
if options['oneShot']:
localBackground = options['localBackground']
seedRadius = options['seedRadius']
gaussXY = options['gaussXY']
gaussZ = options['gaussZ']
else:
localBackground = parameters[i]['localBackground']
seedRadius = parameters[i]['seedRadius']
gaussXY = parameters[i]['gaussXY']
gaussZ = parameters[i]['gaussZ']
resultsTable.incrementCounter()
resultsTable.addValue("Threshold", localBackground)
resultsTable.addValue("Seed radius", seedRadius)
resultsTable.addValue("GXY", gaussXY)
resultsTable.addValue("GZ", gaussZ)
resultsTable.addValue("TOTAL", results[i]['all'])
resultsTable.addValue("0-250", results[i]['0'])
resultsTable.addValue("251-500", results[i]['250'])
resultsTable.addValue("501-750", results[i]['500'])
resultsTable.addValue("751-1000", results[i]['750'])
resultsTable.addValue("1001-1500", results[i]['1000'])
resultsTable.addValue(">1501", results[i]['1500'])
resultsTable.addValue("Skipped", results[i]['edge'])
resultsTable.save(options['outputDir'] + options['outputFile'])
示例8: main
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import incrementCounter [as 别名]
#.........这里部分代码省略.........
t_rows = rt.getColumnAsDoubles(t_col)
# Assess n of data points and extract unique path ids
n_rows = len(track_id_rows)
row_indices = range(n_rows)
track_ids = set(track_id_rows)
n_tracks = len(track_ids)
log("Table has %g rows" % n_rows)
log("Table has %g tracks" % n_tracks)
log("Parsing tracks...")
for track_id in track_ids:
for row, next_row in zip(row_indices, row_indices[1:]):
if track_id_rows[row] != track_id:
continue
if not isNumber(angle_rows[row]):
rt.setValue("FLAG", row, "NA")
continue
lower_bound = max(0, row - BOUT_WINDOW + 1)
upper_bound = min(n_rows-1, row + BOUT_WINDOW)
win_d2p = []
for _ in range(lower_bound, upper_bound):
win_d2p.append(d2p_rows[row])
if sum(win_d2p) <= MIN_D2P * len(win_d2p):
rt.setValue("FLAG", row, 0)
else:
current_angle = angle_rows[row]
next_angle = angle_rows[next_row]
current_delta = delta_rows[row]
flag = -1 if current_angle < 0 else 1
delta_change = (abs(current_delta) > 90)
same_sign = ((current_angle<0) == (next_angle<0))
if delta_change and not same_sign:
flag *= -1
rt.setValue("FLAG", row, flag)
if next_row == n_rows - 1:
rt.setValue("FLAG", next_row, flag)
if rt.save(table_file.getAbsolutePath()):
log("Processed table successfully saved (file overwritten)")
else:
log("Could not override input file. Displaying it...")
rt.show(table_file.name)
log("Creating onset table...")
onset_rt = RT()
onset_rt.showRowNumbers(False)
frame_int = DEF_FRAME_INTERVAL
if "table" in frame_rate_detection:
frame_int = getFrameIntervalFromTable(row_indices, track_id_rows, t_rows)
elif "image" in frame_rate_detection:
frame_int = getFrameIntervalFromImage(image_file.getAbsolutePath())
else:
log("Using default frame rate")
for track_id in track_ids:
for prev_row, row in zip(row_indices, row_indices[1:]):
if not track_id in (track_id_rows[prev_row], track_id_rows[row]):
continue
flag = rt.getValue("FLAG", row)
if not isNumber(flag):
continue
flag = int(flag)
if flag == 0:
continue
if flag == 1 or flag == -1:
srow = onset_rt.getCounter()
onset_rt.incrementCounter()
onset_rt.setValue("TID", srow, track_id)
from_frame = int(t_rows[prev_row]/frame_int) + 1
to_frame = int(t_rows[row]/frame_int) + 1
onset_rt.setValue("First disp. [t]", srow,
"%s to %s" % (t_rows[prev_row], t_rows[row]))
onset_rt.setValue("First disp. [frames]", srow,
"%s to %s" % (from_frame, to_frame))
onset_rt.setValue("ManualTag", srow, "")
break
out_path = suffixed_path(table_file.getAbsolutePath(), "ManualTagging")
if onset_rt.save(out_path):
log("Summary table successfully saved: %s" % out_path)
else:
log("File not saved... Displaying onset table")
onset_rt.show("Onsets %s" % table_file.name)