示例#1
0
 def _updateParticle(self, item, row):
     setXmippAttributes(item, row, md.MDL_ANGLE_ROT, md.MDL_ANGLE_TILT,
                        md.MDL_ANGLE_PSI, md.MDL_SHIFT_X, md.MDL_SHIFT_Y,
                        md.MDL_FLIP, md.MDL_SPH_DEFORMATION,
                        md.MDL_SPH_COEFFICIENTS, md.MDL_SPH_TSNE_COEFF1D,
                        md.MDL_SPH_TSNE_COEFF2D)
     createItemMatrix(item, row, align=ALIGN_PROJ)
    def _createItemMatrix(self, particle, row):

        row.setValue(emlib.MDL_SHIFT_X,
                     row.getValue(emlib.MDL_SHIFT_X) * self.scaleFactor)
        row.setValue(emlib.MDL_SHIFT_Y,
                     row.getValue(emlib.MDL_SHIFT_Y) * self.scaleFactor)
        setXmippAttributes(particle, row, emlib.MDL_SHIFT_X,
                           emlib.MDL_SHIFT_Y,
                           emlib.MDL_ANGLE_ROT, emlib.MDL_ANGLE_TILT,
                           emlib.MDL_ANGLE_PSI)
        createItemMatrix(particle, row, align=ALIGN_PROJ)
示例#3
0
    def _processRow(self, particle, row):
        def __setXmippImage(label):
            attr = '_xmipp_' + xmippLib.label2Str(label)
            if not hasattr(particle, attr):
                img = Image()
                setattr(particle, attr, img)
                img.setSamplingRate(particle.getSamplingRate())
            else:
                img = getattr(particle, attr)
            img.setLocation(xmippToLocation(row.getValue(label)))

        particle.setLocation(xmippToLocation(row.getValue(xmippLib.MDL_IMAGE)))
        #__setXmippImage(xmippLib.MDL_IMAGE)
        #__setXmippImage(xmippLib.MDL_IMAGE_REF)

        setXmippAttributes(particle, row, xmippLib.MDL_IMAGE_ORIGINAL,
                           xmippLib.MDL_IMAGE_REF)
 def _processRow(self, particle, row):
     setXmippAttributes(particle, row,
                        xmippLib.MDL_ZSCORE_RESVAR, xmippLib.MDL_ZSCORE_RESMEAN,
                        xmippLib.MDL_ZSCORE_RESCOV, xmippLib.MDL_IMAGE_ORIGINAL,
                        xmippLib.MDL_COST, xmippLib.MDL_CONTINUOUS_GRAY_A,
                        xmippLib.MDL_CONTINUOUS_GRAY_B, xmippLib.MDL_CONTINUOUS_X,
                        xmippLib.MDL_CONTINUOUS_Y,
                        xmippLib.MDL_CORRELATION_IDX, xmippLib.MDL_CORRELATION_MASK,
                        xmippLib.MDL_CORRELATION_WEIGHT, xmippLib.MDL_IMED)
     def __setXmippImage(label):
         attr = '_xmipp_' + xmippLib.label2Str(label)
         if not hasattr(particle, attr):
             img = Image()
             setattr(particle, attr, img)
             img.setSamplingRate(particle.getSamplingRate())
         else:
             img = getattr(particle, attr)
         img.setLocation(xmippToLocation(row.getValue(label)))
     
     __setXmippImage(xmippLib.MDL_IMAGE)
     __setXmippImage(xmippLib.MDL_IMAGE_REF)
     __setXmippImage(xmippLib.MDL_IMAGE_RESIDUAL)
     __setXmippImage(xmippLib.MDL_IMAGE_COVARIANCE)
    def readPartsFromMics(self, micList, outputParts):
        """ Read the particles extract for the given list of micrographs
        and update the outputParts set with new items.
        """
        p = Particle()
        for mic in micList:
            # We need to make this dict because there is no ID in the .xmd file
            coordDict = {}
            for coord in self.coordDict[mic.getObjId()]:
                pos = self._getPos(coord)
                if pos in coordDict:
                    print(
                        "WARNING: Ignoring duplicated coordinate: %s, id=%s" %
                        (coord.getObjId(), pos))
                coordDict[pos] = coord

            added = set()  # Keep track of added coords to avoid duplicates
            fnMicXmd = self._getMicXmd(mic)
            if exists(fnMicXmd):
                for row in md.iterRows(fnMicXmd):
                    pos = (row.getValue(md.MDL_XCOOR),
                           row.getValue(md.MDL_YCOOR))
                    coord = coordDict.get(pos, None)
                    if coord is not None and coord.getObjId() not in added:
                        # scale the coordinates according to particles dimension.
                        coord.scale(self.getBoxScale())
                        p.copyObjId(coord)
                        p.setLocation(
                            xmippToLocation(row.getValue(md.MDL_IMAGE)))
                        p.setCoordinate(coord)
                        p.setMicId(mic.getObjId())
                        p.setCTF(mic.getCTF())
                        # adding the variance and Gini coeff. value of the mic zone
                        setXmippAttributes(p, row, md.MDL_SCORE_BY_VAR)
                        setXmippAttributes(p, row, md.MDL_SCORE_BY_GINI)
                        if row.containsLabel(md.MDL_ZSCORE_DEEPLEARNING1):
                            setXmippAttributes(p, row,
                                               md.MDL_ZSCORE_DEEPLEARNING1)

                        # disabled particles (in metadata) should not add to the
                        # final set
                        if row.getValue(md.MDL_ENABLED) > 0:
                            outputParts.append(p)
                            added.add(coord.getObjId())

            # Release the list of coordinates for this micrograph since it
            # will not be longer needed
            del self.coordDict[mic.getObjId()]
    def _updateClass(self, item):
        classId = item.getObjId()
        classRow = findRow(self.mdClasses, xmippLib.MDL_REF2, classId)

        representative = item.getRepresentative()
        representative.setTransform(rowToAlignment(classRow, ALIGN_PROJ))
        representative.setLocation(xmippToLocation(classRow.getValue(xmippLib.MDL_IMAGE)))
        setXmippAttributes(representative, classRow, xmippLib.MDL_ANGLE_ROT)
        setXmippAttributes(representative, classRow, xmippLib.MDL_ANGLE_TILT)
        setXmippAttributes(representative, classRow, xmippLib.MDL_CLASS_COUNT)

        self.averageSet.append(representative)

        reprojection = Image()
        reprojection.setLocation(xmippToLocation(classRow.getValue(xmippLib.MDL_IMAGE1)))
        item.reprojection = reprojection
 def _updateParticle(self, item, row):
     setXmippAttributes(item, row, MD.MDL_ZSCORE_DEEPLEARNING1)
     if row.getValue(MD.MDL_ENABLED) <= 0:
         item._appendItem = False
     else:
         item._appendItem = True
示例#8
0
 def _updateParticle(self, item, row):
     setXmippAttributes(item, row, md.MDL_ANGLE_ROT, md.MDL_ANGLE_TILT,
                        md.MDL_ANGLE_PSI, md.MDL_SHIFT_X, md.MDL_SHIFT_Y,
                        md.MDL_FLIP, md.MDL_NMA, md.MDL_COST)
     createItemMatrix(item, row, align=em.ALIGN_PROJ)
 def _createItemMatrix(self, particle, row):
     setXmippAttributes(particle, row, emlib.MDL_SHIFT_DIFF,
                        emlib.MDL_ANGLE_DIFF)
 def _processRow(self, particle, row):
     particle.setLocation(xmippToLocation(row.getValue(xmippLib.MDL_IMAGE)))
     if self.model.get() == ITER_TRAIN:
         setXmippAttributes(particle, row,
                            xmippLib.MDL_CORR_DENOISED_PROJECTION)
示例#11
0
 def _updateParticle(self, item, row):
     setXmippAttributes(item, row, md.MDL_SCORE_BY_EMPTINESS)
     if row.getValue(md.MDL_ENABLED) <= 0:
         item._appendItem = False
     else:
         item._appendItem = True