Exemplo n.º 1
0
    def visualize(self):
        from protlib_gui_figure import XmippArrayPlotter1D, XmippArrayPlotter2D, XmippArrayPlotter3D

        components = self.DisplayRawDeformation.split()
        dim = len(components)
        if dim > 0:
            modeList = []
            modeNameList = []
            # Get modes
            MD = MetaData(self.Modesfile)
            MD.removeDisabled()
            for modeComponent in components:
                mode = int(modeComponent)
                if mode > MD.size():
                    from protlib_gui_ext import showWarning

                    showWarning("Warning", "You don't have so many modes", parent=self.master)
                else:
                    mode -= 1
                    currentMode = 0
                    modeName = ""
                    for id in MD:
                        modeName = MD.getValue(MDL_NMA_MODEFILE, id)
                        currentMode += 1
                        if currentMode > mode:
                            break
                    modeNameList.append(modeName)
                    modeList.append(mode)

            # Actually plot
            if dim == 1:
                XmippArrayPlotter1D(
                    self.extraPath("deformations.txt"),
                    modeList[0],
                    "Histogram for mode %s" % modeNameList[0],
                    "Deformation value",
                    "Number of images",
                )
            elif dim == 2:
                XmippArrayPlotter2D(
                    self.extraPath("deformations.txt"), modeList[0], modeList[1], "", modeNameList[0], modeNameList[1]
                )
            elif dim == 3:
                XmippArrayPlotter3D(
                    self.extraPath("deformations.txt"),
                    modeList[0],
                    modeList[1],
                    modeList[2],
                    "",
                    modeNameList[0],
                    modeNameList[1],
                    modeNameList[2],
                )
Exemplo n.º 2
0
def readPosCoordinates(posFile):
    """ Read the coordinates in .pos file and return corresponding metadata.
    There are two possible blocks with particles:
    particles: with manual/supervised particles
    particles_auto: with automatically picked particles.
    If posFile doesn't exist, the metadata will be empty 
    """
    md = MetaData()
    
    if exists(posFile):
        blocks = getBlocksInMetaDataFile(posFile)
        
        for b in ['particles', 'particles_auto']:
            if b in blocks:
                mdAux = MetaData('%(b)s@%(posFile)s' % locals())
                md.unionAll(mdAux)
        md.removeDisabled()
    
    return md
Exemplo n.º 3
0
def getMdSizeEnabled(filename):
    """ Return the metadata size containing only ''enabled'' lines """
    md = MetaData(filename)
    md.removeDisabled()
    return md.size()