本文整理汇总了Python中ij.plugin.frame.RoiManager.select方法的典型用法代码示例。如果您正苦于以下问题:Python RoiManager.select方法的具体用法?Python RoiManager.select怎么用?Python RoiManager.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.plugin.frame.RoiManager
的用法示例。
在下文中一共展示了RoiManager.select方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __displayCells
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import select [as 别名]
def __displayCells(self, nameimage, methodeleon=False):
"""
Displays all the ROIs of the cells with different colors
"""
# we define a list of colors that will be used.
colors = []
ncells= len(self.__dict[nameimage])
if ncells > 0 :
step=200/ncells
if step<1 : step=1
for i in range(ncells) :
r = random.randrange(5,205,step)
g = random.randrange(10,210,step)
b = random.randrange(30,230,step)
#r = int(0+i*step)
#g = random.randrange(10, 190, 30)
#b = int(250-i*step)
colors.append(Color(r, g, b))
else : colors=[Color.blue, Color.green, Color.magenta, Color.orange, Color.yellow]
tempcolors=list(colors)
# we try to have random and different colors for each cell.
for cellname in self.__dict[nameimage].keys() :
if len(tempcolors)>0 :
self.__dict[nameimage][cellname].setColor(tempcolors.pop(0))
else :
tempcolors=list(colors)
self.__dict[nameimage][cellname].setColor(tempcolors.pop(0))
self.__SaveCells(nameimage)
rm = RoiManager.getInstance()
if (rm==None): rm = RoiManager()
rm.runCommand("reset")
# if the user wants to save files, .zip for the ROIs are saved.
#if self.__optionSave == True :
#os.mkdir(self.__pathdir+"ROIs/", mode=0777)
os.makedirs(self.__pathdir+"ROIs/", mode=0777)
tempimp = IJ.createImage("tempimp", "8-bit Black", self.__dictImages[nameimage].getWidth(), self.__dictImages[nameimage].getHeight(), 1)
tempimp.show()
for cellname in self.__dict[nameimage].keys() :
for numslice in range(self.__dictImages[nameimage].getImageStackSize()) :
r = self.__dict[nameimage][cellname].getRoi(numslice)
try :
name=r.getName()
except AttributeError : continue
else :
s = "%04i" % (numslice+1)
#name=s+"-"+name.split("-", 1)[1]
name=s+"-cell"+name.split("cell")[1]
r.setName(name)
try :
rm.addRoi(r)
rname=rm.getName(rm.getCount()-1)
#rm.select(self.__dictImages[nameimage], rm.getCount()-1)
rm.select(tempimp, rm.getCount()-1)
rm.runCommand("Rename", name)
except TypeError : continue
#if isinstance(self.__dict[nameimage][cellname].getRoi(numslice),Roi) == True :
# s = "%04i" % (numslice)
# #rm.add(self.__dictImages[nameimage], self.__dict[nameimage][cellname].getRoi(numslice) , numslice)
# name=self.__dict[nameimage][cellname].getRoi(numslice).getName()
# name=s+name
# self.__dict[nameimage][cellname].getRoi(numslice).setName(name)
# rm.addRoi(self.__dict[nameimage][cellname].getRoi(numslice))
rm.runCommand("Save", self.__pathdir+"ROIs/"+cellname+".zip")
rm.runCommand("reset")
tempimp.close()
示例2: __settings
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import select [as 别名]
#.........这里部分代码省略.........
measureslabels_indep=["MaxFeret","MinFeret","AngleFeret","XFeret","YFeret","Area","Angle","Major","Minor","Solidity","AR","Round","Circ","XC","YC","FerCoord","FerAxis","MidAxis"]
measureslabels_dep=["Mean","StdDev","IntDen","Kurt","Skew","XM","YM","Fprofil","MidProfil","NFoci","ListFoci","ListAreaFoci","ListPeaksFoci","ListMeanFoci"]
measureslabels_global=["Latency", "velocity", "cumulatedDist"]
measureslabels_dep_tabonly=set(["MidAxis","FerCoord","FerAxis","Fprofil","MidProfil","ListFoci","ListAreaFoci","ListPeaksFoci","ListMeanFoci"])
ens_measures_global=set(measureslabels_global)
ens_measures_indep=set(measureslabels_indep)
ens_measures_dep=set(measureslabels_dep)
measureslabels=[]
for label in measureslabels_indep :
measureslabels.append(label)
for label in measureslabels_dep :
measureslabels.append(label)
#self.__defaultmeasures=[False for i in range(len(measureslabels))]
#self.__defaultmeasures_global=[False for i in range(len(measureslabels_global))]
gdmeasures=NonBlockingGenericDialog("MeasuresChoice")
gdmeasures.setFont(Font("Courrier", 1, 10))
gdmeasures.addMessage("******* TIME SETTINGS *******")
gdmeasures.addCheckbox("Only starting at begining :", self.__onlystart) # 1 only start
gdmeasures.addNumericField("Minimal Lifetime : ",self.__minLife,0)
gdmeasures.addNumericField("Maximal Lifetime : ",self.__maxLife,0)
#gdmeasures.addNumericField("Maximal Lifetime : ",self.__img.getImageStackSize(),0)
gdmeasures.addCheckbox("x axis in seconds", self.__useTime) # 2 use time
gdmeasures.addMessage("")
gdmeasures.addMessage("")
gdmeasures.addMessage("Choose the measures to make on the cells : ")
gdmeasures.addMessage("******* TIME MEASURES *******")
gdmeasures.addCheckboxGroup(4,8,measureslabels,self.__defaultmeasures)
gdmeasures.addMessage("")
gdmeasures.addMessage("******* GLOBAL MEASURES *******")
gdmeasures.addMessage("PLEASE : If you have selected movement parameters you MUST to select XC and YC !")
gdmeasures.addCheckboxGroup(3,1,measureslabels_global,self.__defaultmeasures_global)
gdmeasures.addNumericField("Noise value for maxima finder: ",self.__noise,0)
gdmeasures.addMessage("")
gdmeasures.addMessage("******* OPTIONS *******")
gdmeasures.addCheckbox("Select the cells in next dialog ?", self.__onlyselect) # 3 only select
gdmeasures.addCheckbox("Save results to text files ?", self.__savetables) # 4 save files
#gdmeasures.addCheckbox("Append mode ?", self.__savemode) # 5 append mode
gdmeasures.addCheckbox("Analyse in batch mode ?", self.__batchanalyse) # 6 analysis batch mode
gdmeasures.addCheckbox("Update overlay ?", self.__updateoverlay) # 7 update overlay
gdmeasures.addMessage("")
gdmeasures.addMessage("")
help_panel=Panel()
helpbutton=Button("HELP")
helpbutton.actionPerformed = helpbuttonPressed
help_panel.add(helpbutton)
gdmeasures.addPanel(help_panel)
gdmeasures.hideCancelButton()
if not self.__batchanalyse :
gdmeasures.showDialog()
self.__onlystart=gdmeasures.getNextBoolean() # 1 only start
self.__minLife=gdmeasures.getNextNumber()
self.__maxLife=gdmeasures.getNextNumber()
self.__useTime=gdmeasures.getNextBoolean() # 2 use time
self.__measuresparambool=[]
self.__measuresparambool_global=[]
for i in range(len(measureslabels)) :
self.__measuresparambool.append(gdmeasures.getNextBoolean())
self.__defaultmeasures[i]=self.__measuresparambool[-1]
for i in range(len(measureslabels_global)) :
self.__measuresparambool_global.append(gdmeasures.getNextBoolean())
示例3: __ImportCells
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import select [as 别名]
def __ImportCells(self, imagesnames) :
#self.__dictCells[imgName]={}
rm = RoiManager.getInstance()
if (rm==None): rm = RoiManager()
rm.runCommand("reset")
listpaths = []
listfilescells=[]
if self.__optionImages :
IJ.showMessage("Select the folder 'Cells' containing the cells to import")
selectdir=IJ.getDirectory("image")
selectdir=IJ.getDirectory("")
listfilescells.extend(glob.glob(selectdir+os.path.sep+"*"))
listpaths.append("")
else :
IJ.showMessage("Select the text file containing the list cell paths (listpaths.txt)")
selectdir=IJ.getDirectory("current")
frame = Frame("Text file settings ?")
fd = FileDialog(frame)
fd.setDirectory(selectdir)
fd.show()
selectdir = fd.getDirectory()
textfile = fd.getFile()
fichier = open(selectdir+textfile,"r")
listpaths=[ glob.glob(f.split("\n")[0]+"Selected-Cells"+os.path.sep+"*") for f in fichier.readlines()]
#for f in templist :
# listpaths.append(f.split("\n")+"Cells")
listfilescells.append("")
if listfilescells[0]=="" : importmode = True
else : importmode = False
for j in range(len(listpaths)) :
self.__dictCells[imagesnames[j]]={}
if importmode : listfilescells = listpaths[j]
pathtemp = []
for cellfile in listfilescells :
filetemp = open(cellfile,"r")
linestemp=filetemp.readlines()
for line in linestemp :
params=line.split("=")
values=params[1].split("\n")
if params[0] == "NAMECELL" :
celltemp=Bacteria_Cell(str(values[0]))
self.__dictCells[imagesnames[j]][values[0]]=celltemp
self.__dictMeasures[self.__dictCells[imagesnames[j]][values[0]]]={}
if params[0] == "PATHROIS" :
pathtemp.append(str(values[0]))
if params[0] == "NSLICES" :
for i in range(int(values[0])) :
celltemp.getListRoi().append("")
if params[0] == "SLICEINIT" :
celltemp.setSlideInit(int(values[0]))
for i in range(int(values[0])-2) :
celltemp.setRoi("NOT HERE YET",i)
if params[0] == "SLICEEND" :
celltemp.setSlideEnd(int(values[0]))
for i in range(int(values[0])) :
celltemp.setRoi("LOST",i)
if params[0] == "COLOR" :
colorstemp=values[0].split(";")
celltemp.setColor(Color(int(colorstemp[0]),int(colorstemp[1]),int(colorstemp[2])))
indiceroi=0
ind=0
tempimp = WindowManager.getImage(imagesnames[j])
if tempimp is not None :
IJ.selectWindow(imagesnames[j])
tempimp.show()
else :
if imagesnames[j][-4:]==".tif" :
IJ.selectWindow(imagesnames[j][:-4])
tempimp = IJ.getImage()
else :
IJ.selectWindow(imagesnames[j]+".tif")
tempimp = IJ.getImage()
rm.runCommand("reset")
for cellname in self.__dictCells[imagesnames[j]].keys() :
rm.runCommand("Open", pathtemp[ind])
ind+=1
nbtemp=self.__dictCells[imagesnames[j]][cellname].getLifeTime()
for i in range(nbtemp) :
rm.select(tempimp, indiceroi)
roi=rm.getSelectedRoisAsArray()[0]
self.__dictCells[imagesnames[j]][cellname].setRoi(roi,i+self.__dictCells[imagesnames[j]][cellname].getSlideInit()-1)
#.........这里部分代码省略.........
示例4: RoiManager
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import select [as 别名]
from ij import IJ
from ij.gui import OvalRoi
from ij.plugin.frame import RoiManager
imp = IJ.getImage()
rm = RoiManager() # instantiate manager # throws exception if it doesn't exist
#rm = RoiManager.getInstance() # if manager exists
roi = OvalRoi(75, 75, 50, 50); # define and add ROI
imp.setRoi(roi) # make active on image
rm.addRoi(roi) # add
rm.select(0) # select the zeroth ROI and rename it
rm.runCommand("Rename", "roi");
示例5: segmentation
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import select [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)
示例6: exit
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import select [as 别名]
# addAndDeleteROI_.py
# Add and delete a ROI from an image
#
# Modifications
# Date Who Ver What
# ---------- --- ------ -------------------------------------------------
# 2014-10-21 JRM 0.1.00 Initial prototype
from ij import WindowManager
from ij import IJ
from ij.plugin.frame import RoiManager
raw = IJ.openImage("D:\\Data\\images\\tmp\\sis-efi-sc.png")
raw.show()
IJ.makeRectangle(0, 190, 1600, 260)
wbROI = raw.getRoi()
if (wbROI==None):
exit("you must draw region first")
print(wbROI)
rm = RoiManager()
rm.select(raw, 0)
rm.runCommand("Show All")
rm.runCommand("Draw")
print("done")