コード例 #1
0
ファイル: protlib_relion.py プロジェクト: josegutab/scipion
def produceXmippOutputs(log, inputDataStar, 
                        outputImages, outputClasses, outputVolumes,
                        classLabel, classTemplate):
    """ After Relion have finished, produce the files expected by Xmipp.
    Params:
        inputDataStar: the filename of the last data.star images file.
        outputImages: the filename to write the images as expected by xmipp.
        outputClasses: the filename to write the classes and images as expected by xmipp.
        outputVolumes: filename to write a list of produced volumes.
        classLabel: either MDL_REF or MDL_REF3D
    """
    addRelionLabels()
    # Write output images
    md = MetaData(inputDataStar)
    md.write(outputImages)
    # Create the classes metadata
    iteration = getIteration(inputDataStar)
    # If iteration is not None, means that is a classification
    # since for refinenment, the final images should not have iteration
    if iteration is not None:
        createClassesFromImages(inputDataStar, outputClasses, iteration, 
                                classLabel, classTemplate)
        # Write volumes (the same as classes block)
        md.read('classes@' + outputClasses)
        if outputVolumes.endswith('.xmd'): # do not write volumes.xmd for 2d
            md.write('volumes@' + outputVolumes)
    else:
        volFn = inputDataStar.replace('data.star', 'class001.mrc')
        md.clear()
        md.setValue(MDL_IMAGE, volFn, md.addObject())
        if outputVolumes.endswith('.xmd'): # do not write volumes.xmd for 2d
            md.write('volumes@' + outputVolumes)
コード例 #2
0
ファイル: protlib_relion.py プロジェクト: josegutab/scipion
 def _visualizeDisplayResolutionPlotsSSNR(self):
     names = []
     windowTitle = {}
     prefixes = self._getPrefixes()
     
     n = len(prefixes) * self._visualizeNrefs
     gridsize = self._getGridSize(n)
     addRelionLabels()
     activateMathExtensions()
     xplotter = XmippPlotter(*gridsize)
     
     for prefix in prefixes:
         for ref3d in self._visualizeRef3Ds:
           plot_title = 'Resolution SSNR %s, for Class %s' % (prefix, ref3d)
           a = xplotter.createSubPlot(plot_title, 'Armstrongs^-1', 'log(SSNR)', yformat=False)
           blockName = 'model_class_%d@' % ref3d
           legendName = []
           for it in self._visualizeIterations:
               file_name = blockName + self.getFilename(prefix + 'model', iter=it)
               #file_name = self.getFilename('ResolutionXmdFile', iter=it, ref=ref3d)
               self._plotSSNR(a, file_name)
               legendName.append('iter %d' % it)
           xplotter.showLegend(legendName)
           a.grid(True)
     xplotter.show(True)
コード例 #3
0
ファイル: protlib_relion.py プロジェクト: josegutab/scipion
 def _visualizeAvgPMAX(self):         
         addRelionLabels()            
         mdIters = MetaData()
         iterations = range(self.firstIter(), self._visualizeLastIteration+1)
         labels = [MDL_AVGPMAX, MDL_PMAX]
         colors = ['g', 'b']
         prefixes = self._getPrefixes()
         for it in iterations: # range (firstIter,self._visualizeLastIteration+1): #alwaya list all iteration
             objId = mdIters.addObject()
             mdIters.setValue(MDL_ITER, it, objId)
             for i, prefix in enumerate(prefixes):
                 fn = 'model_general@'+ self.getFilename(prefix + 'model', iter=it)
                 md = MetaData(fn)
                 pmax = md.getValue(MDL_AVGPMAX, md.firstObject())
                 mdIters.setValue(labels[i], pmax, objId)
         fn = self.getFilename('all_avgPmax_xmipp')
         mdIters.write(fn)
         #self.display2D(fn, extraParams='--label_relion') //do not display table since labels are confussing                   
         xplotter = XmippPlotter()
         xplotter.createSubPlot("Avg PMax per Iterations", "Iterations", "Avg PMax")
         for label, color in zip(labels, colors):
             xplotter.plotMd(mdIters, MDL_ITER, label, color)
         
         if len(prefixes) > 1:
             xplotter.showLegend(prefixes)
         xplotter.show(True)
コード例 #4
0
ファイル: protlib_relion.py プロジェクト: josegutab/scipion
    def _visualizeDisplayResolutionPlotsFSC(self):
        self.ResolutionThreshold = float(self.parser.getTkValue('ResolutionThreshold'))
        n = self._visualizeNrefs * len(self._getPrefixes())
        gridsize = self._getGridSize(n)
        
        activateMathExtensions()
        addRelionLabels()
        
        xplotter = XmippPlotter(*gridsize, windowTitle='Resolution FSC')

        for prefix in self._getPrefixes():
          for ref3d in self._visualizeRef3Ds:
            plot_title = prefix + 'class %s' % ref3d
            a = xplotter.createSubPlot(plot_title, 'Armstrongs^-1', 'FSC', yformat=False)
            legends = []
            blockName = 'model_class_%d@' % ref3d
            for it in self._visualizeIterations:
                model_star = blockName + self.getFilename(prefix + 'model', iter=it)
                if self._plotFSC(a, model_star):
                    legends.append('iter %d' % it)
            xplotter.showLegend(legends)
            if self.ResolutionThreshold < self.maxFrc:
                a.plot([self.minInv, self.maxInv],[self.ResolutionThreshold, self.ResolutionThreshold], color='black', linestyle='--')
            a.grid(True)
            
        xplotter.show(True)
コード例 #5
0
ファイル: protlib_relion.py プロジェクト: josegutab/scipion
    def _getIterAngularDist(self, it):
        """ Return the .star file with the classes angular distribution
        for this iteration. If the file not exists, it will be written.
        """
        data_angularDist = self.getFilename('angularDist_xmipp', iter=it)
        addRelionLabels()
        
        if not xmippExists(data_angularDist):
            self._writeIterAngularDist(it)
 
        return data_angularDist
コード例 #6
0
ファイル: protlib_relion.py プロジェクト: josegutab/scipion
 def _getIterSortedData(self, it):
     """ Sort the it??.data.star file by the maximum likelihood. """
     addRelionLabels()
     data_sorted = self.getFilename('data_sorted_xmipp', iter=it)
     if not xmippExists(data_sorted):
         print "Sorting particles by likelihood iteration %03d" % it
         fn = 'images@'+ self.getFilename('data', iter=it)
         md = MetaData(fn)
         md.sort(MDL_LL, False)
         md.write('images_sorted@' + data_sorted)
     
     return data_sorted
コード例 #7
0
ファイル: protlib_relion.py プロジェクト: josegutab/scipion
 def _getIterClasses(self, it):
     """ Return the .star file with the classes for this iteration.
     If the file doesn't exists, it will be created. 
     """
     addRelionLabels()
     data_star = self.getFilename('data', iter=it)
     data_classes = self.getFilename('classes_xmipp', iter=it)
     
     if not xmippExists(data_classes):
         createClassesFromImages(data_star, data_classes, it, 
                                 self.ClassLabel, self.ClassFnTemplate)
     return data_classes
コード例 #8
0
ファイル: protlib_relion.py プロジェクト: josegutab/scipion
 def _visualizeTableChange(self): 
         mdIters = MetaData()
         labels = self._getChangeLabels()
         iterations = range(self.firstIter(), self._visualizeLastIteration+1)
         addRelionLabels()
         
         print " Computing average changes in offset, angles, and class membership"
         for it in iterations:
             print "Computing data for iteration; %03d"% (it)
             objId = mdIters.addObject()
             mdIters.setValue(MDL_ITER, it, objId)
             #agregar por ref3D
             fn = self.getFilename('optimiser', iter=it )
             md = MetaData(fn)
             firstId = md.firstObject()
             for label in labels:
                 mdIters.setValue(label, md.getValue(label, firstId), objId)
         fn = self.getFilename('all_changes_xmipp')
         mdIters.write(fn)
         self.display2D(fn, extraParams='--label_relion')