本文整理汇总了Python中ij.plugin.frame.RoiManager.getCount方法的典型用法代码示例。如果您正苦于以下问题:Python RoiManager.getCount方法的具体用法?Python RoiManager.getCount怎么用?Python RoiManager.getCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.plugin.frame.RoiManager
的用法示例。
在下文中一共展示了RoiManager.getCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __settings
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getCount [as 别名]
#.........这里部分代码省略.........
#velocities=[]
for i in range(len(self.__listcellname)) :
IJ.showProgress(i, len(self.__listcellname))
self.__measurecumulDist(self.__img,imgName)
self.__img.show()
self.__img.getProcessor().resetThreshold()
if self.__updateoverlay :
if self.__img.getOverlay() is not None : self.__img.getOverlay().clear()
outputrois=[]
cellnames=[]
self.__img.hide()
for cellname in self.__listcellname :
for r in dico[cellname].getListRoi():
if isinstance(r,Roi) :
pos=r.getPosition()
#print "MC overlay", cellname, r.getName(), pos
#r.setPosition(0)
#overlay.add(r)
outputrois.append(r)
if "cell" in r.getName() : cellnames.append(r.getName())
else : cellnames.append(str(pos)+"-"+cellname)
#print cellnames[-1]
rm = RoiManager.getInstance()
if (rm==None): rm = RoiManager()
rm.show()
self.__img.show()
IJ.selectWindow(self.__img.getTitle())
rm.runCommand("reset")
for i in range(len(outputrois)) :
outputrois[i].setName(cellnames[i])
rm.addRoi(outputrois[i])
rm.select(rm.getCount()-1)
rm.runCommand("Rename", cellnames[i])
IJ.run("Show Overlay", "")
rm.runCommand("UseNames", "true")
rm.runCommand("Associate", "true")
IJ.run(self.__img, "Labels...", "color=red font=12 show use")
IJ.run(self.__img, "From ROI Manager", "")
rm.runCommand("Show None")
rm.runCommand("Show All")
# ----------- batch analyse ------------------------
if self.__batchanalyse :
if self.__savetables : saveResults()
self.__dictMeasures.clear()
self.__allcells[:]=[]
self.__measurescompl[:]=[]
self.__measures[:]=[]
return False
# ---------- display methodes dialog ----------------
# Allows the user to choose how to see the results of the measures.
gd0=NonBlockingGenericDialog("Display")
gd0.addMessage("How do you want to see the results ?")
panel0=Panel()
diagrambutton=Button("Diagram")
diagrambutton.actionPerformed = diagrambuttonPressed
panel0.add(diagrambutton)
graphbutton=Button("Graph")
graphbutton.actionPerformed = graphbuttonPressed
panel0.add(graphbutton)
tabbutton=Button("Tab")
tabbutton.actionPerformed = tabbuttonPressed
panel0.add(tabbutton)
gd0.addPanel(panel0)
gd0.addCheckbox("Analyse next stack ?", self.__nextstack)
gd0.hideCancelButton()
gd0.showDialog()
self.__nextstack = gd0.getNextBoolean()
# ---------- save tables ---------------------------
if self.__savetables : saveResults()
# --------- re-start analysis -------------------
self.__dictMeasures.clear()
#self.__listcellname[:]=[]
self.__allcells[:]=[]
self.__measurescompl[:]=[]
self.__measures[:]=[]
if self.__nextstack : return False
else : return True
示例2: __displayCells
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getCount [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()
示例3: __ImportCells
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getCount [as 别名]
#.........这里部分代码省略.........
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)
indiceroi+=1
IJ.run("Show Overlay", "")
rm.runCommand("UseNames", "true")
rm.runCommand("Associate", "true")
IJ.run(tempimp, "Labels...", "color=red font=12 show use")
if rm.getCount()>0 : IJ.run(tempimp, "From ROI Manager", "")
rm.runCommand("Show None")
rm.runCommand("Show All")
roipath = os.path.split(pathtemp[0])[0]+os.path.sep
rootpath = roipath.rsplit(os.path.sep, 2)[0]+os.path.sep
self.__listpaths[j] = rootpath
self.__rootpath=rootpath