예제 #1
0
		def tabbuttonPressed(event) :
		
			tab="\t"
			headings=[]
			measures=[]
			#img=IJ.getImage()
			#for i in range(self.__img.getImageStackSize()+1) :
			for i in range(self.__maxLife+1) :
				headings.append("Slice "+str(i))
			
			headings[0]=WindowManager.getUniqueName(self.__img.getShortTitle())
			#for m in self.__measurescompl :
			for m in self.__dictMeasures[dico[self.__listcellname[0]]].keys() :
				
				headstring=""
				for head in headings: 
					headstring+=head+tab
				tw=TextWindow(self.__listfiles[0]+"-"+m,headstring,"",800,600)
				tp=tw.getTextPanel()
				#for cellname in dico.keys() :
				for cellname in self.__listcellname :
					line=[]
					line=[str(meas)+tab for meas in self.__dictMeasures[dico[cellname]][m]]
					line.insert(0, cellname+tab)
					linestr=""
					for s in line: linestr+=s
					tp.appendLine(linestr)
				tp.updateDisplay()

			if self.__measuresparambool_global[0] :
				tw=TextWindow("Latency","cell\tLatency", "",800,600)
				tp=tw.getTextPanel()
				for i in range(len(self.__listcellname)) :
					#if latencies[i][0] : line=self.__listcellname[i]+"\t"+str(latencies[i][1])
					#else : line=self.__listcellname[i]+"\t"+"NaN"
					line=self.__listcellname[i]+"\t"+str(latencies[i][1])
					tp.appendLine(line)
				tp.updateDisplay() 
예제 #2
0
	def __buildstack(self, listfiles):						
		"""
		Creates stacks according to the list of paths given by the user.
		
		
		"""
		
		

		if not isinstance(listfiles[0],list) and os.path.isfile(listfiles[0]) : 
			if len(self.__positionsList)==0 : tempname = WindowManager.getUniqueName("image")
			else : tempname = self.__positionsList[0]
			tempd = tempfile.mkdtemp()
			fichier = open(tempd+"/"+tempname+".tif","w")
			rawtimes=[]
			rawtimes.append(0)
			zerotimes=0
			for i in range(len(listfiles)-1) :
				difftimes=int((os.stat(listfiles[i+1]).st_mtime-os.stat(listfiles[i]).st_mtime))
				if difftimes==0 : zerotimes+=1
				rawtimes.append(rawtimes[-1]+difftimes)
				fichier.writelines(listfiles[i]+"\n")
			
			fichier.writelines(listfiles[-1]+"\n")
			fichier.close()
			IJ.run("Stack From List...","open="+tempd+"/"+tempname+".tif")
			n=WindowManager.getImageCount()
			tempid=WindowManager.getNthImageID(n)
			tempimg=WindowManager.getImage(tempid)
			if self.__batch : tempimg.hide()
			else : tempimg.show()
			self.__dictImages[tempname]=tempimg
			tempimg.hide()
			nameimages=tempname
			if zerotimes/len(rawtimes) > 0.5 : rawtimes=range(len(listfiles))
			self.__dictTimeStack["image1"]=rawtimes
			

		#elif isinstance(listfiles[0][0],str) :
		elif os.path.isfile(listfiles[0][0]) : 
			nameimages=[]
			rawtimes=[]
			rawtimes.append(0)
			for i in range(len(listfiles)) :
				if len(self.__positionsList)==0 : tempname = WindowManager.getUniqueName("image"+str(i+1))
				else : tempname = self.__positionsList[i]
				tempd = tempfile.mkdtemp()
				fichier = open(tempd+"/"+tempname+".tif","w")
				zerotimes=0
				for j in range(len(listfiles[i])-1) :
					difftimes=int((os.stat(listfiles[i][j+1]).st_mtime-os.stat(listfiles[i][j]).st_mtime))
					if difftimes==0 : zerotimes+=1
					rawtimes.append(rawtimes[-1]+difftimes)
					fichier.writelines(listfiles[i][j]+"\n")

				fichier.writelines(listfiles[i][-1]+"\n")
				fichier.close()
				IJ.run("Stack From List...","open="+tempd+"/"+tempname+".tif")
				n=WindowManager.getImageCount()
				tempid=WindowManager.getNthImageID(n)
				tempimg=WindowManager.getImage(tempid)
				#self.__dictImages["image"+str(i+1)]=tempimg
				#nameimages.append("image"+str(i+1))
				self.__dictImages[tempname]=tempimg
				nameimages.append(tempname)
				if zerotimes/len(rawtimes) > 0.5 : rawtimes=range(len(listfiles[i]))
				#self.__dictTimeStack["image"+str(i+1)]=rawtimes
				self.__dictTimeStack[tempname]=rawtimes
				rawtimes=[] 
				rawtimes.append(0)
				tempimg.hide()
			
		
		else : 
			nameimages=[]
			print "ERROR IN BUILDSTACK"

		return nameimages
예제 #3
0
		def graphbuttonPressed(event) :
			
			colors=[]
			#img=IJ.getImage()
			#nbslices=self.__img.getImageStackSize()
			nbslices=self.__maxLife

			acell=dico.values()[0]
			if self.__useTime : 
				x = acell.getListTimes()
				namex="Time sec"
			else : 
				x = range(1,nbslices+1)
				namex = "Frame"
			maxx=max(x)
			minx=min(x)
			
			#x=[i for i in range(1,nbslices+1)]
			font=Font("new", Font.BOLD, 14)
			tempname = WindowManager.getUniqueName(self.__img.getShortTitle())
			for i in range(len(self.__measures)) :
				#print "i", i, self.__measures[i]
				yarray=[]
				flag=True
				miny=10000000000
				maxy=-1000000000
				#we find the min and max values in order to set the scale.
				for cellname in self.__listcellname :	
					colors.append(dico[cellname].getColor())
					yarray.append(self.__dictMeasures[dico[cellname]][self.__measures[i]])
					#for meas in self.__dictMeasures[dico[cellname]][self.__measures[i]] :
					for meas in yarray[-1] :
						if (meas<miny) and (Double.isNaN(meas)==False) :
							miny=meas
					if max(yarray[-1])>maxy : maxy=max(yarray[-1])
				
				miny-=0.1*miny
				maxy+=0.1*maxy
				count=0.05
				
				for j in range(len(yarray)) :
					if j==0 :
						if len(self.__measures)>1 :
							plot=Plot("Plots-"+str(self.__measures[i]),namex,str(self.__measures[i]),x,yarray[j])
							
						else : 
							plot=Plot("Plot-"+tempname,namex,str(self.__measures[i]),x,yarray[j])
							
						plot.setLimits(minx,maxx,miny,maxy)
						plot.setColor(colors[j])
						plot.changeFont(font)
						plot.addLabel(0.05, count, self.__listcellname[j])
					else :
						plot.setColor(colors[j])
						plot.setLineWidth(3)
						plot.addPoints(x,yarray[j],Plot.LINE)
						plot.addLabel(0.05, count, self.__listcellname[j])

					count+=0.05
						
				plot.setColor(colors[0])
				plot.show()
				
			if len(self.__measures)>1 :
				IJ.run("Images to Stack", "name="+tempname+"-plots title=Plots- use")
예제 #4
0
	def __buildstacks(self) :
		listfiles = self.__listfiles[2]
		positionsList = self.__imagesnames
		
		if not isinstance(listfiles[0],list) and os.path.isfile(listfiles[0]) : 
			if len(positionsList)==0 : tempname = WindowManager.getUniqueName("image")
			else : tempname = positionsList[0]
			tempd = tempfile.mkdtemp()
			fichier = open(tempd+os.path.sep+tempname+".tif","w")
			rawtimes=[]
			rawtimes.append(0)
			zerotimes=0
			for i in range(len(listfiles)-1) :
				difftimes=int((os.stat(listfiles[i+1]).st_mtime-os.stat(listfiles[i]).st_mtime))
				if difftimes==0 : zerotimes+=1
				rawtimes.append(rawtimes[-1]+difftimes)
				fichier.writelines(listfiles[i]+"\n")
			
			fichier.writelines(listfiles[-1]+"\n")
			fichier.close()
			IJ.run("Stack From List...","open="+tempd+os.path.sep+tempname+".tif")
			n=WindowManager.getImageCount()
			tempid=WindowManager.getNthImageID(n)
			tempimg=WindowManager.getImage(tempid)
			tempimg.show()
			#self.__dictImages[tempname]=tempimg
			#tempimg.hide()
			nameimages=tempname+"tif"
			#if zerotimes/len(rawtimes) > 0.5 : rawtimes=range(len(listfiles))
			#self.__dictTimeStack[tempname]=rawtimes
			

		#elif isinstance(listfiles[0][0],str) :
		elif os.path.isfile(listfiles[0][0]) : 
			nameimages=[]
			rawtimes=[]
			rawtimes.append(0)
			for i in range(len(listfiles)) :
				if len(positionsList)==0 : tempname = WindowManager.getUniqueName("image"+str(i+1))
				else : tempname = positionsList[i]
				tempd = tempfile.mkdtemp()
				fichier = open(tempd+os.path.sep+tempname+".tif","w")
				zerotimes=0
				for j in range(len(listfiles[i])-1) :
					difftimes=int((os.stat(listfiles[i][j+1]).st_mtime-os.stat(listfiles[i][j]).st_mtime))
					if difftimes==0 : zerotimes+=1
					rawtimes.append(rawtimes[-1]+difftimes)
					fichier.writelines(listfiles[i][j]+"\n")

				fichier.writelines(listfiles[i][-1]+"\n")
				fichier.close()
				IJ.run("Stack From List...","open="+tempd+os.path.sep+tempname+".tif")
				n=WindowManager.getImageCount()
				tempid=WindowManager.getNthImageID(n)
				tempimg=WindowManager.getImage(tempid)
				tempimg.show()
				#self.__dictImages[tempname]=tempimg
				nameimages.append(tempname)
				#if zerotimes/len(rawtimes) > 0.5 : rawtimes=range(len(listfiles[i]))
				
				#self.__dictTimeStack[tempname]=rawtimes
				rawtimes=[] 
				rawtimes.append(0)
								
		
		else : 
			nameimages=[]
			print "ERROR IN BUILDSTACK"

		return nameimages