def commitToDatabase(self, imgdata):
		"""
		Uses the appionLoop commit
		"""
		imgassess = apDatabase.getImgCompleteStatus(imgdata)
		tiltdata = apTiltPair.getTiltPair(imgdata)
		msg = not self.params['background']
		if tiltdata is None:
			if imgassess is not False:
				apDisplay.printColor("\nrejecting unpaired image: "+apDisplay.short(imgdata['filename']), "red")
				apDatabase.insertImgAssessmentStatus(imgdata, self.params['runid'], False, msg=msg)
				self.reject+=1
			return
		if self.params['background'] is False:
			apDisplay.printMsg("tiltpair: "+apDisplay.short(tiltdata['filename']))
		tiltassess = apDatabase.getImgCompleteStatus(tiltdata)
		if imgassess is False or tiltassess is False:
			if imgassess is not False:
				apDisplay.printColor("\nrejecting bad tilt images: "+apDisplay.short(imgdata['filename']), "magenta")
			if tiltassess is not False:
				apDisplay.printColor("\nrejecting bad tilt images: "+apDisplay.short(tiltdata['filename']), "magenta")
			apDatabase.insertImgAssessmentStatus(imgdata, self.params['runid'], False, msg=msg)
			apDatabase.insertImgAssessmentStatus(tiltdata, self.params['runid'], False, msg=msg)
			self.reject+=2
		if self.params['background'] is False:
			print "Assessment:", imgassess, tiltassess
		return
	def commitToDatabase(self, imgdata):
		"""
		Uses the appionLoop commit
		"""
		imgassess = apDatabase.getImgCompleteStatus(imgdata)
		tiltdata = apTiltPair.getTiltPair(imgdata)
		msg = not self.params['background']
		if tiltdata is None:
			if imgassess is not False:
				apDisplay.printColor("\nrejecting unpaired image: "+apDisplay.short(imgdata['filename']), "red")
				apDatabase.insertImgAssessmentStatus(imgdata, self.params['runid'], False, msg=msg)
				self.reject+=1
			return
		if self.params['background'] is False:
			apDisplay.printMsg("tiltpair: "+apDisplay.short(tiltdata['filename']))
		tiltassess = apDatabase.getImgCompleteStatus(tiltdata)
		if imgassess is False or tiltassess is False:
			if imgassess is not False:
				apDisplay.printColor("\nrejecting bad tilt images: "+apDisplay.short(imgdata['filename']), "magenta")
			if tiltassess is not False:
				apDisplay.printColor("\nrejecting bad tilt images: "+apDisplay.short(tiltdata['filename']), "magenta")
			apDatabase.insertImgAssessmentStatus(imgdata, self.params['runid'], False, msg=msg)
			apDatabase.insertImgAssessmentStatus(tiltdata, self.params['runid'], False, msg=msg)
			self.reject+=2
		if self.params['background'] is False:
			print "Assessment:", imgassess, tiltassess
		return
Example #3
0
	def getTiltAssess(self, imgdata, tiltdata):
		ass1 = apDatabase.getImgCompleteStatus(imgdata)
		ass2 = apDatabase.getImgCompleteStatus(tiltdata)
		if ass1 is False or ass2 is False:
			return False
		if ass1 is True and ass2 is True:
			return True
		return None
 def loopCheckAndProcess(self):
         allfiles = self.getAllFiles()
         images = []
         for filename in allfiles:
                 if os.path.isfile(filename) and '_st.mrc' in filename and self.rundata['session']['name'] in filename:
                         try:
                                 imagedata = leginondata.AcquisitionImageData(session=self.rundata['session'],filename=filename[:-7]).query()[0]
                         except:
                                 continue
                         images.append(imagedata)
         self.num_stacks = len(images)
         for imagedata in images:
                 if self.params['limit'] > 0:
                         if self.success_count >= self.params['limit']:
                                 return True
                 # Avoid hidden and trash images
                 if apDatabase.getImgCompleteStatus(imagedata) == False:
                         apDisplay.printMsg('---------------------------------------------------------')
                         apDisplay.printMsg(' Skipping hidden/trashed %s' % imagedata['filename'])
                         apDisplay.printMsg('---------------------------------------------------------')
                         continue
                 apDisplay.printMsg('---------------------------------------------------------')
                 apDisplay.printMsg('  Processing %s' % imagedata['filename'])
                 apDisplay.printMsg('---------------------------------------------------------')
                 self.processImage(imagedata)
                 if self.params['commit']:
                         self.commitToDatabase(imagedata)
                 apDisplay.printMsg('\n')
         return False
Example #5
0
    def skipTestOnImage(self, imgdata):
        imgname = imgdata['filename']
        skip = False
        reason = None
        #tiltskip is default to None since it might not need evaluation
        tiltskip = None

        if imgname in self.donedict:
            skip = True
            reason = 'done'
        elif self.reprocessImage(imgdata) is False:
            self._writeDoneDict(imgname)
            reason = 'reproc'
            skip = True

        if skip is True:
            return skip, reason
        else:
            # image not done or reprocessing allowed
            # check sibling status instead if wanted
            if self.params['sibassess'] is True:
                status = apDatabase.getSiblingImgCompleteStatus(imgdata)
            else:
                status = apDatabase.getImgCompleteStatus(imgdata)

            if self.params['norejects'] is True and status is False:
                reason = 'reject'
                skip = True

            elif self.params['bestimages'] is True and status is not True:
                reason = 'reject'
                skip = True

            elif (self.params['tiltangle'] is not None
                  or self.params['tiltangle'] != 'all'):
                tiltangle = apDatabase.getTiltAngleDeg(imgdata)

                tiltangle = apDatabase.getTiltAngleDeg(imgdata)
                if (self.params['tiltangle'] == 'notilt'
                        and abs(tiltangle) > 3.0):
                    skip = True
                elif (self.params['tiltangle'] == 'hightilt'
                      and abs(tiltangle) < 30.0):
                    skip = True
                elif (self.params['tiltangle'] == 'lowtilt'
                      and abs(tiltangle) >= 30.0):
                    skip = True
                ### the reason why -2.0 and 2.0 are used is because the tilt angle is saved as 0 +/- a small amount
                elif (self.params['tiltangle'] == 'minustilt'
                      and tiltangle > -2.0):
                    skip = True
                elif (self.params['tiltangle'] == 'plustilt'
                      and tiltangle < 2.0):
                    skip = True
                if skip == True:
                    reason = 'tilt'

        return skip, reason
 def rejectTiltPairs(self, imgdata):
         tiltdata = apTiltPair.getTiltPair(imgdata)
         if tiltdata is None:
                 apDisplay.printColor("\nrejecting unpaired image: "+apDisplay.short(imgdata['filename']), "red")
                 return False
         tiltassess = apDatabase.getImgCompleteStatus(tiltdata)
         if tiltassess is False:
                 apDisplay.printColor("\nrejecting bad tilt images: "+apDisplay.short(imgdata['filename']), "magenta")
                 return False
         return True
        def skipTestOnImage(self,imgdata):
                imgname = imgdata['filename']
                skip = False
                reason = None
                #tiltskip is default to None since it might not need evaluation
                tiltskip = None

                if imgname in self.donedict:
                        skip = True
                        reason = 'done'
                elif self.reprocessImage(imgdata) is False:
                        self._writeDoneDict(imgname)
                        reason = 'reproc'
                        skip = True

                if skip is True:
                        return skip, reason
                else:
                # image not done or reprocessing allowed
                        # check sibling status instead if wanted
                        if self.params['sibassess'] is True:
                                status=apDatabase.getSiblingImgCompleteStatus(imgdata)
                        else:
                                status=apDatabase.getImgCompleteStatus(imgdata) 

                        if self.params['norejects'] is True and status is False:
                                reason = 'reject'
                                skip = True
                
                        elif self.params['bestimages'] is True and status is not True:
                                reason = 'reject'
                                skip = True

                        elif ( self.params['tiltangle'] is not None or self.params['tiltangle'] != 'all' ):
                                tiltangle = apDatabase.getTiltAngleDeg(imgdata)

                                tiltangle = apDatabase.getTiltAngleDeg(imgdata)
                                if (self.params['tiltangle'] == 'notilt' and abs(tiltangle) > 3.0 ):
                                        skip = True
                                elif (self.params['tiltangle'] == 'hightilt' and abs(tiltangle) < 30.0 ):
                                        skip = True
                                elif (self.params['tiltangle'] == 'lowtilt' and abs(tiltangle) >= 30.0 ):
                                        skip = True
                                ### the reason why -2.0 and 2.0 are used is because the tilt angle is saved as 0 +/- a small amount
                                elif (self.params['tiltangle'] == 'minustilt' and tiltangle > -2.0 ):
                                        skip = True
                                elif (self.params['tiltangle'] == 'plustilt' and tiltangle < 2.0 ):
                                        skip = True
                                if skip == True:
                                        reason = 'tilt'

                return skip, reason
Example #8
0
 def rejectTiltPairs(self, imgdata):
     tiltdata = apTiltPair.getTiltPair(imgdata)
     if tiltdata is None:
         apDisplay.printColor(
             "\nrejecting unpaired image: " +
             apDisplay.short(imgdata['filename']), "red")
         return False
     tiltassess = apDatabase.getImgCompleteStatus(tiltdata)
     if tiltassess is False:
         apDisplay.printColor(
             "\nrejecting bad tilt images: " +
             apDisplay.short(imgdata['filename']), "magenta")
         return False
     return True
Example #9
0
    def chooseValidResultImageInDDAlignPairs(self, alldata):
        '''
		Return the first non-rejected result image
		'''
        if not alldata:
            # no data
            return False
        for pairdata in alldata:
            if apDatabase.getImgCompleteStatus(pairdata['result']) is False:
                # bad status
                continue
            # good status
            return pairdata['result']
        # no data with valid image status
        return False
	def chooseValidResultImageInDDAlignPairs(self, alldata):
		'''
		Return the first non-rejected result image
		'''
		if not alldata:
			# no data
			return False
		for pairdata in alldata:
			if apDatabase.getImgCompleteStatus(pairdata['result']) is False:
				# bad status
				continue
			# good status
			return pairdata['result']
		# no data with valid image status
		return False
Example #11
0
 def loopCheckAndProcess(self):
     allfiles = self.getAllFiles()
     images = []
     for filename in allfiles:
         if os.path.isfile(
                 filename) and '_st.mrc' in filename and self.rundata[
                     'session']['name'] in filename:
             try:
                 imagedata = leginondata.AcquisitionImageData(
                     session=self.rundata['session'],
                     filename=filename[:-7]).query()[0]
             except:
                 continue
             images.append(imagedata)
     self.num_stacks = len(images)
     for imagedata in images:
         if self.params['limit'] > 0:
             if self.success_count >= self.params['limit']:
                 return True
         # Avoid hidden and trash images
         if apDatabase.getImgCompleteStatus(imagedata) == False:
             apDisplay.printMsg(
                 '---------------------------------------------------------'
             )
             apDisplay.printMsg(' Skipping hidden/trashed %s' %
                                imagedata['filename'])
             apDisplay.printMsg(
                 '---------------------------------------------------------'
             )
             continue
         apDisplay.printMsg(
             '---------------------------------------------------------')
         apDisplay.printMsg('  Processing %s' % imagedata['filename'])
         apDisplay.printMsg(
             '---------------------------------------------------------')
         self.processImage(imagedata)
         if self.params['commit']:
             self.commitToDatabase(imagedata)
         apDisplay.printMsg('\n')
     return False