当前位置: 首页>>代码示例>>Python>>正文


Python RoiManager.runCommand方法代码示例

本文整理汇总了Python中ij.plugin.frame.RoiManager.runCommand方法的典型用法代码示例。如果您正苦于以下问题:Python RoiManager.runCommand方法的具体用法?Python RoiManager.runCommand怎么用?Python RoiManager.runCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ij.plugin.frame.RoiManager的用法示例。


在下文中一共展示了RoiManager.runCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_roi_manager

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [as 别名]
def get_roi_manager(new=False):
    rm = RoiManager.getInstance()
    if not rm:
        rm = RoiManager()
    if new:
        rm.runCommand("Reset")
    return rm
开发者ID:imagej,项目名称:imagej-scripting,代码行数:9,代码来源:Particles_From_Mask.py

示例2: measureTumor

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [as 别名]
def measureTumor(original, locations):
	'''Returns the area from the original image with the 
	highest kurtosis which generally corresponds to the most
	in focus image. Also saves an image corresponding to a mask
	of the measurement.'''
	# Prevent ROI manager from appearing
	roiM = RoiManager(True)
	ParticleAnalyzer.setRoiManager(roiM)
	# Locate particles above a minimum size and with a desired circularity
	IJ.run(locations, "Analyze Particles...", "size=" + str(minimumCancerArea) +"-" + str(maxCancerArea) +" circularity=" + str(circularityCutoff) + "-1.00 show=Nothing exclude add stack");
	# Choose ROI with the highest kurtosis
	maxKurtosis = None
	area = None
	selectedROI = None
	for roi in roiM.getRoisAsArray():
		original.setRoi(roi)
		stats = original.getStatistics(Measurements.KURTOSIS, Measurements.AREA)
		currentKurtosis = stats.kurtosis
		if currentKurtosis > maxKurtosis:
			maxKurtosis = stats.kurtosis
			area = stats.area
			selectedROI = roi
	original.killRoi() # Remove the remaining ROI
	roiM.runCommand("Reset")
	return (area, selectedROI)
开发者ID:btweinstein,项目名称:bryan_imagej,代码行数:27,代码来源:getEllipticalArea_.py

示例3: resetpressed

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [as 别名]
		def resetpressed(event):
			self.__ranges.clear()
			self.__image=IJ.getImage()
			rm = RoiManager.getInstance()
			if (rm==None): rm = RoiManager()
			rm.runCommand("reset")
			self.__image.killRoi()
			IJ.setAutoThreshold(self.__image, "MaxEntropy")
			rt=ResultsTable()
			pa=ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET , Measurements.AREA+Measurements.ELLIPSE+Measurements.MEAN, rt, 0.00, 10000.00, 0.00, 1.00)
			pa.analyze(self.__image)
			self.__roisArray=[]
			self.__roisArray=rm.getRoisAsArray()
			#rm.runCommand("Show All")
			#rm.runCommand("Select All")
			#rm.runCommand("Set Color", "blue")
			
			IJ.resetThreshold(self.__image)
			
			keys=self.__slidersDict.keys()
			for k in keys:
				if k.endswith("min"): 
					self.__slidersDict[k].setValue(0)
					self.__slidersDict[k].repaint()
				else:
					self.__slidersDict[k].setValue(self.__slidersDict[k].getMaximum())
					self.__slidersDict[k].repaint()
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:29,代码来源:RangeRois.py

示例4: particleRemover

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [as 别名]
def particleRemover(image, minArea):
	'''Send in a thresholded image, remove the small spots'''
	numSlices = image.getImageStackSize()
	particleRoiM = RoiManager(True)
	ParticleAnalyzer.setRoiManager(particleRoiM)
	IJ.run(image, "Analyze Particles...", "size=0-" + str(minArea) + " circularity=0.00-1.00 include show=Nothing add stack");
	# Set the fill color to black before filling
	IJ.setForegroundColor(0, 0, 0);
	particleRoiM.runCommand("Fill");
	particleRoiM.runCommand("Reset");
开发者ID:btweinstein,项目名称:bryan_imagej,代码行数:12,代码来源:ParticleRemoverPy_.py

示例5: RoiSelection

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [as 别名]
def RoiSelection():
	true=1
	false=0
	IJ.run("Invert", "stack");
	IJ.run("Fill Holes", "stack");
	IJ.run("Create Selection");
	rm = RoiManager()
	rm.runCommand("add")
	rm.runCommand("split")
	#number_selected=rm.getCount()
	IJ.run("Select None");
	rm.runCommand("deselect")
	#rm.select(0)
	#print number_selected
	roi_array=rm.getRoisAsArray()
	max_roi=None
	max_points=-1
	for roi in roi_array:
	  polygon=roi.getPolygon()
	  if polygon is not None:
	    number_of_points = polygon.npoints
	    if max_points < number_of_points:
	      max_points=number_of_points
	      max_roi=roi
	#print max_points
	#sorted_roi_array=sorted(roi_array, key=methodcaller('getLength'), reverse=True)
	#length_array=[]
	#index=0
	#for roi in roi_array:
	#	index=index+1
	#	length_array.append((index,roi.getLength()))
	#sorted_length_array=sorted(length_array, key=itemgetter(0))
	rm.runCommand("Select All")
	rm.runCommand("Delete")
	#for roi in roi_array:
	interpolated_polygon=max_roi.getInterpolatedPolygon(20,True)
	roi_polygon=PolygonRoi(interpolated_polygon,Roi.POLYGON)
	rm.addRoi(roi_polygon)
开发者ID:jmil,项目名称:MPI_Fiji_Scripts,代码行数:40,代码来源:MainProgram.py

示例6: makeCell

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [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
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:39,代码来源:BacteriaCell.py

示例7: updatepressed

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [as 别名]
		def updatepressed(event):
			self.__image=IJ.getImage()
			rm = RoiManager.getInstance()
			if (rm==None): rm = RoiManager()
			rm.runCommand("reset")
			self.__image.killRoi()
			IJ.run("Threshold...")
			IJ.setAutoThreshold(self.__image, "MaxEntropy")
			
			rt=ResultsTable()
			pa=ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET , Measurements.AREA+Measurements.ELLIPSE+Measurements.MEAN, rt, 0.00, 10000.00, 0.00, 1.00)
			pa.analyze(self.__image)
			self.__roisArray=[]
			self.__roisArray=rm.getRoisAsArray()
			#for i in range(rm.getCount()) : 
			#	rm.select(i)
			#	rm.runCommand("Set Color", "0000FF", 2)
				
			IJ.resetThreshold(self.__image)
			rt.show("tempRT")
			areas=rt.getColumn(ResultsTable.AREA)
			means=rt.getColumn(ResultsTable.MEAN)
			majors=rt.getColumn(ResultsTable.MAJOR)
			minors=rt.getColumn(ResultsTable.MINOR)
			#print 0
			if self.__slidersDict["Area_max"].getMaximum() <  int(max(areas)+1):
			#	print 1
				self.__slidersDict["Area_max"].setMaximum(int(max(areas))+1)
			if self.__slidersDict["Area_min"].getMaximum() < int(max(areas)+1):
			#	print 2
				self.__slidersDict["Area_min"].setMaximum(int(max(areas))+1)
			if self.__slidersDict["Mean_max"].getMaximum() < int(max(means)+1):
			#	print 3
				self.__slidersDict["Mean_max"].setMaximum(int(max(means))+1)
			if self.__slidersDict["Mean_min"].getMaximum() < int(max(means)+1):
			#	print 4
				self.__slidersDict["Mean_min"].setMaximum(int(max(means))+1)
			if self.__slidersDict["Major_max"].getMaximum() < int(max(majors)):
			#	print 5
				self.__slidersDict["Major_max"].setMaximum(int(max(majors))+1)
			if self.__slidersDict["Major_min"].getMaximum() < int(max(majors)+1):
			#	print 6
				self.__slidersDict["Major_min"].setMaximum(int(max(majors))+1)
			if self.__slidersDict["Minor_max"].getMaximum() < int(max(minors)+1):
			#	print 7
				self.__slidersDict["Minor_max"].setMaximum(int(max(minors))+1)
			if self.__slidersDict["Minor_min"].getMaximum() < int(max(minors)+1):
			#	print 8
				self.__slidersDict["Minor_min"].setMaximum(int(max(minors))+1)
			if self.__slidersDict["AR_max"].getMaximum() < int((max(majors)+1)/min(minors)+1):
			#	print 9
				self.__slidersDict["AR_max"].setMaximum(int((max(majors)+1)/(min(minors))))
			if self.__slidersDict["AR_min"].getMaximum() < int((max(majors)+1)/min(minors)):
			#	print 10
				self.__slidersDict["AR_min"].setMaximum(int((max(majors)+1)/(min(minors))))

			#print 11
				
			for sb in self.__slidersDict.values():
				sb.repaint()

			#rm.runCommand("reset")
			#temprois=self.getIncludeRois()
			#IJ.run(self.__image, "Remove Overlay", "")
			#o=Overlay()
			#for roi in temprois:
			#	o.addElement(roi)
			#self.__image.killRoi()
			#self.__image.setOverlay(o)
			self.__image.updateAndDraw()
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:72,代码来源:RangeRois.py

示例8: showSettingsDialog

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [as 别名]
	def showSettingsDialog(self):
		if self.__image.getOverlay() is not None : self.__image.getOverlay().clear()
		rm = RoiManager.getInstance()
		if (rm==None): rm = RoiManager()
		#rm.runCommand("Deselect")
		#for i in range(rm.getCount()) : 
		#	rm.select(i)
		#	rm.runCommand("Set Color", "0000FF", 2)
		
		
		IJ.resetThreshold(self.__image)

		rm.runCommand("Show All")
		
		self.__ranges.clear()
		#areas, means, majors, minors=[],[],[],[]

		#for roi in self.__roisArray:
		#	m=Morph(self.__image, roi)
		#	areas.append(m.Area)
		#	means.append(m.Mean)
		#	majors.append(m.Major)
		#	minors.append(m.Minor)
			
		#maxarea=max(areas)*1000
		#maxint=max(means)*10
		#maxline=max(majors)*100
		#maxminline=max(minors)*100
		#minline=min(minors)
		
		#namemeasures=["Area", "Mean", "Angle", "Major", "Minor", "Solidity", "AR", "Round", "Circ"]
		#maxmeasures=[maxarea, maxint, 180*10, maxline, maxminline, 1*1000, (maxline/minline), 1*1000, 1*1000]
		#set1000=Set(["Solidity", "Round", "Circ"])
		#set10=Set(["Angle"])
		
		def buttonPressed(event):
			temprois=self.getIncludeRois()
			for roi in temprois:
				m=Morph(self.__image, roi)
				IJ.log("----------------------------------")
				IJ.log(roi.getName())
				for r in self.__ranges.values():
					IJ.log(r[0]+" min= "+str(r[1])+" < val="+str(m.__getattribute__(r[0]))+" < max= "+str(r[2]))
			IJ.run(self.__image, "Remove Overlay", "")
			o=Overlay()
			for roi in temprois:
				o.addElement(roi)
			self.__image.killRoi()
			self.__image.setOverlay(o)
			self.__image.updateAndDraw()

		def updatepressed(event):
			self.__image=IJ.getImage()
			rm = RoiManager.getInstance()
			if (rm==None): rm = RoiManager()
			rm.runCommand("reset")
			self.__image.killRoi()
			IJ.run("Threshold...")
			IJ.setAutoThreshold(self.__image, "MaxEntropy")
			
			rt=ResultsTable()
			pa=ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET , Measurements.AREA+Measurements.ELLIPSE+Measurements.MEAN, rt, 0.00, 10000.00, 0.00, 1.00)
			pa.analyze(self.__image)
			self.__roisArray=[]
			self.__roisArray=rm.getRoisAsArray()
			#for i in range(rm.getCount()) : 
			#	rm.select(i)
			#	rm.runCommand("Set Color", "0000FF", 2)
				
			IJ.resetThreshold(self.__image)
			rt.show("tempRT")
			areas=rt.getColumn(ResultsTable.AREA)
			means=rt.getColumn(ResultsTable.MEAN)
			majors=rt.getColumn(ResultsTable.MAJOR)
			minors=rt.getColumn(ResultsTable.MINOR)
			#print 0
			if self.__slidersDict["Area_max"].getMaximum() <  int(max(areas)+1):
			#	print 1
				self.__slidersDict["Area_max"].setMaximum(int(max(areas))+1)
			if self.__slidersDict["Area_min"].getMaximum() < int(max(areas)+1):
			#	print 2
				self.__slidersDict["Area_min"].setMaximum(int(max(areas))+1)
			if self.__slidersDict["Mean_max"].getMaximum() < int(max(means)+1):
			#	print 3
				self.__slidersDict["Mean_max"].setMaximum(int(max(means))+1)
			if self.__slidersDict["Mean_min"].getMaximum() < int(max(means)+1):
			#	print 4
				self.__slidersDict["Mean_min"].setMaximum(int(max(means))+1)
			if self.__slidersDict["Major_max"].getMaximum() < int(max(majors)):
			#	print 5
				self.__slidersDict["Major_max"].setMaximum(int(max(majors))+1)
			if self.__slidersDict["Major_min"].getMaximum() < int(max(majors)+1):
			#	print 6
				self.__slidersDict["Major_min"].setMaximum(int(max(majors))+1)
			if self.__slidersDict["Minor_max"].getMaximum() < int(max(minors)+1):
			#	print 7
				self.__slidersDict["Minor_max"].setMaximum(int(max(minors))+1)
			if self.__slidersDict["Minor_min"].getMaximum() < int(max(minors)+1):
			#	print 8
				self.__slidersDict["Minor_min"].setMaximum(int(max(minors))+1)
#.........这里部分代码省略.........
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:103,代码来源:RangeRois.py

示例9: __displayCells

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [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()
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:80,代码来源:BacteriaTracking.py

示例10: __calRois

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [as 别名]
	def __calRois(self, imp, indice) :									
		"""
		Returns the ROIs of a slice given (identified with its n°) in a stack
		"""
		##imp=self.__dictImages[nameimages]							 		# IL FAUT RÉCUPÉRER L'IMAGE DU STACK !!!!!
		#if self.__batch : imp.hide()
		#else : imp.show()
		#imp.hide()
		imp.show()
		if self.__batch : imp.hide()
		imp.setSlice(indice)
		imp.killRoi()
		ip = imp.getProcessor()

		bs=BackgroundSubtracter() 

		#if str(self.__subback) == "0" or str(self.__subback) == "1" : self.__subback = bool(int(self.__subback))
		#if self.__subback == True : IJ.run(imp, "Subtract Background...", "rolling="+str(self.__radius)+" light")
		if self.__subback == True : bs.rollingBallBackground(ip, self.__radius, False, True, False, True, False)

		if self.__runmacro :
			imp.show()
			imp.setSlice(indice)
			imp.updateAndDraw()
			IJ.runMacroFile(self.__macropath, imp.getTitle())
		
		
			
		imp.updateAndDraw()
		
		#if str(self.__manthresh) == "0" or str(self.__manthresh) == "1" : self.__manthresh = bool(int(self.__manthresh))
		
		#if self.__manthresh : IJ.setThreshold(imp, self.__minthr, self.__maxthr)
		if self.__manthresh : 
			ip.setThreshold(self.__minthr, self.__maxthr, ImageProcessor.RED_LUT)
		else : self.__setThreshold(imp, indice)
		
		rt=ResultsTable()
		pa1=ParticleAnalyzer(ParticleAnalyzer.SHOW_MASKS+ParticleAnalyzer.EXCLUDE_EDGE_PARTICLES , Measurements.AREA, rt, self.__minArea, self.__maxArea, self.__minCirc, self.__maxCirc)
		pa1.setHideOutputImage(True) 
		pa1.analyze(imp)
		
		masks=pa1.getOutputImage()
		masks.getProcessor().erode()
		masks.getProcessor().dilate()
		masks.getProcessor().invertLut()
		masks.getProcessor().threshold(1)
		
		rm = RoiManager.getInstance()
		if (rm==None): rm = RoiManager()
		rm.runCommand("reset")
		#rm.hide()
		
		pa2=ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET+ParticleAnalyzer.EXCLUDE_EDGE_PARTICLES , Measurements.AREA, rt, self.__minArea, self.__maxArea, self.__minCirc, self.__maxCirc) 
		pa2.analyze(masks)
		masks.close()
		
		temparray=rm.getRoisAsArray()
		for r in temparray :
			tempnameroi=r.getName()
			r.setPosition(indice)
			r.setName(str(indice)+"-"+tempnameroi)
			r.setStrokeWidth(1) 
		
		if len(self.__params) > 0 :
			for k in self.__params:
				#if k[0]=="Area": self.__minArea, self.__maxArea = str(k[1]), str(k[2])
				if k[0]=="Area": self.__minArea, self.__maxArea = k[1], k[2]
			for k in self.__params:
				#if k[0]=="Circ": self.__minCirc, self.__maxCirc = str(k[1]), str(k[2])
				if (k[0]=="Circ") and k[3] : self.__minCirc, self.__maxCirc = k[1], k[2]
				else : self.__minCirc, self.__maxCirc = 0, 1
			self.__rr.setRoisarray(temparray, imp)
			self.__rr.setRange(indice, self.__params)
			return self.__rr.includeRois
		else : return temparray
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:78,代码来源:BacteriaTracking.py

示例11: __settings

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [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
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:104,代码来源:MeasuresCells_.py

示例12: __ImportCells

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [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)
#.........这里部分代码省略.........
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:103,代码来源:MeasuresCells_.py

示例13: OpenDialog

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [as 别名]
odref = OpenDialog("Choose a reference image file", None)
reffn = odref.getFileName()

if reffn is None:
    print "User canceled the dialog!"
else:
    refdir = odref.getDirectory()
    refpath = os.path.join(refdir, reffn)

refImp = IJ.openImage(refpath)
width = refImp.width  
height = refImp.height  

roim = RoiManager()
roim.runCommand("open", roipath)

roiArray = roim.getRoisAsArray()
nRoi = len(roiArray)
roim.close()

bwStack = ImageStack(width, height, nRoi)
for i in xrange(1, nRoi+1):
    bwStack.setProcessor(FloatProcessor(width, height, zeros('f', width * height), None), i)

for i in xrange(1, nRoi+1):
    roi = roiArray[i-1]
    fp = bwStack.getProcessor(i)
    fp.setValue(1.0)
    fp.fill(roi)
开发者ID:singingstars,项目名称:lab-program,代码行数:31,代码来源:roi.to.mask_.py

示例14: RoiManager

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [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");
开发者ID:robmarkcole,项目名称:Medical_physics_imageJ,代码行数:15,代码来源:ROI_manager_basic_interaction.py

示例15: runOnFile

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import runCommand [as 别名]
	def runOnFile(self, afile, show = True, jobnr = None):
		afile = str(afile)
		if afile == '' or afile is None:
			od = OpenDialog("Choose image file", None)
			if od.getFileName() == None:
				return
			afile = os.path.join(od.getDirectory(), od.getFileName())
		if '.log' in afile:
			return
		
		try:
			zk = ZeissKeys()
			msg = Message()
			print "Hi"
			if self.jobs is None:
				IJ.showMessage("You need to first set the parameters")
			
			if all([job['pip']=='None' for job in self.jobs]):
				IJ.showMessage("Nothing to do! At least on job different than None") 
				return 0
			
			#create a copy otherwise self.jobs gets overwritten
			jobs = copy.deepcopy(self.jobs)
			random.seed()
			
			#create a roiManager in case one is missing and reset it
			roim = RoiManager.getInstance()
			if roim == None:
				roim = RoiManager()
			roim.runCommand("reset")
			
			for i, job in enumerate(self.jobs):
				jobl = job #not really necessary
				if jobl['pip'] == 'None':
					continue
				self.JOBS_DICT[jobl['pip']] + jobl['task'] + "_" 
				
				if jobnr is not None:
					if jobnr == i:
						#force opening
						imageDef = self.openFile(afile, self.getPrefix(self.JOBS_DICT[jobl['pip']], jobl['task']), 1)
					else: 
						continue
				else:
					imageDef = self.openFile(afile, self.getPrefix(self.JOBS_DICT[jobl['pip']], jobl['task']))
				print imageDef
				jobl['channel'] = int(jobl['channel'])
				
				if imageDef is None:
					continue
				#clean up registry for errors
				IJ.log("Clean up errorMsg registry")
				IJ.run("Read Write Windows Registry", "action=write location=[HKCU\\"+zk.regkey+"] key="+zk.subkey_errormsg+" value=[""] windows=REG_SZ")
				
				[imageC, pixelSize, filepath, filename] = imageDef
				if jobl['channel'] > len(imageC):
					raise IOError('Expecting at least ' + str(jobl['channel']) + ' channels. Image has only ' + str(len(imageC)) + ' channel(s)')
				
				self.rois = [None]*self.nrOfJobs
				self.Segs = [None]*self.nrOfJobs
				self.Procs = [None]*self.nrOfJobs
				#switch color to Cyan for better visibility
				IJ.run(imageC[jobl['channel']-1], "Cyan", "")

				#segment
				self.Procs[i], self.Segs[i], validParticles, self.rois[i] = segmentChannel_Weka(imageC, **jobl)
				if validParticles is None:
					IJ.run("Read Write Windows Registry", "action=write location=[HKCU\\"+zk.regkey+"] key="+zk.subkey_codemic+" value=["+msg.CODE_NOTHING+"] windows=REG_SZ")

				#write values to registry
				try:
					executeTask_Weka(validParticles, **jobl)
				except Exception, err:
					self.exitWithError(str(err))
					return
				
				if self.rois[i] is None:
					imageC[jobl['channel']-1].show()
					self.Segs[i].show()
					self.Procs[i].show()
					continue
				if validParticles is None:
					particle = []
				else:
					particle = [part[0] for part in validParticles]
				imgOut = autTool.createOutputImg(imageC[jobl['channel']-1], self.rois[i], particle)
				
				imgOut.show()	
				self.saveOutputImg(imgOut, filepath, i+1)			
				
			IJ.run("Collect Garbage", "")
开发者ID:tischi,项目名称:scripts,代码行数:93,代码来源:2015-04-30--Tischi--KatharinaSonnen--Online_Weka_Metaphase_Detection_.py


注:本文中的ij.plugin.frame.RoiManager.runCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。