def readSetOfCoordinates(outputDir, micSet, coordSet): """ Read from Bsoft .star files. Params: outputDir: the directory where the .star files are. micSet: the SetOfMicrographs to associate the .star, which name should be the same of the micrographs. coordSet: the SetOfCoordinates that will be populated. """ addBsoftLabelAliases() boxSize = 0 for mic in micSet: outputFile = join(outputDir, replaceBaseExt(mic.getFileName(), 'star')) #scipionPosFile = join(outputDir, "scipion_" + replaceBaseExt(mic.getFileName(), 'pos')) if exists(outputFile): posMd = xmipp.MetaData(outputFile) for objId in posMd: coord = rowToCoordinate(rowFromMd(posMd, objId)) boxSize = 2 * posMd.getValue(xmipp.MDL_PICKING_PARTICLE_SIZE, objId) coord.setMicrograph(mic) coord.setX(coord.getX()) coord.setY(coord.getY()) coordSet.append(coord) # Add an unique ID that will be propagated to particles posMd.setValue(xmipp.MDL_ITEM_ID, long(coord.getObjId()), objId) # if not posMd.isEmpty(): # posMd.write("particles@%s" % scipionPosFile) #reading origin.x value and converting to particle size, can change, we take last value coordSet.setBoxSize(boxSize)
def readSetOfCoordinates(outputDir, micSet, coordSet): """ Read from Bsoft .star files. Params: outputDir: the directory where the .star files are. micSet: the SetOfMicrographs to associate the .star, which name should be the same of the micrographs. coordSet: the SetOfCoordinates that will be populated. """ addBsoftLabelAliases() boxSize = 0 for mic in micSet: outputFile = join(outputDir, replaceBaseExt(mic.getFileName(), 'star')) #scipionPosFile = join(outputDir, "scipion_" + replaceBaseExt(mic.getFileName(), 'pos')) if exists(outputFile): posMd = xmipp.MetaData(outputFile) for objId in posMd: coord = rowToCoordinate(rowFromMd(posMd, objId)) boxSize = 2 * posMd.getValue(xmipp.MDL_PICKING_PARTICLE_SIZE, objId) coord.setMicrograph(mic) coord.setX(coord.getX()) coord.setY(coord.getY()) coordSet.append(coord) # Add an unique ID that will be propagated to particles posMd.setValue(xmipp.MDL_ITEM_ID, long(coord.getObjId()), objId) # if not posMd.isEmpty(): # posMd.write("particles@%s" % scipionPosFile) #reading origin.x value and converting to particle size, can change, we take last value coordSet.setBoxSize(boxSize)
def readCoordinates(part, fileName, coordsSet, outputDir): from pyworkflow.em.packages.xmipp3.convert import (readPosCoordinates, rowToCoordinate, rowFromMd) posMd = readPosCoordinates(fileName) for objId in posMd: coord = rowToCoordinate(rowFromMd(posMd, objId)) coord.setX(coord.getX()) coord.setY(coord.getY()) coord.setMicId(part.getObjId()) coord._subparticle = part coordsSet.append(coord)
def readCoordinates(part, fileName, coordsSet, outputDir): from pyworkflow.em.packages.xmipp3.convert import (readPosCoordinates, rowToCoordinate, rowFromMd) posMd = readPosCoordinates(fileName) for objId in posMd: coord = rowToCoordinate(rowFromMd(posMd, objId)) coord.setX(coord.getX()) coord.setY(coord.getY()) coord.setMicId(part.getObjId()) coord._subparticle = part coordsSet.append(coord)
def importCoordinates(self, fileName, addCoordinate): posMd = readPosCoordinates(fileName) for objId in posMd: coord = rowToCoordinate(rowFromMd(posMd, objId)) addCoordinate(coord)