本文整理匯總了Python中ij.plugin.frame.RoiManager.getSelectedRoisAsArray方法的典型用法代碼示例。如果您正苦於以下問題:Python RoiManager.getSelectedRoisAsArray方法的具體用法?Python RoiManager.getSelectedRoisAsArray怎麽用?Python RoiManager.getSelectedRoisAsArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ij.plugin.frame.RoiManager
的用法示例。
在下文中一共展示了RoiManager.getSelectedRoisAsArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: makeCell
# 需要導入模塊: from ij.plugin.frame import RoiManager [as 別名]
# 或者: from ij.plugin.frame.RoiManager import getSelectedRoisAsArray [as 別名]
def makeCell(cellfile) :
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]))
if params[0] == "PATHROIS" :
pathtemp = 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])))
rm = RoiManager.getInstance()
if (rm==None): rm = RoiManager()
rm.runCommand("reset")
rm.runCommand("Open", pathtemp)
rois=rm.getSelectedRoisAsArray()
celltemp.setlistRois(rois)
rm.runCommand("UseNames", "true")
rm.runCommand("Associate", "true")
return celltemp
示例2: __ImportCells
# 需要導入模塊: from ij.plugin.frame import RoiManager [as 別名]
# 或者: from ij.plugin.frame.RoiManager import getSelectedRoisAsArray [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)
#.........這裏部分代碼省略.........