plotter.createSubPlot(title, 'atom index', ylabel)
    plotter.plotMdFile(mdFn, None, xmippLib.MDL_NMA_ATOMSHIFT)
    return plotter


def createDistanceProfilePlot(protocol, modeNumber):
    vectorMdFn = protocol._getExtraPath("distanceProfiles",
                                        "vec%d.xmd" % modeNumber)
    plotter = createShiftPlot(vectorMdFn,
                              "Atom shifts for mode %d" % modeNumber, "shift")
    return plotter


def createVmdView(protocol, modeNumber):
    vmdFile = protocol._getExtraPath("animations",
                                     "animated_mode_%03d.vmd" % modeNumber)
    return VmdView('-e "%s"' % vmdFile)


def showDistanceProfilePlot(protocol, modeNumber):
    createDistanceProfilePlot(protocol, modeNumber).show()


def showVmdView(protocol, modeNumber):
    createVmdView(protocol, modeNumber).show()


ProjectWindow.registerObjectCommand(OBJCMD_NMA_PLOTDIST,
                                    showDistanceProfilePlot)
ProjectWindow.registerObjectCommand(OBJCMD_NMA_VMD, showVmdView)
Beispiel #2
0
    DataView(volFn).show()


def showClassAvgProjs(volumeSet, volId):
    showExtraFile(volumeSet, volId, '_aptcl.hdf')


def showProjs(volumeSet, volId):
    showExtraFile(volumeSet, volId, '_proj.hdf')


def showInitialRandomVolume(volumeSet, volId):
    showExtraFile(volumeSet, volId, '_init.hdf')


ProjectWindow.registerObjectCommand(OBJCMD_CLASSAVG_PROJS, showClassAvgProjs)
ProjectWindow.registerObjectCommand(OBJCMD_PROJS, showProjs)
ProjectWindow.registerObjectCommand(OBJCMD_INITVOL, showInitialRandomVolume)


class Refine2DViewer(ProtocolViewer):
    """ Visualization of e2refine2d results. """

    _targets = [EmanProtRefine2D, EmanProtRefine2DBispec]
    _environments = [DESKTOP_TKINTER, WEB_DJANGO]
    _label = 'viewer refine 2d'

    def _defineParams(self, form):
        self._env = os.environ.copy()
        form.addSection(label='Results per Iteration')
        form.addParam('iterToShow',
Beispiel #3
0
                if i == 0:
                    res['freq'] = [float(x) for x in line.split()]
                elif i == 2:
                    res['amp'] = [float(x) for x in line.split()]
                elif i == 3:
                    res['fit'] = [float(x) for x in line.split()]
                elif i == 4:
                    res['quality'] = [float(x) for x in line.split()]
                    break
                i += 1
    return res


OBJCMD_CTFFIND4 = "CTFFind plot results"

ProjectWindow.registerObjectCommand(OBJCMD_CTFFIND4, createCtfPlot)


class CtffindViewer(Viewer):
    """ Specific way to visualize SetOfCtf. """
    _environments = [DESKTOP_TKINTER]
    _targets = [CistemProtCTFFind]

    def _visualize(self, prot, **kwargs):
        outputCTF = getattr(prot, 'outputCTF', None)

        if outputCTF is not None:
            ctfView = CtfView(self._project, outputCTF)
            viewParams = ctfView.getViewParams()
            viewParams[showj.OBJCMDS] = "'%s'" % OBJCMD_CTFFIND4
            return [ctfView]
        # we only consider the 'doSaveUnweightedMic' flag if the
        # weighted ones should be created.
        return (self.doSaveAveMic and self.doSaveUnweightedMic)

    def _createOutputWeightedMicrographs(self):
        return (self.doSaveAveMic and self.doApplyDoseFilter)

    def _getOutputMovieUnWtName(self, movie):
        """ Returns the name of the output dose-weighted movie.
        (relative to micFolder)
        """
        return self._getMovieRoot(movie) + '_aligned_movie.mrcs'


def showCartesianShiftsPlot(inputSet, itemId):
    item = inputSet[itemId]
    if item.hasAttribute('_xmipp_OFMeanX'):
        meanX = [float(x) for x in item._xmipp_OFMeanX]
        meanY = [float(y) for y in item._xmipp_OFMeanY]
        plotter = createAlignmentPlot(meanX, meanY)
        plotter.show()
    else:
        print("These items do not have OF alignment set. ")


ProjectWindow.registerObjectCommand(OBJCMD_MOVIE_ALIGNCARTESIAN,
                                    showCartesianShiftsPlot)

# Just for backwards compatibility
ProtMovieAlignment = XmippProtOFAlignment
Beispiel #5
0
                               'CTF',
                               yformat=False)
    a.invert_xaxis()
    for i in range(1, 5):
        _plotCurve(a, i, fn)
    xplotter.showLegend([
        'simulated CTF', 'equiphase avg.', 'equiphase avg. - bg',
        'cross correlation'
    ])
    a.grid(True)
    xplotter.show()


OBJCMD_GCTF = "Display Ctf Analysis"

ProjectWindow.registerObjectCommand(OBJCMD_GCTF, createCtfPlot)


def _plotCurve(a, i, fn):
    freqs = _getValues(fn, 0)
    curv = _getValues(fn, i)
    a.plot(freqs, curv)


def _getValues(fn, col):
    f = open(fn)
    values = []
    for line in f:
        if not line.startswith('Resolution', 2, 12):
            column = line.split()
            value = float(column[col])
Beispiel #6
0
def showExtraFile(volumeSet, volId, suffix):
    vol = volumeSet[volId]
    volFn = vol.getFileName().replace('.hdf', suffix)
    vw.DataView(volFn).show()

def showClassAvgProjs(volumeSet, volId):
    showExtraFile(volumeSet, volId, '_aptcl.hdf')

def showProjs(volumeSet, volId):
    showExtraFile(volumeSet, volId, '_proj.hdf')

def showInitialRandomVolume(volumeSet, volId):
    showExtraFile(volumeSet, volId, '_init.hdf')


ProjectWindow.registerObjectCommand(OBJCMD_CLASSAVG_PROJS, showClassAvgProjs)
ProjectWindow.registerObjectCommand(OBJCMD_PROJS, showProjs)
ProjectWindow.registerObjectCommand(OBJCMD_INITVOL, showInitialRandomVolume)


class RefineEasyViewer(ProtocolViewer):
    """ Visualization of Refine Easy."""
    
    _targets = [EmanProtRefine]
    _environments = [DESKTOP_TKINTER, WEB_DJANGO]
    _label = 'viewer Refine Easy'
    
    def _defineParams(self, form):
        self._env = os.environ.copy()
        form.addSection(label='Results per Iteration')
        form.addParam('iterToShow', EnumParam,
Beispiel #7
0
    
    legendName = ['rotational avg. No Astg',
                  'rotational avg.',
                  'CTF Fit',
                  'Cross Correlation',
                  '2sigma cross correlation of noise']
    for i in range(1, 6):
        _plotCurve(a, i, fn)
    xplotter.showLegend(legendName)
    a.grid(True)
    xplotter.show()


OBJCMD_CTFFIND4 = "Display Ctf Fitting"

ProjectWindow.registerObjectCommand(OBJCMD_CTFFIND4, createCtfPlot)


class CtffindViewer(Viewer):
    """ Specific way to visualize SetOfCtf after Gctf. """
    _environments = [DESKTOP_TKINTER, WEB_DJANGO]
    _targets = [ProtCTFFind]

    def _visualize(self, prot, **kwargs):
        outputCTF = getattr(prot, 'outputCTF', None)

        if outputCTF is not None:
            ctfView = CtfView(self._project, outputCTF)
            viewParams = ctfView.getViewParams()
            viewParams[showj.OBJCMDS] = "'%s'" % OBJCMD_CTFFIND4
            return [ctfView]
        return (self.doSaveAveMic and self.doSaveUnweightedMic)
    
    
    def _createOutputWeightedMicrographs(self):
        return (self.doSaveAveMic and self.doApplyDoseFilter)
    
    def _getOutputMovieWtName(self, movie):
        """ Returns the name of the output dose-weighted movie.
        (relative to micFolder)
        """
        return self._getMovieRoot(movie) + '_aligned_movie_DW.mrcs'



def showCartesianShiftsPlot(inputSet, itemId):
    item = inputSet[itemId]
    if item.hasAttribute('_xmipp_OFMeanX'):
        meanX = [float(x) for x in item._xmipp_OFMeanX]
        meanY = [float(y) for y in item._xmipp_OFMeanY]
        plotter = createAlignmentPlot(meanX, meanY)
        plotter.show()
    else:
        print "These items do not have OF alignment set. "


ProjectWindow.registerObjectCommand(OBJCMD_MOVIE_ALIGNCARTESIAN,
                                    showCartesianShiftsPlot)

# Just for backwards compatibility
ProtMovieAlignment = XmippProtOFAlignment
Beispiel #9
0
    a = xplotter.createSubPlot(plot_title, 'Resolution (Angstroms)', 'CTF',
                               yformat=False)
    a.invert_xaxis()
    for i in range(1, 5):
        _plotCurve(a, i, fn)
    xplotter.showLegend(['simulated CTF',
                         'equiphase avg.',
                         'equiphase avg. - bg',
                         'cross correlation'])
    a.grid(True)
    xplotter.show()


OBJCMD_GCTF = "Display Ctf Analysis"

ProjectWindow.registerObjectCommand(OBJCMD_GCTF, createCtfPlot)


def _plotCurve(a, i, fn):
    freqs = _getValues(fn, 0)
    curv = _getValues(fn, i)
    a.plot(freqs, curv)


def _getValues(fn, col):
    f = open(fn)
    values = []
    for line in f:
        if not line.startswith('Resolution', 2, 12):
            column = line.split()
            value = float(column[col])