コード例 #1
0
    def _fillClasses(self, outputClasses):
        """ Create the SetOfClasses2D """
        inputSet = self.inputClasses.get().getImages()
        myRep = md.MetaData('classes@' + self._getExtraPath(
            'final_classes.xmd'))

        for row in md.iterRows(myRep):
            fn = row.getValue(md.MDL_IMAGE)
            rep = Particle()
            rep.setLocation(xmippToLocation(fn))
            repId = row.getObjId()
            newClass = Class2D(objId=repId)
            newClass.setAlignment2D()
            newClass.copyInfo(inputSet)
            newClass.setAcquisition(inputSet.getAcquisition())
            newClass.setRepresentative(rep)
            outputClasses.append(newClass)

        i=1
        mdBlocks = md.getBlocksInMetaDataFile(self._getExtraPath(
            'final_classes.xmd'))
        for block in mdBlocks:
            if block.startswith('class00'):
                mdClass = md.MetaData(block + "@" + self._getExtraPath(
                                      'final_classes.xmd'))
                imgClassId = i
                newClass = outputClasses[imgClassId]
                newClass.enableAppend()
                for row in md.iterRows(mdClass):
                    part = rowToParticle(row)
                    newClass.append(part)
                i+=1
                newClass.setAlignment2D()
                outputClasses.update(newClass)
コード例 #2
0
 def _fillAverages(self, avgSet):
     """ Create the SetOfAverages from a given metadata """
     myFileClasses = "classes@" + self._getExtraPath('last_classes.xmd')
     repSet = md.MetaData(myFileClasses)
     for rep in md.iterRows(repSet):
         particle = rowToParticle(rep)
         repId = rep.getValue(md.MDL_REF)  #rep.getObjId()
         particle.setObjId(repId)
         avgSet.append(particle)
コード例 #3
0
    def _fillParticles(self, outputParticles, outputCoords, inputParticles):
        """ Create the SetOfParticles and SetOfCoordinates"""
        myParticles = md.MetaData(self._getExtraPath('final_images.xmd'))
        outputParticles.enableAppend()
        outputCoords.enableAppend()

        #Calculating the scale that relates the coordinates with the actual
        # position in the mic
        scale = inputParticles.getSamplingRate() / \
                self.inputMics.get().getSamplingRate()
        #Dictionary with the name and id of the inpt mics
        micDictname = {}
        micDictId = {}
        for mic in self.inputMics.get():
            micKey = mic.getMicName()
            micDictname[micKey] = mic.clone()
            micKey2 = mic.getObjId()
            micDictId[micKey2] = mic.clone()

        for row in md.iterRows(myParticles):
            #To create the new particle
            p = rowToParticle(row)

            #To create the new coordinate
            newCoord = Coordinate()
            coord = p.getCoordinate()
            if coord.getMicName() is not None:
                micKey = coord.getMicName()
                micDict = micDictname
            else:
                micKey = coord.getMicId()
                micDict = micDictId
            mic = micDict.get(micKey, None)
            if mic is None:
                print("Skipping particle, key %s not found" % micKey)
            else:
                newCoord.copyObjId(p)
                x, y = coord.getPosition()
                newCoord.setPosition(x * scale, y * scale)
                newCoord.setMicrograph(mic)
                outputCoords.append(newCoord)
                p.setCoordinate(newCoord)
            #Storing the new particle
            outputParticles.append(p)

        boxSize = inputParticles.getXDim() * scale
        outputCoords.setBoxSize(boxSize)