コード例 #1
0
    def _visualize(self, obj, **args):
        cls = type(obj)
        if issubclass(cls, Volume) or issubclass(cls, Image):
            fn = obj.getFileName()
            if pwutils.getExt(fn) in ['.stk', '.vol', '.xmp']:
                # eman2 expects spider files with .spi extension only
                pwutils.createLink(fn, pwutils.replaceExt(fn, 'spi'))
                fn = pwutils.replaceExt(fn, 'spi')
            view = CommandView("%s %s &" %
                               (Plugin.getProgram('e2display.py'), fn),
                               env=Plugin.getEnviron())
            return [view]

        elif isinstance(obj, EmanProtBoxing):
            coords = obj.getCoords()
            if coords:
                return DataViewer._visualize(self, obj.outputCoordinates)

        elif isinstance(obj, EmanProtInitModel):
            obj = obj.outputVolumes
            fn = obj.getFileName()
            labels = 'id enabled comment _filename '
            objCommands = "'%s' '%s' '%s'" % (OBJCMD_CLASSAVG_PROJS,
                                              OBJCMD_PROJS, OBJCMD_INITVOL)

            self._views.append(
                ObjectView(self._project,
                           obj.strId(),
                           fn,
                           viewParams={
                               showj.MODE: showj.MODE_MD,
                               showj.VISIBLE: labels,
                               showj.RENDER: '_filename',
                               showj.OBJCMDS: objCommands
                           }))
            return self._views

        elif isinstance(obj, EmanProtInitModelSGD):
            obj = obj.outputVolumes
            fn = obj.getFileName()
            labels = 'id enabled comment _filename '
            objCommands = "'%s'" % OBJCMD_CLASSAVG_PROJS

            self._views.append(
                ObjectView(self._project,
                           obj.strId(),
                           fn,
                           viewParams={
                               showj.MODE: showj.MODE_MD,
                               showj.VISIBLE: labels,
                               showj.RENDER: '_filename',
                               showj.OBJCMDS: objCommands
                           }))
            return self._views
コード例 #2
0
 def _visualizeImages(self, outputName):
     views = []
     prot = self.protocol
     if hasattr(prot, outputName):
         ouputFn = getattr(prot, outputName).getFileName()
         ouputId = getattr(prot, outputName).strId()
         labels = ('id enabled _index _filename _xmipp_scoreEmptiness '
                   '_xmipp_scoreByVariance _xmipp_zScore '
                   '_xmipp_cumulativeSSNR _sampling '
                   '_ctfModel._defocusU _ctfModel._defocusV '
                   '_ctfModel._defocusAngle _transform._matrix')
         if 'Classes' in outputName:
             views.append(ClassesView(self._project, ouputId, ouputFn))
         else:
             views.append(
                 ObjectView(self._project,
                            ouputId,
                            ouputFn,
                            viewParams={
                                ORDER: labels,
                                VISIBLE: labels,
                                SORT_BY: '_xmipp_scoreEmptiness desc',
                                MODE: MODE_MD,
                                RENDER: '_filename'
                            }))
     else:
         appendStr = ', yet.' if prot.isActive() else '.'
         self.infoMessage('%s does not have %s%s' %
                          (prot.getObjLabel(), outputName, appendStr),
                          title='Info message').show()
     return views
コード例 #3
0
    def _visualizeCtfs(self, objName):
        views = []

        # display metadata with selected variables
        labels = ('id enabled _micObj._filename _psdFile _ctf2_psdFile '
                  '_xmipp_ctfmodel_quadrant '
                  '_defocusU _defocusV _ctf2_defocus_diff '
                  '_astigmatism _ctf2_astigmatism '
                  '_defocusRatio _ctf2_defocusRatio '
                  '_defocusAngle _ctf2_defocusAngle_diff '
                  '_resolution _ctf2_resolution _consensus_resolution '
                  '_phaseShift _ctf2_phaseShift_diff '
                  '_fitQuality _ctf2_fitQuality ')

        if self.protocol.useCritXmipp.get():
            labels += ' '.join(CtfView.EXTRA_LABELS)

        if self.protocol.hasAttribute(objName):
            set = getattr(self.protocol, objName)
            views.append(
                ObjectView(self._project,
                           set.getObjId(),
                           set.getFileName(),
                           viewParams={
                               MODE: MODE_MD,
                               ORDER: labels,
                               VISIBLE: labels
                           }))
        else:
            self.infoMessage('%s does not have %s%s' %
                             (self.protocol.getObjLabel(), objName,
                              getStringIfActive(self.protocol)),
                             title='Info message').show()
        return views
コード例 #4
0
    def _createVolumesSqlite(self):
        """ Write an sqlite with all volumes selected for visualization. """
        path = self.protocol._getExtraPath('viewer_volumes.sqlite')
        samplingRate = self.protocol._getSampling()
        files = self._getVolumeNames()

        self.createVolumesSqlite(files, path, samplingRate)
        return [ObjectView(self._project, self.protocol.strId(), path)]
コード例 #5
0
 def _showCtf(self, paramName=None):
     views = []
     outputType = self.getEnumText('outputType')
     obj = getattr(self.protocol, outputType)
     strId = obj.strId()
     fn = obj.getFileName()
     particlesView = ObjectView(self._project, strId, fn)
     views.append(particlesView)
     return views
コード例 #6
0
 def _viewParam(self, paramName):
     if paramName == 'displayModes':
         modes = self.protocol.outputModes
         return [
             ObjectView(self._project, modes.strId(), modes.getFileName())
         ]
     elif paramName == 'displayMaxDistanceProfile':
         fn = self.protocol._getExtraPath("maxAtomShifts.xmd")
         return [
             createShiftPlot(fn, "Maximum atom shifts", "maximum shift")
         ]
コード例 #7
0
 def _visualize(self, obj, **args):
     if hasattr(self.protocol, "outputVolumes"):
         obj = self.protocol.outputVolumes
         fn = obj.getFileName()
         labels = 'id enabled comment _filename _xmipp_volScoreSum _xmipp_volScoreSumTh _xmipp_volScoreMean _xmipp_volScoreMin'
         self._views.append(ObjectView(self._project, obj.strId(), fn,
                                       viewParams={showj.ORDER: labels, 
                                                   showj.VISIBLE: labels, 
                                                   showj.MODE: showj.MODE_MD,
                                                   showj.RENDER:'_filename'}))
     return self._views
コード例 #8
0
    def _createVolumesSqlite(self):
        """ Write an sqlite with all volumes selected for visualization. """
        path = self.protocol._getExtraPath('3DFSC_viewer_volumes.sqlite')
        samplingRate = self.protocol.inputVolume.get().getSamplingRate()

        vols = self._getVolumeNames()
        files = []
        for vol in vols:
            if os.path.exists(vol):
                files.append(vol)
        self.createVolumesSqlite(files, path, samplingRate)
        return [ObjectView(self._project, self.protocol.strId(), path)]
コード例 #9
0
    def _visualize(self, obj, **kwargs):
        views = []

        if obj.hasAttribute('outputMicrographs'):
            views.append(
                ObjectView(self._project,
                           obj.strId(),
                           obj.outputMicrographs.getFileName(),
                           viewParams=getViewParams()))
        elif obj.hasAttribute('outputMovies'):
            views.append(
                ObjectView(self._project,
                           obj.strId(),
                           obj.outputMovies.getFileName(),
                           viewParams=getViewParams()))
        else:
            views.append(
                self.infoMessage("Output (micrographs or movies) has "
                                 "not been produced yet."))

        return views
コード例 #10
0
 def _showOutputParticles(self, paramName=None):
     views = []
     if hasattr(self.protocol, "outputParticles"):
         obj = self.protocol.outputParticles
         fn = obj.getFileName()
         labels = 'id enabled _filename _xmipp_zScore _xmipp_cumulativeSSNR '
         labels += '_ctfModel._defocusU _ctfModel._defocusV _xmipp_shiftX _xmipp_shiftY _xmipp_tilt _xmipp_scale _xmipp_maxCC _xmipp_weight'
         labels += " _xmipp_cost _xmipp_weightContinuous2 _xmipp_angleDiff0 _xmipp_weightJumper0 _xmipp_angleDiff _xmipp_weightJumper _xmipp_angleDiff2 _xmipp_weightJumper2"
         labels += "_xmipp_weightSSNR _xmipp_maxCCPerc _xmipp_costPerc _xmipp_continuousScaleX _xmipp_continuousScaleY _xmipp_continuousX _xmipp_continuousY _xmipp_continuousA _xmipp_continuousB"
         views.append(ObjectView(self._project, obj.strId(), fn,
                                       viewParams={showj.ORDER: labels, 
                                                   showj.VISIBLE: labels, 
                                                   showj.MODE: showj.MODE_MD,
                                                   showj.RENDER:'_filename'}))
     return views
コード例 #11
0
 def createScipionPartView(self, filename):
     inputParticlesId = self.protocol.inputParticles.get().strId()
     labels = 'enabled id _size _filename _transform._matrix'
     viewParams = {
         showj.ORDER: labels,
         showj.VISIBLE: labels,
         showj.RENDER: '_filename',
         'labels': 'id',
     }
     return ObjectView(self._project,
                       self.protocol.strId(),
                       filename,
                       other=inputParticlesId,
                       env=self._env,
                       viewParams=viewParams)
コード例 #12
0
    def _createVolumesSqlite(self):
        """ Write an sqlite with all volumes selected for visualization. """
        path = self.protocol._getExtraPath('relion_viewer_volumes.sqlite')
        samplingRate = self.protocol.inputParticles.get().getSamplingRate()

        files = []
        volumes = self._getVolumeNames()
        for volFn in volumes:
            if not os.path.exists(volFn.replace(':mrc', '')):
                raise Exception("Missing volume file: %s\n Please select "
                                "a valid class or iteration number." % volFn)
            print("Adding vol: %s" % volFn)
            files.append(volFn)

        self.createVolumesSqlite(files, path, samplingRate)
        return [ObjectView(self._project, self.protocol.strId(), path)]
コード例 #13
0
 def _viewR2(self, paramName=None):
     views = []
     if hasattr(self.protocol, "outputMicrographs"):
         obj = self.protocol.outputMicrographs
         fn = obj.getFileName()
         labels = 'id _filename _xmipp_ctfDefocusR2'
         views.append(
             ObjectView(self._project,
                        obj.strId(),
                        fn,
                        viewParams={
                            showj.ORDER: labels,
                            showj.VISIBLE: labels,
                            showj.RENDER: None,
                            showj.MODE: showj.MODE_MD
                        }))
     return views
コード例 #14
0
 def _showVolume(self, paramName=None):
     choice = self.displayVolume.get()
     views=[]
     for it in self._iterations:
         fnDir = self.protocol._getExtraPath("Iter%03d"%it)
         if choice == 0:
             if self.protocol.alignmentMethod==self.protocol.GLOBAL_ALIGNMENT:
                 fnDir = join(fnDir,'globalAssignment')
             else:
                 fnDir = join(fnDir,'localAssignment')
             fnVolume = join(fnDir,"volumeRef01.vol")
         elif choice == 1:
             fnVolume = join(fnDir,"volumeAvg.mrc")
         elif choice == 2:
             fnVolume = join(fnDir,"volumeAvgFiltered.mrc")
         if exists(fnVolume):
             samplingRate=self.protocol.readInfoField(fnDir,"sampling",MDL_SAMPLINGRATE)
             views.append(ObjectView(self._project, None, fnVolume, viewParams={showj.RENDER: 'image', showj.SAMPLINGRATE: samplingRate}))
     return views
コード例 #15
0
 def _showOutputParticles(self, paramName=None):
     views = []
     if hasattr(self.protocol, "outputParticles"):
         obj = self.protocol.outputParticles
         fn = obj.getFileName()
         labels = 'id enabled _filename '
         labels += '_ctfModel._defocusU _ctfModel._defocusV _xmipp_shiftX _xmipp_shiftY _xmipp_angleTilt '
         labels += ' _xmipp_angleRot  _xmipp_anglePsi _xmipp_maxCC _xmipp_weight '
         views.append(
             ObjectView(self._project,
                        obj.strId(),
                        fn,
                        viewParams={
                            showj.ORDER: labels,
                            showj.VISIBLE: labels,
                            showj.MODE: showj.MODE_MD,
                            showj.RENDER: '_filename'
                        }))
     return views
コード例 #16
0
    def objectView(self, filenameOrObject, **kwargs):
        """ This is a wrapper around the ObjectView constructor, just to
        avoid passing the project and protocol, since both are know
        here in the ProtocolViewer.
        Params:
            filenameOrObject: This parameter can be either a filename or an
                object that has 'getFileName' method.
            **kwargs: Can receive extra keyword-arguments that will be passed
                to the ObjectView constructor
        """
        fn = None

        if isinstance(filenameOrObject, str):
            # If the input is a string filename, we should take the object id
            # from the protocol. This assumes that self.protocol have been
            # previously set
            fn = filenameOrObject
            strId = self.getProtocolId()

        elif isinstance(filenameOrObject, pwobj.Object):

            if filenameOrObject.getObjId() is None:
                strId = self.getProtocolId()
            else:
                strId = filenameOrObject.strId()

            if hasattr(filenameOrObject, 'getLocation'):
                # In this case fn will be a location tuple that will be
                # correctly handled by the showj DataView
                fn = filenameOrObject.getLocation()
            elif hasattr(filenameOrObject, 'getFileName'):
                # If the input is an object, we can take the id from it
                fn = filenameOrObject.getFileName()

        if fn is None:
            raise Exception("Incorrect input object, it should be 'string' or "
                            "'Object' (with 'getLocation' or 'getFileName' "
                            "methods).")

        return ObjectView(self._project, strId, fn, **kwargs)
コード例 #17
0
    def _visualizeParticles(self, e=None):
        views = []

        labels = 'id enabled _index _filename _xmipp_zScoreDeepLearning1 '
        labels += '_xmipp_zScore _xmipp_cumulativeSSNR '
        labels += '_xmipp_scoreEmptiness'

        otherParam = {}
        objId = 0
        if (isinstance(self.protocol, XmippProtScreenDeepConsensus)
                and self.protocol.hasAttribute('outputCoordinates')):
            fnParts = self.protocol._getPath("particles.sqlite")
            objId = self.protocol.outputCoordinates.strId()
            otherParam = {'other': 'deepCons'}

        elif (isinstance(self.protocol, XmippProtScreenDeepLearning)
              and self.protocol.hasAttribute('outputParticles')):
            parts = self.protocol.outputParticles
            fnParts = parts.getFileName()
            objId = parts.strId()

        if objId:
            views.append(
                ObjectView(self._project,
                           objId,
                           fnParts,
                           viewParams={
                               ORDER: labels,
                               VISIBLE: labels,
                               SORT_BY: '_xmipp_zScoreDeepLearning1 asc',
                               RENDER: '_filename',
                               MODE: MODE_MD
                           },
                           **otherParam))
        else:
            print(" > Not output found, yet.")

        return views
コード例 #18
0
 def viewVolumesSqlite(self, volumes):
     path = self.protocol._getExtraPath('viewer_volumes.sqlite')
     samplingRate = self.protocol.inputParticles.get().getSamplingRate()
     self.createVolumesSqlite(volumes, path, samplingRate)
     return [ObjectView(self._project, self.protocol.strId(), path)]
コード例 #19
0
    def _viewParam(self, param=None):
        micSet = self.protocol.getInputMicrographs()
        tmpDir = self.protocol._getTmpPath()
        pwutils.cleanPath(tmpDir)
        pwutils.makePath(tmpDir)
        # FIXME: (JMRT) We are always writing the SetOfCoordinates and removing
        # the tmpDir, we need to take into account if the user has picked
        # some particles in the tmpDir and has not saved them, that now he
        # will lose all picked particles.
        # A possible solution could be to alert that changes have not been
        # written during modification of tmpDir or create a new Xmipp picking
        # protocol to continue picking later without losing the coordinates.

        if micSet is None:
            raise Exception(
                'visualize: SetOfCoordinates has no micrographs set.')

        micsFn = pwutils.join(tmpDir, micSet.getName() + '_micrographs.xmd')
        from .convert import writeSetOfMicrographs
        from pwem.viewers.showj import launchSupervisedPickerGUI
        writeSetOfMicrographs(micSet, micsFn)
        inTmpFolder = True
        view = []

        if param == 'doShowAutopick':
            self._convertCoords(micSet, tmpDir, coordsType='autopick')
            launchSupervisedPickerGUI(micsFn,
                                      tmpDir,
                                      self.protocol,
                                      mode='review',
                                      inTmpFolder=inTmpFolder)
        elif param == 'doShowRejected':
            self._convertCoords(micSet, tmpDir, coordsType='rejected')
            launchSupervisedPickerGUI(micsFn,
                                      tmpDir,
                                      self.protocol,
                                      mode='review',
                                      inTmpFolder=inTmpFolder)
        elif param == 'doShowCC':
            fn = self.protocol._getPath('micrographs_ccmax.sqlite')
            view.append(ObjectView(self._project, self.protocol.strId(), fn))
            return view
        elif param == 'doShowFilt':
            fn = self.protocol._getPath('micrographs_pref.sqlite')
            view.append(ObjectView(self._project, self.protocol.strId(), fn))
            return view
        elif param == 'doShowBgEst':
            fn = self.protocol._getPath('micrographs_bg.sqlite')
            view.append(ObjectView(self._project, self.protocol.strId(), fn))
            return view
        elif param == 'doShowBgSub':
            fn = self.protocol._getPath('micrographs_bgfree.sqlite')
            view.append(ObjectView(self._project, self.protocol.strId(), fn))
            return view
        elif param == 'doShowSigma':
            fn = self.protocol._getPath('micrographs_lsigma.sqlite')
            view.append(ObjectView(self._project, self.protocol.strId(), fn))
            return view
        elif param == 'doShowMask':
            fn = self.protocol._getPath('micrographs_mask.sqlite')
            view.append(ObjectView(self._project, self.protocol.strId(), fn))
            return view
コード例 #20
0
ファイル: viewer.py プロジェクト: I2PC/scipion-em-xmipp
    def _visualize(self, obj, **kwargs):
        cls = type(obj)

        if issubclass(cls, XmippProtCTFMicrographs):
            if obj.hasAttribute('outputCTF'):
                ctfSet = obj.outputCTF
            else:
                mics = obj.inputMicrographs.get()
                ctfSet = self.__createTemporaryCtfs(obj, mics)

            if ctfSet.isEmpty():
                self._views.append(
                    self.infoMessage("No CTF estimation has finished yet"))
            else:
                self.getCTFViews(ctfSet)

        # elif issubclass(cls, SetOfNormalModes):
        #     from .viewer_nma import OBJCMD_NMA_PLOTDIST, OBJCMD_NMA_VMD
        #     fn = obj.getFileName()
        #     objCommands = "'%s' '%s'" % (OBJCMD_NMA_PLOTDIST, OBJCMD_NMA_VMD)
        #     self._views.append(ObjectView(self._project, self.protocol.strId(),
        #                                   fn, obj.strId(),
        #                                   viewParams={OBJCMDS: objCommands},
        #                                   **kwargs))

        elif (issubclass(cls, XmippProtExtractParticles)
              or issubclass(cls, XmippProtScreenParticles)):
            particles = obj.outputParticles
            self._visualize(particles)

            fn = obj._getPath('images.xmd')
            if os.path.exists(fn):  # it doesnt unless cls is Xmipp
                md = emlib.MetaData(fn)
                # If Zscore on output images plot Zscore particle sorting
                if md.containsLabel(emlib.MDL_ZSCORE):
                    xplotter = XmippPlotter(
                        windowTitle="Zscore particles sorting")
                    xplotter.createSubPlot("Particle sorting",
                                           "Particle number", "Zscore")
                    xplotter.plotMd(md, False, mdLabelY=emlib.MDL_ZSCORE)
                    self._views.append(xplotter)
                # If VARscore on output images plot VARscore particle sorting
                if md.containsLabel(emlib.MDL_SCORE_BY_VAR):
                    xplotter = XmippPlotter(
                        windowTitle="Variance particles sorting")
                    xplotter.createSubPlot("Variance Histogram", "Variance",
                                           "Number of particles")
                    xplotter.plotMd(md,
                                    False,
                                    mdLabelY=emlib.MDL_SCORE_BY_VAR,
                                    nbins=100)
                    self._views.append(xplotter)

        elif issubclass(cls, XmippProtDeepDenoising):
            fn = obj.outputParticles.getFileName()
            self._views.append(
                ObjectView(self._project,
                           obj.outputParticles.strId(),
                           fn,
                           viewParams={
                               VISIBLE:
                               'enabled id _filename '
                               '_xmipp_corrDenoisedProjection '
                               '_xmipp_corrDenoisedNoisy '
                               '_xmipp_imageOriginal _xmipp_imageRef',
                               RENDER:
                               '_filename _xmipp_imageOriginal '
                               '_xmipp_imageRef',
                               SORT_BY:
                               'id',
                               MODE:
                               MODE_MD
                           }))

            md = emlib.MetaData(obj._getExtraPath('particlesDenoised.xmd'))
            if (md.containsLabel(emlib.MDL_CORR_DENOISED_PROJECTION)
                    and md.containsLabel(emlib.MDL_CORR_DENOISED_NOISY)):
                xplotter = XmippPlotter(
                    windowTitle="denoised vs proj & denoised vs original")
                xplotter.createSubPlot("Correlations",
                                       "corr_denoised_projection",
                                       "corr_denoised_original")
                xplotter.plotScatterMd(
                    md,
                    mdLabelX=emlib.MDL_CORR_DENOISED_PROJECTION,
                    mdLabelY=emlib.MDL_CORR_DENOISED_NOISY)
                self._views.append(xplotter)

        elif issubclass(cls, XmippProtMovieGain):
            if obj.hasAttribute('outputGains'):
                self._visualize(obj.outputGains)
            # movieGainMonitor = MonitorMovieGain(obj,
            #                                     workingDir=obj.workingDir.get(),
            #                                     samplingInterval=60,
            #                                     monitorTime=300,
            #                                     stddevValue=0.04,
            #                                     ratio1Value=1.15,
            #                                     ratio2Value=4.5)
            # self._views.append(MovieGainMonitorPlotter(movieGainMonitor))

        elif issubclass(cls, XmippProtRotSpectra):
            self._visualize(obj.outputClasses,
                            viewParams={
                                'columns': obj.SomXdim.get(),
                                RENDER:
                                ' spectraPlot._filename average._filename',
                                ZOOM: 30,
                                VISIBLE: 'enabled id _size average._filename '
                                'spectraPlot._filename',
                                'labels': 'id _size',
                                SORT_BY: 'id'
                            })

        elif issubclass(cls, XmippProtKerdensom):
            self._visualize(obj.outputClasses,
                            viewParams={
                                'columns': obj.SomXdim.get(),
                                'render': 'average._filename '
                                '_representative._filename',
                                'labels': '_size',
                                'sortby': 'id'
                            })

        elif issubclass(cls, XmippProtCompareReprojections):
            fn = obj.reprojections.getFileName()
            labels = (
                'id enabled _index _xmipp_image._filename _xmipp_imageRef._filename '
                '_xmipp_imageResidual._filename _xmipp_imageCovariance._filename '
                '_xmipp_cost _xmipp_zScoreResCov _xmipp_zScoreResMean _xmipp_zScoreResVar '
                '_xmipp_continuousA _xmipp_continuousB _xmipp_continuousX _xmipp_continuousY'
            )
            labelRender = (
                "_xmipp_image._filename _xmipp_imageRef._filename "
                "_xmipp_imageResidual._filename _xmipp_imageCovariance._filename"
            )
            self._views.append(
                ObjectView(self._project,
                           obj.reprojections.strId(),
                           fn,
                           viewParams={
                               ORDER: labels,
                               VISIBLE: labels,
                               SORT_BY: '_xmipp_cost asc',
                               RENDER: labelRender,
                               MODE: MODE_MD
                           }))

        elif issubclass(cls, XmippProtCompareAngles):
            fn = obj.outputParticles.getFileName()
            labels = 'id enabled _index _filename _xmipp_shiftDiff _xmipp_angleDiff'
            labelRender = "_filename"
            self._views.append(
                ObjectView(self._project,
                           obj.outputParticles.strId(),
                           fn,
                           viewParams={
                               ORDER: labels,
                               VISIBLE: labels,
                               SORT_BY: '_xmipp_angleDiff asc',
                               RENDER: labelRender,
                               MODE: MODE_MD
                           }))

        elif issubclass(cls, XmippProtConsensusLocalCTF):
            fn = obj.outputParticles.getFileName()
            labels = (
                'id enabled _index _filename _ctfModel._xmipp_ctfDefocusA '
                '_ctfModel._xmipp_ctfDefocusResidual')
            labelRender = "_filename"
            self._views.append(
                ObjectView(self._project,
                           obj.outputParticles.strId(),
                           fn,
                           viewParams={
                               ORDER: labels,
                               VISIBLE: labels,
                               SORT_BY: '_ctfModel._xmipp_ctfDefocusResidual',
                               RENDER: labelRender,
                               MODE: MODE_MD
                           }))

        elif issubclass(cls, XmippParticlePickingAutomatic):
            micSet = obj.getInputMicrographs()
            mdFn = getattr(micSet, '_xmippMd', None)
            inTmpFolder = False
            if mdFn:
                micsfn = mdFn.get()
            else:  # happens if protocol is not an xmipp one
                micsfn = obj._getExtraPath(micSet.getName() +
                                           '_micrographs.xmd')
                writeSetOfMicrographs(micSet, micsfn)
                inTmpFolder = True

            posDir = obj._getExtraPath()
            memory = showj.getJvmMaxMemory()
            launchSupervisedPickerGUI(micsfn,
                                      posDir,
                                      obj,
                                      mode='review',
                                      memory=memory,
                                      inTmpFolder=inTmpFolder)

        elif issubclass(cls, XmippProtParticleBoxsize):
            """ Launching a Coordinates viewer with only one coord in the center
                with the estimated boxsize.
            """
            micSet = obj.inputMicrographs.get()

            coordsFn = self._getExtraPath(micSet.getName() +
                                          '_coords_to_view.sqlite')
            if not os.path.exists(coordsFn):
                # Just creating the coords once
                coordsSet = SetOfCoordinates(filename=coordsFn)
                coordsSet.setBoxSize(obj.boxsize)
                for mic in micSet:
                    coord = Coordinate()
                    coord.setMicrograph(mic)
                    coord.setPosition(mic.getXDim() / 2, mic.getYDim() / 2)
                    coordsSet.append(coord)
                coordsSet.write()
            else:
                coordsSet = SetOfCoordinates(filename=coordsFn)
                coordsSet.loadAllProperties()

            coordsSet.setMicrographs(micSet)
            coordsSet.setName(micSet.getName())
            self._visualize(coordsSet)

        # We need this case to happens before the ProtParticlePicking one
        elif issubclass(cls, XmippProtAssignmentTiltPair):
            if obj.getOutputsSize() >= 1:
                coordsSet = obj.getCoordsTiltPair()
                self._visualize(coordsSet)

        elif issubclass(cls, XmippProtValidateNonTilt):
            outputVols = obj.outputVolumes
            labels = 'id enabled comment _filename weight'
            self._views.append(
                ObjectView(self._project,
                           outputVols.strId(),
                           outputVols.getFileName(),
                           viewParams={
                               MODE: MODE_MD,
                               VISIBLE: labels,
                               ORDER: labels,
                               SORT_BY: 'weight desc',
                               RENDER: '_filename'
                           }))

        elif issubclass(cls, XmippProtMultiRefAlignability):
            outputVols = obj.outputVolumes
            labels = (
                'id enabled comment _filename weightAlignabilityPrecision '
                'weightAlignabilityAccuracy')
            self._views.append(
                ObjectView(self._project,
                           outputVols.strId(),
                           outputVols.getFileName(),
                           viewParams={
                               MODE: MODE_MD,
                               VISIBLE: labels,
                               ORDER: labels,
                               SORT_BY: 'weightAlignabilityAccuracy desc',
                               RENDER: '_filename'
                           }))

            fn = obj.outputParticles.getFileName()
            labels = (
                'id enabled _index _filename _xmipp_scoreAlignabilityAccuracy '
                '_xmipp_scoreAlignabilityPrecision')
            labelRender = "_filename"
            self._views.append(
                ObjectView(self._project,
                           obj.outputParticles.strId(),
                           fn,
                           viewParams={
                               ORDER: labels,
                               VISIBLE: labels,
                               SORT_BY:
                               '_xmipp_scoreAlignabilityAccuracy desc',
                               RENDER: labelRender,
                               MODE: MODE_MD
                           }))

            fn = obj._getExtraPath('vol001_pruned_particles_alignability.xmd')
            md = emlib.MetaData(fn)
            plotter = XmippPlotter()
            plotter.createSubPlot('Soft-alignment validation plot',
                                  'Angular Precision', 'Angular Accuracy')
            plotter.plotMdFile(md,
                               emlib.MDL_SCORE_BY_ALIGNABILITY_PRECISION,
                               emlib.MDL_SCORE_BY_ALIGNABILITY_ACCURACY,
                               marker='.',
                               markersize=.55,
                               color='red',
                               linestyle='')
            self._views.append(plotter)

        elif issubclass(cls, XmippProtExtractParticlesPairs):
            self._visualize(obj.outputParticlesTiltPair)

        else:
            # Use default visualization defined in base class
            DataViewer._visualize(self, obj, **kwargs)

        return self._views
コード例 #21
0
 def _getObjView(self, obj, fn, viewParams={}):
     return ObjectView(self._project,
                       obj.strId(),
                       fn,
                       viewParams=viewParams)