コード例 #1
0
    def runTiltAligner(self, imgdata, tiltdata):
        ### set tilt
        tilt1 = apDatabase.getTiltAngleDeg(imgdata)
        tilt2 = apDatabase.getTiltAngleDeg(tiltdata)
        theta = abs(tilt2) - abs(tilt1)

        ### pre-load particle picks
        picks1 = self.getParticlePicks(imgdata)
        picks2 = self.getParticlePicks(tiltdata)
        if len(picks1) < 10 or len(picks2) < 10:
            apDisplay.printWarning(
                "Not enough particles ot run program on image pair")
            self.badprocess = True
            return

        ### set image file 1
        imgname = imgdata['filename'] + ".dwn.mrc"
        imgpath = os.path.join(self.params['rundir'], imgname)

        ### set tilt file 2
        tiltname = tiltdata['filename'] + ".dwn.mrc"
        tiltpath = os.path.join(self.params['rundir'], tiltname)

        ### set out file
        outname1 = os.path.basename(
            imgdata['filename']) + "." + self.getExtension()
        outfile1 = os.path.join(self.params['pickdatadir'], outname1)
        outname2 = os.path.basename(
            tiltdata['filename']) + "." + self.getExtension()
        outfile2 = os.path.join(self.params['pickdatadir'], outname1)

        pixdiam = self.params['diam'] / self.params['apix'] / self.params['bin']
        tiltaxis = self.params['inittiltaxis']

        ### run tilt automation
        autotilter = autotilt.autoTilt()
        result = autotilter.processTiltPair(imgpath, tiltpath, picks1, picks2,
                                            theta, outfile1, pixdiam, tiltaxis)
        if result is None:
            apDisplay.printWarning("Image processing failed")
            self.badprocess = True
            return

        if os.path.isfile(outfile1) and outfile1 != outfile2:
            if os.path.exists(outfile2):
                os.remove(outfile2)
            os.symlink(os.path.basename(outfile1), outfile2)

        ### read alignment results
        if not os.path.isfile(outfile1):
            apDisplay.printWarning("Image processing failed")
            self.badprocess = True
            return
        self.data = tiltfile.readData(outfile1)
        self.currentpicks1 = numpy.asarray(self.data['picks1'])
        self.currentpicks2 = numpy.asarray(self.data['picks2'])

        #print self.data
        # 1. tilt data are copied to self.tiltparams by app
        # 2. particles picks are copied to self.peaks1 and self.peaks2 by app
        # 3. particle errors are copied to self.peakerrors by app
        # 4. assessment status is  copied to self.assess
        self.peaktree1 = apPeaks.convertListToPeaks(self.currentpicks1,
                                                    self.params)
        self.peaktree2 = apPeaks.convertListToPeaks(self.currentpicks2,
                                                    self.params)
        self.peakerrors = self.getRmsdArray()
        self.getOverlap(imgpath, tiltpath)
コード例 #2
0
	def runTiltAligner(self, imgdata, tiltdata):
		#reset targets
		self.app.onResetParams(None, False)
		self.tiltparams = {}

		#set tilt
		tilt1 = apDatabase.getTiltAngleDeg(imgdata)
		tilt2 = apDatabase.getTiltAngleDeg(tiltdata)
		self.theta = abs(tilt2) - abs(tilt1)
		self.app.data['theta'] = self.theta
		self.app.data['filetypeindex'] = self.params['outtypeindex']
		outname = os.path.basename(imgdata['filename'])+"."+self.getExtension()
		outfile = os.path.join(self.params['pickdatadir'], outname)
		self.app.data['outfile'] = outfile
		self.app.data['dirname'] = self.params['pickdatadir']
		self.app.data['image1file'] = apDisplay.short(imgdata['filename'])
		self.app.data['image2file'] = apDisplay.short(tiltdata['filename'])
		self.app.data['pixdiam'] = self.params['diam']/self.params['apix']/self.params['bin']
		#print "pixdiam=", self.app.data['pixdiam']
		#print "theta=",self.app.data['theta']

		#pre-load particle picks
		self.app.picks1 = self.getParticlePicks(imgdata)
		self.app.picks2 = self.getParticlePicks(tiltdata)

		#set image assessment
		self.assess = self.getTiltAssess(imgdata, tiltdata)
		self.assessold = self.assess
		self.app.setAssessStatus()

		#open image file 1
		imgname = imgdata['filename']+".dwn.mrc"
		imgpath = os.path.join(self.params['rundir'],imgname)
		self.app.panel1.openImageFile(imgpath)

		#open tilt file 2
		tiltname = tiltdata['filename']+".dwn.mrc"
		tiltpath = os.path.join(self.params['rundir'],tiltname)
		self.app.panel2.openImageFile(tiltpath)

		#guess the shift
		outfile = self.app.data['outfile']
		if not os.path.exists(outfile):
			if self.params['autopick'] is True and self.params['importalign'] is False:
				if len(self.app.picks1) > 0 and len(self.app.picks2) > 0:
					apDisplay.printMsg("Autopicking image")
					self.app.onGuessShift(None)
			elif self.params['importalign'] is True:
				self.importPreviousTiltParams(imgdata)
		else:
			self.app.readData(outfile)
			self.app.onAutoOptim(None)
		time.sleep(0.1)

		#run the picker
		self.app.MainLoop()

		#########################################
		# RESULTS
		#########################################

		self.app.panel1.openImageFile(None)
		self.app.panel2.openImageFile(None)

		# 1. tilt data are copied to self.tiltparams by app
		# 2. particles picks are copied to self.peaks1 and self.peaks2 by app
		# 3. particle errors are copied to self.peakerrors by app
		# 4. assessment status is  copied to self.assess
		self.appdata = self.app.data
		self.peaktree1 = apPeaks.convertListToPeaks(self.peaks1, self.params)
		self.peaktree2 = apPeaks.convertListToPeaks(self.peaks2, self.params)
コード例 #3
0
	def runTiltAligner(self, imgdata, tiltdata):
		### set tilt
		tilt1 = apDatabase.getTiltAngleDeg(imgdata)
		tilt2 = apDatabase.getTiltAngleDeg(tiltdata)
		theta = abs(tilt2) - abs(tilt1)

		### pre-load particle picks
		picks1 = self.getParticlePicks(imgdata)
		picks2 = self.getParticlePicks(tiltdata)
		if len(picks1) < 10 or len(picks2) < 10:
			apDisplay.printWarning("Not enough particles ot run program on image pair")
			self.badprocess = True
			return

		### set image file 1
		imgname  = imgdata['filename']+".dwn.mrc"
		imgpath  = os.path.join(self.params['rundir'], imgname)

		### set tilt file 2
		tiltname = tiltdata['filename']+".dwn.mrc"
		tiltpath = os.path.join(self.params['rundir'], tiltname)

		### set out file
		outname1 = os.path.basename(imgdata['filename'])+"."+self.getExtension()
		outfile1 = os.path.join(self.params['pickdatadir'], outname1)
		outname2 = os.path.basename(tiltdata['filename'])+"."+self.getExtension()
		outfile2 = os.path.join(self.params['pickdatadir'], outname1)

		pixdiam = self.params['diam']/self.params['apix']/self.params['bin']
		tiltaxis = self.params['inittiltaxis']

		### run tilt automation
		autotilter = autotilt.autoTilt()
		result = autotilter.processTiltPair(imgpath, tiltpath, picks1, picks2, theta, outfile1, pixdiam, tiltaxis)
		if result is None:
			apDisplay.printWarning("Image processing failed")
			self.badprocess = True
			return

		if os.path.isfile(outfile1) and outfile1 != outfile2:
			if os.path.exists(outfile2):
				os.remove(outfile2)
			os.symlink(os.path.basename(outfile1), outfile2)

		### read alignment results
		if not os.path.isfile(outfile1):
			apDisplay.printWarning("Image processing failed")
			self.badprocess = True
			return
		self.data = tiltfile.readData(outfile1)
		self.currentpicks1 = numpy.asarray(self.data['picks1'])
		self.currentpicks2 = numpy.asarray(self.data['picks2'])

		#print self.data
		# 1. tilt data are copied to self.tiltparams by app
		# 2. particles picks are copied to self.peaks1 and self.peaks2 by app
		# 3. particle errors are copied to self.peakerrors by app
		# 4. assessment status is  copied to self.assess
		self.peaktree1 = apPeaks.convertListToPeaks(self.currentpicks1, self.params)
		self.peaktree2 = apPeaks.convertListToPeaks(self.currentpicks2, self.params)
		self.peakerrors = self.getRmsdArray()
		self.getOverlap(imgpath, tiltpath)