コード例 #1
0
    def _plotHistogram(self, fnhist, titlename, xname):
        md = MetaData()
        md.read(self.protocol._getPath('extra/' + fnhist))
        x_axis = []
        y_axis = []

        i = 0
        for idx in md:
            x_axis_ = md.getValue(MDL_X, idx)
            if i == 0:
                x0 = x_axis_
            elif i == 1:
                x1 = x_axis_
            y_axis_ = md.getValue(MDL_COUNT, idx)

            i += 1
            x_axis.append(x_axis_)
            y_axis.append(y_axis_)
        delta = x1 - x0
        plt.figure()
        plt.bar(x_axis, y_axis, width=delta)
        plt.title(titlename + "Histogram")
        plt.xlabel(xname + "(a.u.)")
        plt.ylabel("Counts")

        return plt.show()
コード例 #2
0
    def _plotHistogram(self, param=None):
        md = MetaData()
        md.read(self.protocol._getFileName(FN_METADATA_HISTOGRAM))
        x_axis = []
        y_axis = []

        i = 0
        for idx in md:
            x_axis_ = md.getValue(MDL_X, idx)
            if i == 0:
                x0 = x_axis_
            elif i == 1:
                x1 = x_axis_
            y_axis_ = md.getValue(MDL_COUNT, idx)

            i += 1
            x_axis.append(x_axis_)
            y_axis.append(y_axis_)
        delta = x1 - x0
        fig = plt.figure()
        plt.bar(x_axis, y_axis, width=delta)
        plt.title("Resolutions Histogram")
        plt.xlabel("Resolution (A)")
        plt.ylabel("Counts")

        return [Plotter(figure2=fig)]
コード例 #3
0
    def _plotHistogram(self, param=None):
        md = MetaData()
        md.read(self.protocol._getPath('extra/hist.xmd'))
        x_axis = []
        y_axis = []

        i = 0
        for idx in md:
            x_axis_ = md.getValue(MDL_X, idx)
            if i==0:
                x0 = x_axis_
            elif i==1:
                x1 = x_axis_
            y_axis_ = md.getValue(MDL_COUNT, idx)

            i+=1
            x_axis.append(x_axis_)
            y_axis.append(y_axis_)
        delta = x1-x0
        plt.figure()
        plt.bar(x_axis, y_axis, width = delta)
        plt.title("Resolutions Histogram")
        plt.xlabel("Resolution (A)")
        plt.ylabel("Counts")
        
        return plt.show()
コード例 #4
0
ファイル: dataimport.py プロジェクト: EyeSeeTea/scipion-web
    def importCoordinates(self, fileName, addCoordinate):
        if exists(fileName):
            ext = getExt(fileName)
            
            if ext == ".json":
                jsonPosDict = loadJson(fileName)
                
                if jsonPosDict.has_key("boxes"):
                    boxes = jsonPosDict["boxes"]

                    for box in boxes:
                        x, y = box[:2]
                        coord = Coordinate()
                        coord.setPosition(x, y)
                        addCoordinate(coord)
                        
            elif ext == ".box":
                md = MetaData()
                md.readPlain(fileName, "xcoor ycoor particleSize")
                size = md.getValue(MDL_PICKING_PARTICLE_SIZE, md.firstObject())
                if size is None:
                    print ">>> WARNING: Error parsing coordinate file: %s" % fileName
                    print "             Skipping this file."
                else:
                    half = size / 2
                    for objId in md:
                        x = md.getValue(MDL_XCOOR, objId)
                        y = md.getValue(MDL_YCOOR, objId)
                        coord = Coordinate()
                        coord.setPosition(x+half, y+half)
                        addCoordinate(coord)
            else:
                raise Exception('Unknown extension "%s" to import Eman coordinates' % ext)
コード例 #5
0
    def _plotHistogram(self, param=None):
        md = MetaData()
        md.read(self.protocol._getPath('extra/hist.xmd'))
        x_axis = []
        y_axis = []

        i = 0
        for idx in md:
            x_axis_ = md.getValue(MDL_X, idx)
            if i == 0:
                x0 = x_axis_
            elif i == 1:
                x1 = x_axis_
            y_axis_ = md.getValue(MDL_COUNT, idx)

            i += 1
            x_axis.append(x_axis_)
            y_axis.append(y_axis_)
        delta = x1 - x0
        plt.figure()
        plt.bar(x_axis, y_axis, width=delta)
        plt.title("Resolutions Histogram")
        plt.xlabel("Resolution (A)")
        plt.ylabel("Counts")

        return plt.show()
コード例 #6
0
    def _plotCurve(self, a, fnDir, labelmd):
        print labelmd
        md = MetaData(fnDir)
        resolution = []
        radius = []
        for objId in md:
            resolution.append(md.getValue(labelmd, objId))
            radius.append(md.getValue(MDL_IDX, objId))
#         resolution_inv = [md.getValue(labelmd, objId) for objId in md]
#         frc = [md.getValue(MDL_IDX, objId) for objId in md]
        self.maxFrc = max(radius)
        self.minInv = min(resolution)
        self.maxInv = max(resolution)
        a.plot(radius, resolution, 'x')
コード例 #7
0
ファイル: dataimport.py プロジェクト: josegutab/scipion
    def importCoordinates(self, fileName, addCoordinate):

        if exists(fileName):
            ext = getExt(fileName)
            if ext == ".json":
                print "importando un json"
                jsonPosDict = loadJson(fileName)

                if jsonPosDict.has_key("boxes"):
                    boxes = jsonPosDict["boxes"]

                    for box in boxes:
                        x, y = box[:2]
                        coord = Coordinate()
                        coord.setPosition(x, y)
                        addCoordinate(coord)
            elif ext == ".box":
                md = MetaData()
                md.readPlain(fileName, 'xcoor ycoor xSize ySize')
                for objId in md:
                    x = md.getValue(MDL_XCOOR, objId)
                    y = md.getValue(MDL_YCOOR, objId)
                    coord = Coordinate()
                    coord.setPosition(x, y)
                    addCoordinate(coord)
            else:
                print "importando un queseyo"
コード例 #8
0
    def getBoxSize(self, coordFile):
        """ Try to infer the box size from the given coordinate file.
        In the case of .box files, the size is the 3rd column
        In the case of .json files, we will look for file
        e2boxercache/base.json
        """
        if coordFile.endswith('.box'):
            md = MetaData()
            md.readPlain(coordFile, "xcoor ycoor particleSize")
            return md.getValue(MDL_PICKING_PARTICLE_SIZE, md.firstObject())

        elif coordFile.endswith('.json'):
            infoDir = pwutils.dirname(coordFile)
            # Still go one level up of info dir
            jsonBase = pwutils.join(pwutils.dirname(infoDir), 'e2boxercache',
                                    'base.json')
            jsonBase2 = pwutils.join(infoDir, 'project.json')
            if pwutils.exists(jsonBase):
                jsonDict = loadJson(jsonBase)
                if jsonDict.has_key('box_size'):
                    return int(jsonDict["box_size"])
            elif pwutils.exists(jsonBase2):
                jsonDict = loadJson(jsonBase2)
                if jsonDict.has_key('global.boxsize'):
                    return int(jsonDict["global.boxsize"])

        return None
コード例 #9
0
def readCoordinates(mic, fileName, coordsSet):
    if exists(fileName):
        md = MetaData()
        md.readPlain(fileName, 'xcoor ycoor')
        for objId in md:
            x = md.getValue(MDL_XCOOR, objId)
            y = md.getValue(MDL_YCOOR, objId)
            coord = Coordinate()
            coord.setPosition(x, y)
            coord.setMicrograph(mic)
            coordsSet.append(coord)
コード例 #10
0
ファイル: convert.py プロジェクト: coocoky/scipion
def readCoordinates(mic, fileName, coordsSet):
    if exists(fileName):
         md = MetaData()
         md.readPlain(fileName, 'xcoor ycoor')
         for objId in md:
            x = md.getValue(MDL_XCOOR, objId)
            y = md.getValue(MDL_YCOOR, objId)
            coord = Coordinate()
            coord.setPosition(x, y)
            coord.setMicrograph(mic)
            coordsSet.append(coord)
コード例 #11
0
ファイル: dataimport.py プロジェクト: I2PC/scipion
 def importCoordinates(self, fileName, addCoordinate):
     print "In importCoordinates Appion with filename=%s" % fileName
     if exists(fileName):
         md = MetaData()
         md.readPlain(fileName, 'xcoor ycoor')
         for objId in md:
             x = md.getValue(MDL_XCOOR, objId)
             y = md.getValue(MDL_YCOOR, objId)
             coord = Coordinate()
             coord.setPosition(x, y)
             addCoordinate(coord)
コード例 #12
0
 def importCoordinates(self, fileName, addCoordinate):
     print "In importCoordinates Appion with filename=%s" % fileName
     if exists(fileName):
         md = MetaData()
         md.readPlain(fileName, 'xcoor ycoor')
         for objId in md:
             x = md.getValue(MDL_XCOOR, objId)
             y = md.getValue(MDL_YCOOR, objId)
             coord = Coordinate()
             coord.setPosition(x, y)
             addCoordinate(coord)
コード例 #13
0
    def _plotHistogram(self, param=None):
        md = MetaData()
        md.read(self.protocol._getFileName(FN_METADATA_HISTOGRAM))
        x_axis = []
        y_axis = []

        for idx in md:
            x_axis_ = md.getValue(MDL_X, idx)
            y_axis_ = md.getValue(MDL_COUNT, idx)

            x_axis.append(x_axis_)
            y_axis.append(y_axis_)

        plotter = EmPlotter()
        plotter.createSubPlot("Resolutions Histogram", "Resolution (A)",
                              "# of Counts")
        barwidth = (x_axis[-1] - x_axis[0]) / len(x_axis)

        plotter.plotDataBar(x_axis, y_axis, barwidth)

        return [plotter]
コード例 #14
0
    def _showColorSlices(self, fileName, setrangelimits, titleFigure, lowlim,
                         highlim):
        imageFile = self.protocol._getExtraPath(fileName)
        img = ImageHandler().read(imageFile)
        imgData = img.getData()
        imgData2 = np.ma.masked_where(imgData < 0.001, imgData, copy=True)
        if setrangelimits is True:
            fig, im = self._plotVolumeSlices(titleFigure,
                                             imgData2,
                                             lowlim,
                                             highlim,
                                             self.getColorMap(),
                                             dataAxis=self._getAxis())
        else:
            md = MetaData()
            md.read(self.protocol._getExtraPath(OUTPUT_THRESHOLDS_FILE))
            idx = 1
            val1 = md.getValue(MDL_RESOLUTION_FREQ, idx)
            val2 = md.getValue(MDL_RESOLUTION_FREQ2, idx)

            if val1 >= val2:
                max_Res = val1 + 0.01
            else:
                max_Res = val2

#             max_Res = np.nanmax(imgData2)
            min_Res = np.nanmin(imgData2)
            fig, im = self._plotVolumeSlices(titleFigure,
                                             imgData2,
                                             min_Res,
                                             max_Res,
                                             self.getColorMap(),
                                             dataAxis=self._getAxis())
        cax = fig.add_axes([0.9, 0.1, 0.03, 0.8])
        cbar = fig.colorbar(im, cax=cax)
        cbar.ax.invert_yaxis()

        return plt.show(fig)
コード例 #15
0
ファイル: dataimport.py プロジェクト: azazellochg/scipion
 def getBoxSize(self, coordFile):
     """ Try to infer the box size from the given coordinate file.
     In the case of .box files, the size is the 3rd column
     In the case of .json files, we will look for file e2boxercache/base.json
     """
     if coordFile.endswith('.box'):
         md = MetaData()
         md.readPlain(coordFile, "xcoor ycoor particleSize")
         return md.getValue(MDL_PICKING_PARTICLE_SIZE, md.firstObject())
     
     elif coordFile.endswith('.json'):
         infoDir = dirname(coordFile)
         # Still go one level up of info dir
         jsonBase = join(dirname(infoDir), 'e2boxercache', 'base.json')
         if exists(jsonBase):
             jsonDict = loadJson(jsonBase)
             if jsonDict.has_key('box_size'):
                 return int(jsonDict["box_size"])
             
     return None