本文整理汇总了Python中ij.plugin.frame.RoiManager.moveRoisToOverlay方法的典型用法代码示例。如果您正苦于以下问题:Python RoiManager.moveRoisToOverlay方法的具体用法?Python RoiManager.moveRoisToOverlay怎么用?Python RoiManager.moveRoisToOverlay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.plugin.frame.RoiManager
的用法示例。
在下文中一共展示了RoiManager.moveRoisToOverlay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: segmentation
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import moveRoisToOverlay [as 别名]
def segmentation(imp, spot_data, channel, diameter_init, ES_tolerance, ES_area_max, ES_ctrl_pts, ES_iteration, repeat_max):
# Open files
cal = imp.getCalibration()
manager = RoiManager.getInstance()
if manager is None:
manager = RoiManager()
# Prepare log files for output
options = IS.MEDIAN | IS.AREA | IS.MIN_MAX | IS.CENTROID | IS.PERIMETER | IS.ELLIPSE | IS.SKEWNESS
convergence = []
Sintensity = []
for spot in spot_data:
repeat = 0
flag = False
spotID = int(spot[0])
Xcenter = (float(spot[1]) / cal.pixelWidth)
Ycenter = (float(spot[2]) / cal.pixelHeight)
Quality = float(spot[3])
diameter_init = float(spot[4] / cal.pixelWidth) * 2.0
while True:
manager = RoiManager.getInstance()
if manager is None:
manager = RoiManager()
Xcurrent = int(Xcenter - diameter_init / 2.0)
Ycurrent = int(Ycenter - diameter_init / 2.0)
Dcurrent1 = int(diameter_init * (1.2 - repeat / 10.0))
Dcurrent2 = int(diameter_init * (0.8 + repeat / 10.0))
roi = OvalRoi(Xcurrent, Ycurrent, Dcurrent1, Dcurrent2)
imp.setPosition(channel)
imp.setRoi(roi)
Esnake_options1 = "target_brightness=Bright control_points=" + \
str(ES_ctrl_pts) + " gaussian_blur=0 "
Esnake_options2 = "energy_type=Contour alpha=2.0E-5 max_iterations=" + \
str(ES_iteration) + " immortal=false"
IJ.run(imp, "E-Snake", Esnake_options1 + Esnake_options2)
roi_snake = manager.getRoisAsArray()
roi_ind = len(roi_snake) - 1
stats = IS.getStatistics(
imp.getProcessor(), options, imp.getCalibration())
perimeter = roi_snake[roi_ind].getLength() * cal.pixelWidth
circularity = 4.0 * 3.1417 * (stats.area / (perimeter * perimeter))
if stats.area > 17.0 and stats.area < ES_area_max and stats.skewness < -0.01 and circularity > 0.01 and stats.minor > 2.0 and boundaries(Xcenter, Ycenter, stats.xCentroid / cal.pixelWidth, stats.yCentroid / cal.pixelHeight, ES_tolerance):
Sintensity = stats.median
convergence.append(True)
break
if stats.median > 6000 and stats.area > 17.0 and stats.area < ES_area_max:
Sintensity = stats.median
convergence.append(True)
break
elif repeat > repeat_max:
manager.select(imp, roi_ind)
manager.runCommand(imp, 'Delete')
roi = OvalRoi(Xcenter + 1.0 - diameter_init / 2.0, Ycenter +
1.0 - diameter_init / 2.0, diameter_init, diameter_init)
imp.setRoi(roi)
manager.add(imp, roi, spotID)
roi_snake.append(roi)
stats = IS.getStatistics(
imp.getProcessor(), options, imp.getCalibration())
Sintensity = stats.median
convergence.append(False)
break
else:
IJ.log('Area=' + str(stats.area) + ' Skewness=' + str(stats.skewness) +
' circularity=' + str(circularity) + ' Minor=' + str(stats.minor))
manager.select(imp, roi_ind)
manager.runCommand(imp, 'Delete')
repeat += 1
# End Spot-segmentation
# End all Spots-segmentation
manager.runCommand(imp, 'Show All')
imp.setPosition(channel)
color = imp.createImagePlus()
ip = imp.getProcessor().duplicate()
color.setProcessor("segmentation" + str(channel), ip)
color.show()
IJ.selectWindow("segmentation" + str(channel))
manager.moveRoisToOverlay(color)
spot_optimal = manager.getRoisAsArray()
manager.reset()
for i in xrange(0, len(spot_optimal)):
spot = spot_optimal[i]
spot.setStrokeWidth(2)
if convergence[i]:
spot.setStrokeColor(Color.GREEN)
else:
spot.setStrokeColor(Color.MAGENTA)
imp.setRoi(spot)
manager.add(imp, spot, i)
manager.runCommand(imp, 'Show All')
imp.setPosition(channel)