Beispiel #1
0
    def _loadVisualizeItersAndRefs(self):
        """ Load selected iterations and classes 3D for visualization mode. """
        DisplayRef3DNo = self.parser.getTkValue('DisplayRef3DNo')
        VisualizeIter = self.parser.getTkValue('VisualizeIter')
        
        if DisplayRef3DNo == 'all':
            self._visualizeRef3Ds = range(1, self.NumberOfClasses + 1)
        else:
            self._visualizeRef3Ds = getListFromRangeString(self.parser.getTkValue('SelectedRef3DNo'))
        
        self._visualizeNrefs = len(self._visualizeRef3Ds)
        lastIteration = self.lastIter()
        firstIter = self.firstIter()
        
        if VisualizeIter == 'last':
            self._visualizeIterations = [lastIteration]
        else:
            self._visualizeIterations = getListFromRangeString(self.parser.getTkValue('SelectedIters'))

        self._visualizeLastIteration = self._visualizeIterations[-1]
        self._visualizeLastRef3D = self._visualizeRef3Ds[-1]
        
        self._visualizeVolumesMode = self.parser.getTkValue('DisplayReconstruction')
        
        from matplotlib.ticker import FuncFormatter
        self._plotFormatter = FuncFormatter(self._formatFreq) 
Beispiel #2
0
    def validate(self):
        errors = []
        classSelection = getListFromRangeString(self.SelectedClasses)
        blocks = getBlocksInMetaDataFile(self.ClassifMd)
        self.ExtractDir = getWorkingDirFromRunName(self.ExtractionRun)

        for classNo in classSelection:
            blockName = "class%06d_images" % classNo
            if not blockName in blocks:
                errors.append("%s cannot be found at %s" % (blockName, self.ClassifMd))
        if self.CenterMaxShift > 100 or self.CenterMaxShift < 0:
            errors.append("Maximum shift must be in the range 0-100")
        if self.LowPassFilter > 0.5 or self.LowPassFilter < 0:
            errors.append("Low pass filter must be in the range 0-0.5")

        files = [getImagesFilename(self.ExtractDir, s) for s in ["", "untilted", "tilted"]]
        fnMicrographs = getProtocolFilename("micrographs", WorkingDir=self.ExtractDir)
        files.append(fnMicrographs)
        for f in files:
            if not exists(f):
                errors.append("Cannot find file: %s" % f)

        if exists(fnMicrographs):
            blocks = getBlocksInMetaDataFile(fnMicrographs)
            if not "micrographPairs" in blocks:
                errors.append("Cannot find block micrographPairs@" + fnMicrographs)

        return errors
Beispiel #3
0
 def visualize(self):
     from protlib_utils import runShowJ
     fnSubset=""
     if self.WhatToShow=="Classes":
         fnSubset=""
     elif self.WhatToShow=="Class Cores":
         fnSubset="_core"
     elif self.WhatToShow=="Class Stable Cores":
         fnSubset="_stable_core"
     levelFiles=glob.glob(os.path.join(self.ExtraDir,"level_??/level_classes%s.xmd"%fnSubset))
     if levelFiles:
         levelFiles.sort()
         lastLevelFile=levelFiles[-1]
         if self.DoShowLast:
             runShowJ("classes@"+lastLevelFile)
         else:
             listOfLevels = getListFromRangeString(self.LevelsToShow)
             lastLevel=int(re.search('level_(\d\d)',lastLevelFile).group(1))
             if max(listOfLevels)<=lastLevel:
                 files = "";
                 for level in listOfLevels:
                     fn=os.path.join(self.ExtraDir,"level_%02d/level_classes%s.xmd"%(level,fnSubset))
                     if os.path.exists(fn):
                         files+="classes_sorted@"+fn+" "
                 if files!="":
                     runShowJ(files)
     if self.DoShowHierarchy:
         fnHierarchy=self.getFilename("hierarchy",subset=fnSubset)
         if os.path.exists(fnHierarchy):
             from protlib_gui_ext import showTextfileViewer
             showTextfileViewer(fnHierarchy,[fnHierarchy])
Beispiel #4
0
 def visualize(self):
     if self.DoShowList:
         fnVolumes = self.workingDirPath('proposedVolumes.xmd')
         runShowJ(fnVolumes)
     if self.VolumesToShow!="":
         listOfVolumes = getListFromRangeString(self.VolumesToShow)
         for volume in listOfVolumes:
             fnRoot=os.path.join(WorkingDir,'Structure00000_core_extended','proposedVolume%05d'%volume)
             os.system("xmipp_chimera_client -i %s.vol --mode projector 256 --angulardist %s.xmd"%(fnRoot,fnRoot))
 def visualize(self):
     if self.DoShowList:
         fnVolumes = self.workingDirPath('volumesProposed.xmd')
         runShowJ(fnVolumes)
     if self.VolumesToShow!="":
         listOfVolumes = getListFromRangeString(self.VolumesToShow)
         for volume in listOfVolumes:
             fnRoot=self.workingDirPath('volumeProposed%05d'%int(volume))
             os.system("xmipp_chimera_client -i %s.vol --mode projector 256 --angulardist %s.xmd"%(fnRoot,fnRoot))
Beispiel #6
0
    def summary(self):
        message = []
        classSelection = getListFromRangeString(self.SelectedClasses)
        message.append(
            "Random conical tilt reconstruction of %d classes of [%s]" % (len(classSelection), self.ClassifMd)
        )
        import glob

        reconstructedFiles = glob.glob(self.WorkingDir + "/rct_??????.vol")
        if not reconstructedFiles:
            message.append("No reconstruction has been generated")
        else:
            message.append(str(len(reconstructedFiles)) + " reconstructions have finished")
        return message
Beispiel #7
0
    def defineSteps(self):
        self.insertStep("createDir", path=self.ExtraDir)
        pickingDir = getWorkingDirFromRunName(self.ExtractionRun)
        self.insertStep("createLink2", filename="acquisition_info.xmd", dirSrc=pickingDir, dirDest=self.WorkingDir)

        classSelection = getListFromRangeString(self.SelectedClasses)
        fnRCTClasses = self.extraPath("rct_classes.xmd")
        self.insertStep(
            "gatherPairs",
            verifyfiles=[fnRCTClasses],
            WorkingDir=self.WorkingDir,
            ExtraDir=self.ExtraDir,
            ClassSelection=classSelection,
            ClassFile=self.ClassifMd,
            ExtractDir=self.ExtractDir,
            PickingDir=pickingDir,
        )

        mdClasses = MetaData("classes@" + self.ClassifMd)
        hasImage = mdClasses.containsLabel(MDL_IMAGE)

        for classId in mdClasses:
            classNo = mdClasses.getValue(MDL_REF, classId)
            if classNo in classSelection:
                # Locate class representative
                classImage = ""
                if hasImage:
                    classImage = mdClasses.getValue(MDL_IMAGE, classId)
                classNameIn = "class%06d_images@%s" % (classNo, fnRCTClasses)
                classNameOut = self.extraPath("rct_images_%06d.xmd" % classNo)
                classVolumeOut = self.workingDirPath("rct_%06d.vol" % classNo)
                self.insertParallelStep(
                    "reconstructClass",
                    verifyfiles=[classNameOut, classVolumeOut],
                    WorkingDir=self.WorkingDir,
                    ExtraDir=self.ExtraDir,
                    ClassNameIn=classNameIn,
                    ClassNameOut=classNameOut,
                    ClassImage=classImage,
                    CenterMaxShift=self.CenterMaxShift,
                    ThinObject=self.ThinObject,
                    SkipTiltedTranslations=self.SkipTiltedTranslations,
                    ClassVolumeOut=classVolumeOut,
                    ReconstructAdditionalParams=self.ReconstructAdditionalParams,
                    DoLowPassFilter=self.DoLowPassFilter,
                    LowPassFilter=self.LowPassFilter,
                    parent_step_id=XmippProjectDb.FIRST_STEP,
                )
Beispiel #8
0
 def visualize(self):
     classSelection = getListFromRangeString(self.SelectedClasses)
     for classNo in classSelection:
         fnVol = self.workingDirPath("rct_%06d.vol" % classNo)
         if exists(fnVol):
             runShowJ(fnVol)