Esempio n. 1
0
    def _updateClass(self, item):
        classId = item.getObjId()
        classRow = findRow(self.mdClasses, xmipp.MDL_REF2, classId)

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

        self.averageSet.append(representative)

        reprojection = Image()
        reprojection.setLocation(xmippToLocation(classRow.getValue(xmipp.MDL_IMAGE1)))
        item.reprojection = reprojection
Esempio n. 2
0
    def _updateClass(self, item):
        classId = item.getObjId()
        classRow = findRow(self.mdClasses, xmipp.MDL_REF2, classId)

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

        self.averageSet.append(representative)

        reprojection = Image()
        reprojection.setLocation(xmippToLocation(classRow.getValue(xmipp.MDL_IMAGE1)))
        item.reprojection = reprojection
Esempio n. 3
0
 def _updateItem(self, item, row):
     """ Implement this function to do some
     update actions over each single item
     that will be stored in the output Set.
     """
     # By default update the item location (index, filename)
     # with the new binary data location (after preprocessing)
     newFn = row.getValue(md.MDL_IMAGE)
     newLoc = xmippToLocation(newFn)
     item.setLocation(newLoc)
 def _updateItem(self, item, row):
     """ Implement this function to do some
     update actions over each single item
     that will be stored in the output Set.
     """
     # By default update the item location (index, filename) with the new binary data location
     newFn = row.getValue(xmipp.MDL_IMAGE)
     newLoc = xmippToLocation(newFn)
     item.setLocation(newLoc)
     # Also remove alignment info
     item.setTransform(None)
Esempio n. 5
0
 def _updateItem(self, item, row):
     """ Implement this function to do some
     update actions over each single item
     that will be stored in the output Set.
     """
     # By default update the item location (index, filename) with the new binary data location
     newFn = row.getValue(md.MDL_IMAGE)
     newLoc = xmippToLocation(newFn)
     item.setLocation(newLoc)
     # Also remove alignment info
     item.setTransform(None)
Esempio n. 6
0
 def _loadClassesInfo(self, filename):
     """ Read some information about the produced 2D classes
     from the metadata file.
     """
     self._classesInfo = {} # store classes info, indexed by class id
     
     mdClasses = md.MetaData(filename)
     
     for classNumber, row in enumerate(md.iterRows(mdClasses)):
         index, fn = xmippToLocation(row.getValue(md.MDL_IMAGE))
         # Store info indexed by id, we need to store the row.clone() since
         # the same reference is used for iteration            
         self._classesInfo[classNumber+1] = (index, fn, row.clone())
Esempio n. 7
0
    def _loadClassesInfo(self, filename):
        """ Read some information about the produced 2D classes
        from the metadata file.
        """
        self._classesInfo = {}  # store classes info, indexed by class id

        mdClasses = md.MetaData(filename)

        for classNumber, row in enumerate(md.iterRows(mdClasses)):
            index, fn = xmippToLocation(row.getValue(md.MDL_IMAGE))
            # Store info indexed by id, we need to store the row.clone() since
            # the same reference is used for iteration
            self._classesInfo[classNumber + 1] = (index, fn, row.clone())
    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
            for row in md.iterRows(self._getMicXmd(mic)):
                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())
                    # 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()]
Esempio n. 9
0
 def _preprocessClass(self, classItem, classRow):
     classItem.average = Particle()
     classItem.average.setLocation(
         xmippToLocation(classRow.getValue(xmipp.MDL_IMAGE2)))
Esempio n. 10
0
 def _preprocessClass(self, classItem, classRow):
     classItem.average = Particle()
     classItem.average.setLocation(xmippToLocation(classRow.getValue(xmipp.MDL_IMAGE2)))
Esempio n. 11
0
 def _updateLocation(self, item, row):
     index, filename = xmippToLocation(row.getValue(md.MDL_IMAGE))
     item.setLocation(index, filename)
 def _updateLocation(self, item, row):
     index, filename = xmippToLocation(row.getValue(md.MDL_IMAGE))
     item.setLocation(index, filename)