def createPlot2D(self, volPrefix, md):

        import xmipp

        figurePath = self._getExtraPath(volPrefix +
                                        'softAlignmentValidation2D.png')
        figureSize = (8, 6)

        #alignedMovie = mic.alignMetaData
        plotter = Plotter(*figureSize)
        figure = plotter.getFigure()

        ax = figure.add_subplot(111)
        ax.grid()
        ax.set_title('Soft alignment validation map')
        ax.set_xlabel('Angular Precision')
        ax.set_ylabel('Angular Accuracy')

        for objId in md:
            x = md.getValue(xmipp.MDL_SCORE_BY_ALIGNABILITY_PRECISION, objId)
            y = md.getValue(xmipp.MDL_SCORE_BY_ALIGNABILITY_ACCURACY, objId)
            ax.plot(x, y, 'r.', markersize=1)

        ax.grid(True, which='both')
        ax.autoscale_view(True, True, True)

        plotter.savefig(figurePath)
        plotter.show()
        return plotter
def movieCreatePlot(mic, saveFig):

    import xmipp
    meanX = []
    meanY = []
    figureSize = (8, 6)

    #alignedMovie = mic.alignMetaData
    md = xmipp.MetaData(mic.alignMetaData)
    plotter = Plotter(*figureSize)
    figure = plotter.getFigure()

    preX = 0.0
    preY = 0.0
    meanX.append(0.0)
    meanY.append(0.0)
    ax = figure.add_subplot(111)
    ax.grid()
    ax.set_title('Cartesian representation')
    ax.set_xlabel('Drift x (pixels)')
    ax.set_ylabel('Drift y (pixels)')
    ax.plot(0, 0, 'yo-')
    for objId in md:
        preX += md.getValue(xmipp.MDL_OPTICALFLOW_MEANX, objId)
        preY += md.getValue(xmipp.MDL_OPTICALFLOW_MEANY, objId)
        meanX.append(preX)
        meanY.append(preY)
        ax.plot(preX, preY, 'yo-')
        ax.text(preX-0.02, preY+0.01, str(objId+1))
    ax.plot(np.asarray(meanX), np.asarray(meanY))
    if saveFig:
        plotter.savefig(mic.plotCart)
    return plotter
def movieCreatePlot(mic, saveFig):

    import xmipp
    meanX = []
    meanY = []
    figureSize = (8, 6)

    #alignedMovie = mic.alignMetaData
    md = xmipp.MetaData(mic.alignMetaData)
    plotter = Plotter(*figureSize)
    figure = plotter.getFigure()

    preX = 0.0
    preY = 0.0
    meanX.append(0.0)
    meanY.append(0.0)
    ax = figure.add_subplot(111)
    ax.grid()
    ax.set_title('Cartesian representation')
    ax.set_xlabel('Drift x (pixels)')
    ax.set_ylabel('Drift y (pixels)')
    ax.plot(0, 0, 'yo-')
    for objId in md:
        preX += md.getValue(xmipp.MDL_OPTICALFLOW_MEANX, objId)
        preY += md.getValue(xmipp.MDL_OPTICALFLOW_MEANY, objId)
        meanX.append(preX)
        meanY.append(preY)
        ax.plot(preX, preY, 'yo-')
        ax.text(preX - 0.02, preY + 0.01, str(objId + 1))
    ax.plot(np.asarray(meanX), np.asarray(meanY))
    if saveFig:
        plotter.savefig(mic.plotCart)
    return plotter
    def createPlot2D(self,volPrefix,md):
        
        import xmipp
        
        figurePath = self._getExtraPath(volPrefix + 'softAlignmentValidation2D.png')
        figureSize = (8, 6)
    
        #alignedMovie = mic.alignMetaData
        plotter = Plotter(*figureSize)
        figure = plotter.getFigure()
    
        ax = figure.add_subplot(111)
        ax.grid()
        ax.set_title('Soft alignment validation map')
        ax.set_xlabel('Angular Precision')
        ax.set_ylabel('Angular Accuracy')

        for objId in md:
            x = md.getValue(xmipp.MDL_SCORE_BY_ALIGNABILITY_PRECISION, objId)
            y = md.getValue(xmipp.MDL_SCORE_BY_ALIGNABILITY_ACCURACY, objId)
            ax.plot(x, y, 'r.',markersize=1)

        ax.grid(True, which='both')
        ax.autoscale_view(True,True,True)
                
        plotter.savefig(figurePath)
        plotter.show()
        return plotter    
 def _createSpectraPlot(self, label, array, index, objId=None):
     if objId is None:
         objId = index
     # Number of harmonics calculated
     plotter = Plotter()
     a = plotter.createSubPlot('Spectrum for %s %d' % (label, objId), 
                               xlabel='Harmonics', ylabel='Energy')
     
     n = self.spectraHighHarmonic.get() - self.spectraLowHarmonic.get() + 1
     i1 = (index-1) * n
     i2 = i1 + n
     xdata = range(self.spectraLowHarmonic.get(), self.spectraHighHarmonic.get()+1)
     ydata = array[i1:i2]
     a.plot(xdata, ydata)
     
     plotFile = join(self.plotsDir, 'spectra_%s%06d.png' % (label, objId))
     plotter.savefig(plotFile)
     
     return plotFile
Beispiel #6
0
 def _createSpectraPlot(self, label, array, index, objId=None):
     if objId is None:
         objId = index
     # Number of harmonics calculated
     plotter = Plotter()
     a = plotter.createSubPlot('Spectrum for %s %d' % (label, objId), 
                               xlabel='Harmonics', ylabel='Energy')
     
     n = self.spectraHighHarmonic.get() - self.spectraLowHarmonic.get() + 1
     i1 = (index-1) * n
     i2 = i1 + n
     xdata = range(self.spectraLowHarmonic.get(), self.spectraHighHarmonic.get()+1)
     ydata = array[i1:i2]
     a.plot(xdata, ydata)
     
     plotFile = join(self.plotsDir, 'spectra_%s%06d.png' % (label, objId))
     plotter.savefig(plotFile)
     
     return plotFile
def movieCreatePlot(plotType, movie, saveFig):

    import xmipp

    meanX = []
    meanY = []
    stdX = []
    stdY = []
    colors = []
    gr = 255.0

    # if movie is None:
    #     return [self.errorMessage("Invalid movie id *%d*" % movieId,
    #                               title="Invalid input")]

    alignedMovie = movie.alignMetaData
    md = xmipp.MetaData(alignedMovie)
    colorDist = 255 / md.size()

    cartPosition = None
    polarPosition = None
    colorBarPosition = 122
    figureSize = (8, 6)

    if plotType == PLOT_CART:
        cartPosition = 121
    elif plotType == PLOT_POLAR:
        polarPosition = 121
    elif plotType == PLOT_POLARCART:
        cartPosition = 132
        polarPosition = 131
        colorBarPosition = 133

    plotter = Plotter(*figureSize)
    figure = plotter.getFigure()

    # Plot the color bar
    ax = figure.add_subplot(colorBarPosition, aspect="equal", xlim=[0, 6])
    ax.set_xticklabels([])
    ax.set_yticklabels([])
    colorBarX = np.array([1, 1])
    colorBarY = np.array([2, 4])

    # Read the shifts information from the Metadata
    for objId in md:
        meanX.append(md.getValue(xmipp.MDL_OPTICALFLOW_MEANX, objId))
        meanY.append(md.getValue(xmipp.MDL_OPTICALFLOW_MEANY, objId))
        stdX.append(md.getValue(xmipp.MDL_OPTICALFLOW_STDY, objId))
        stdY.append(md.getValue(xmipp.MDL_OPTICALFLOW_STDY, objId))
        colors.append((1, gr / 255.0, 0))
        ax.plot(colorBarX, colorBarY, c=(1, gr / 255.0, 0), linewidth=10)
        ax.text(2, np.mean(colorBarY), str(objId) + "-" + str(objId + 1))
        colorBarY += 2
        gr -= colorDist
    area = (np.sqrt(np.power(np.asarray(stdX), 2) + np.power(np.asarray(stdY), 2))) * 700
    # Plot in polar if needed
    if polarPosition:
        r = np.sqrt(np.power(np.asarray(meanX), 2) + np.power(np.asarray(meanY), 2))
        theta = np.arctan2(meanY, meanX) * 180 / np.pi
        ax = figure.add_subplot(polarPosition, projection="polar")
        ax.set_title("Polar representation")
        c = ax.scatter(theta, r, c=colors, s=area, cmap=plt.cm.hsv)
        c.set_alpha(0.75)
        ax.plot(theta, r, "-^")
        if saveFig:
            plotter.savefig(movie.plotPolar)
    # Plot in cartesian if needed
    if cartPosition:
        ax = figure.add_subplot(cartPosition)
        ax.grid()
        ax.grid()
        ax.set_title("Cartesian representation")
        c = ax.scatter(np.asarray(meanX), np.asarray(meanY), c=colors, s=area, cmap=plt.cm.hsv)
        c.set_alpha(0.75)
        ax.plot(np.asarray(meanX), np.asarray(meanY), "-^")
        if saveFig:
            plotter.savefig(movie.plotCart)
    return plotter