예제 #1
0
    def evaluateSingleMicrograph(self, micFn, micDir):
        mdCTFparam = xmipp.MetaData(
            self._getFileName('ctfparam', micDir=micDir))
        ctfDownFactor = mdCTFparam.getValue(xmipp.MDL_CTF_DOWNSAMPLE_PERFORMED,
                                            mdCTFparam.firstObject())

        mdEval = md.MetaData()
        objId = mdEval.addObject()

        # Check what happen with movies
        #             if md.MDL_TYPE == md.MDL_MICROGRAPH_MOVIE:
        #                 mdEval.setValue(md.MDL_MICROGRAPH_MOVIE, micFn, objId)
        #                 mdEval.setValue(md.MDL_MICROGRAPH,('%05d@%s'%(1, micFn)), objId)
        #             else:
        mdEval.setValue(md.MDL_MICROGRAPH, micFn, objId)

        mdEval.setValue(md.MDL_PSD,
                        str(self._getFileName('psd', micDir=micDir)), objId)
        mdEval.setValue(md.MDL_PSD_ENHANCED,
                        str(self._getFileName('enhanced_psd', micDir=micDir)),
                        objId)
        mdEval.setValue(md.MDL_CTF_MODEL,
                        str(self._getFileName('ctfparam', micDir=micDir)),
                        objId)
        mdEval.setValue(
            md.MDL_IMAGE1,
            str(self._getFileName('ctfmodel_quadrant', micDir=micDir)), objId)
        mdEval.setValue(
            md.MDL_IMAGE2,
            str(self._getFileName('ctfmodel_halfplane', micDir=micDir)), objId)
        mdEval.setValue(md.MDL_CTF_DOWNSAMPLE_PERFORMED, float(ctfDownFactor),
                        objId)
        fnEval = self._getFileName('ctf', micDir=micDir)
        mdEval.write(fnEval)

        # Evaluate if estimated ctf is good enough
        # self.runJob("xmipp_ctf_sort_psds","-i %s --downsampling %f"%(fnEval,ctfDownFactor))
        try:
            self.runJob("xmipp_ctf_sort_psds", "-i %s" % (fnEval))
        except Exception:
            pass
#             print >> sys.stderr, "xmipp_ctf_sort_psds has been Failed!"
#             raise ex

# Check if it is a good micrograph
        fnRejected = self._getTmpPath(basename(micFn + "_rejected.xmd"))
        self.runJob(
            "xmipp_metadata_utilities", '-i %s --query select "%s" -o %s' %
            (fnEval, self._criterion, fnRejected))

        retval = True

        if not isMdEmpty(fnRejected):
            mdCTF = md.MetaData(fnEval)
            mdCTF.setValue(md.MDL_ENABLED, -1, mdCTF.firstObject())
            mdCTF.write(fnEval)
            retval = False
        cleanPath(fnRejected)
        return retval
예제 #2
0
def runReconstructionStep(self, iterN, refN, program, method, args, suffix,
                          **kwargs):
    #if input metadata is empty create a Blanck image
    reconsXmd = 'reconstructionXmd' + suffix
    reconsVol = 'reconstructedFileNamesIters' + suffix
    mdFn = self._getFileName(reconsXmd, iter=iterN, ref=refN)
    volFn = self._getFileName(reconsVol, iter=iterN, ref=refN)
    maskFn = self._getFileName('maskedFileNamesIters', iter=iterN, ref=refN)
    if method == "art":
        mpi = 1
        threads = 1
    else:
        mpi = self.numberOfMpi.get()
        threads = self.numberOfThreads.get()
        args += ' --thr %d' % threads

    if isMdEmpty(mdFn):
        img = xmipp.Image()
        img.read(maskFn)
        #(x,y,z,n) = img.getDimensions()
        self._log.warning(
            "Metadata '%s' is empty. \n Creating a random volume file '%s'" %
            (mdFn, volFn))
        #createEmptyFile(ReconstructedVolume,x,y,z,n)
        img.initRandom()
        img.write(volFn)
    else:
        if method == 'fourier':
            if self._fourierMaxFrequencyOfInterest[iterN] == -1:
                fourierMaxFrequencyOfInterest = self._getFourierMaxFrequencyOfInterest(
                    iterN - 1, refN)
                fourierMaxFrequencyOfInterest = self.resolSam / fourierMaxFrequencyOfInterest + self._constantToAddToMaxReconstructionFrequency[
                    iterN]

                if fourierMaxFrequencyOfInterest > 0.5:
                    fourierMaxFrequencyOfInterest = 0.5
                elif fourierMaxFrequencyOfInterest < 0.:
                    fourierMaxFrequencyOfInterest = 0.001
            else:
                fourierMaxFrequencyOfInterest = self._fourierMaxFrequencyOfInterest[
                    iterN]

            args += ' --max_resolution %s' % fourierMaxFrequencyOfInterest

        if mpi > 1:
            args += ' --mpi_job_size %s' % self.mpiJobSize.get()

        self._log.info(
            '*********************************************************************'
        )
        self._log.info('* Reconstruct volume using %s' % method)
        self.runJob(program,
                    args,
                    numberOfMpi=mpi,
                    numberOfThreads=threads,
                    **kwargs)
예제 #3
0
    def evaluateSingleMicrograph(self, micFn, micDir):
        fnCTF = self._getFileName('ctfparam', micDir=micDir)
        mdCTFparam = md.MetaData(fnCTF)
        objId = mdCTFparam.firstObject()
        mdCTFparam.setValue(md.MDL_MICROGRAPH, micFn, objId)
        mdCTFparam.setValue(md.MDL_PSD,
                            str(self._getFileName('psd', micDir=micDir)), objId)
        mdCTFparam.setValue(md.MDL_PSD_ENHANCED,
                            str(self._getFileName('enhanced_psd',
                                                  micDir=micDir)), objId)
        mdCTFparam.setValue(md.MDL_CTF_MODEL,
                            str(self._getFileName('ctfparam',
                                                  micDir=micDir)), objId)
        mdCTFparam.setValue(md.MDL_IMAGE1,
                            str(self._getFileName('ctfmodel_quadrant',
                                                  micDir=micDir)), objId)
        mdCTFparam.setValue(md.MDL_IMAGE2,
                            str(self._getFileName('ctfmodel_halfplane',
                                                  micDir=micDir)), objId)

        fnEval = self._getFileName('ctf', micDir=micDir)
        mdCTFparam.write(fnEval)

        # Evaluate if estimated ctf is good enough
        try:
            self.runJob("xmipp_ctf_sort_psds", "-i %s" % (fnEval))
        except Exception:
            pass

        # Check if it is a good micrograph
        fnRejected = self._getTmpPath(pwutils.path.basename(micFn +
                                                        "_rejected.xmd"))
        self.runJob("xmipp_metadata_utilities",
                    '-i %s --query select "%s" -o %s'
                    % (fnEval, self._criterion, fnRejected))

        retval = True
        if not isMdEmpty(fnRejected):
            mdCTFparam = md.MetaData(fnEval)
            mdCTFparam.setValue(md.MDL_ENABLED, -1, mdCTFparam.firstObject())
            mdCTFparam.write(fnEval)
            retval = False

        pwutils.path.cleanPath(fnRejected)

        return retval
예제 #4
0
def runReconstructionStep(self, iterN, refN, program, method, args, suffix, **kwargs):
    #if input metadata is empty create a Blanck image
    reconsXmd = 'reconstructionXmd' + suffix
    reconsVol = 'reconstructedFileNamesIters' + suffix
    mdFn = self._getFileName(reconsXmd, iter=iterN, ref=refN)
    volFn = self._getFileName(reconsVol, iter=iterN, ref=refN)
    maskFn = self._getFileName('maskedFileNamesIters', iter=iterN, ref=refN)
    if method=="art":
        mpi = 1
        threads = 1
    else:
        mpi = self.numberOfMpi.get()
        threads = self.numberOfThreads.get()
        args += ' --thr %d' % threads
    
    if isMdEmpty(mdFn):
        img = xmipp.Image()
        img.read(maskFn)
        #(x,y,z,n) = img.getDimensions()
        self._log.warning("Metadata '%s' is empty. \n Creating a random volume file '%s'" % (mdFn, volFn))
        #createEmptyFile(ReconstructedVolume,x,y,z,n)
        img.initRandom()
        img.write(volFn)
    else:
        if method == 'fourier':
            if self._fourierMaxFrequencyOfInterest[iterN] == -1:
                fourierMaxFrequencyOfInterest = self._getFourierMaxFrequencyOfInterest(iterN-1, refN)
                fourierMaxFrequencyOfInterest = self.resolSam / fourierMaxFrequencyOfInterest + self._constantToAddToMaxReconstructionFrequency[iterN]
                
                if fourierMaxFrequencyOfInterest > 0.5:
                    fourierMaxFrequencyOfInterest = 0.5
                elif fourierMaxFrequencyOfInterest < 0.:
                    fourierMaxFrequencyOfInterest = 0.001
            else:
                fourierMaxFrequencyOfInterest = self._fourierMaxFrequencyOfInterest[iterN]
            
            args += ' --max_resolution %s' % fourierMaxFrequencyOfInterest
    
        if mpi > 1:
            args += ' --mpi_job_size %s' % self.mpiJobSize.get()
        
        self._log.info('*********************************************************************')
        self._log.info('* Reconstruct volume using %s' % method)
        self.runJob( program, args, numberOfMpi=mpi, numberOfThreads=threads, **kwargs)
예제 #5
0
    def evaluateSingleMicrograph(self,micFn,micDir):
        mdCTFparam=xmipp.MetaData(self._getFileName('ctfparam', micDir=micDir))
        ctfDownFactor=mdCTFparam.getValue(xmipp.MDL_CTF_DOWNSAMPLE_PERFORMED,mdCTFparam.firstObject())
        
        mdEval = md.MetaData()
        id = mdEval.addObject()

# Check what happen with movies        
#             if md.MDL_TYPE == md.MDL_MICROGRAPH_MOVIE:
#                 mdEval.setValue(md.MDL_MICROGRAPH_MOVIE, micFn, id)
#                 mdEval.setValue(md.MDL_MICROGRAPH,('%05d@%s'%(1, micFn)), id)
#             else:
        mdEval.setValue(md.MDL_MICROGRAPH, micFn, id)
        
        mdEval.setValue(md.MDL_PSD, str(self._getFileName('psd', micDir=micDir)), id)
        mdEval.setValue(md.MDL_PSD_ENHANCED, str(self._getFileName('enhanced_psd', micDir=micDir)), id)
        mdEval.setValue(md.MDL_CTF_MODEL, str(self._getFileName('ctfparam', micDir=micDir)), id)
        mdEval.setValue(md.MDL_IMAGE1, str(self._getFileName('ctfmodel_quadrant', micDir=micDir)), id)
        mdEval.setValue(md.MDL_IMAGE2, str(self._getFileName('ctfmodel_halfplane', micDir=micDir)), id)
        mdEval.setValue(md.MDL_CTF_DOWNSAMPLE_PERFORMED,float(ctfDownFactor), id)
        fnEval = self._getFileName('ctf', micDir=micDir)
        mdEval.write(fnEval)
        
        # Evaluate if estimated ctf is good enough
        # self.runJob("xmipp_ctf_sort_psds","-i %s --downsampling %f"%(fnEval,ctfDownFactor))   
        try:
            self.runJob("xmipp_ctf_sort_psds","-i %s"%(fnEval))
        except Exception:
            pass
#             print >> sys.stderr, "xmipp_ctf_sort_psds has been Failed!"
#             raise ex

        # Check if it is a good micrograph
        fnRejected = self._getTmpPath(basename(micFn +"_rejected.xmd"))
        self.runJob("xmipp_metadata_utilities",'-i %s --query select "%s" -o %s' % (fnEval, self._criterion, fnRejected))
        
        retval=True
        if not isMdEmpty(fnRejected):
            mdCTF = md.MetaData(fnEval)
            mdCTF.setValue(md.MDL_ENABLED, -1, mdCTF.firstObject())
            mdCTF.write(fnEval)
            retval=False
        cleanPath(fnRejected)
        return retval