当前位置: 首页>>代码示例>>Python>>正文


Python visvis.use函数代码示例

本文整理汇总了Python中visvis.use函数的典型用法代码示例。如果您正苦于以下问题:Python use函数的具体用法?Python use怎么用?Python use使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了use函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main(select=3, **kwargs):
    """Script main function.

    select: int
        1: Medical data
        2: Blocky data, different every time
        3: Two donuts
        4: Ellipsoid

    """
    import visvis as vv  # noqa: delay import visvis and GUI libraries

    # Create test volume
    if select == 1:
        vol = vv.volread('stent')
        isovalue = kwargs.pop('level', 800)
    elif select == 2:
        vol = vv.aVolume(20, 128)
        isovalue = kwargs.pop('level', 0.2)
    elif select == 3:
        with timer('computing donuts'):
            vol = donuts()
        isovalue = kwargs.pop('level', 0.0)
        # Uncommenting the line below will yield different results for
        # classic MC
        # vol *= -1
    elif select == 4:
        vol = ellipsoid(4, 3, 2, levelset=True)
        isovalue = kwargs.pop('level', 0.0)
    else:
        raise ValueError('invalid selection')

    # Get surface meshes
    with timer('finding surface lewiner'):
        vertices1, faces1 = marching_cubes_lewiner(vol, isovalue, **kwargs)[:2]

    with timer('finding surface classic'):
        vertices2, faces2 = marching_cubes_classic(vol, isovalue, **kwargs)

    # Show
    vv.figure(1)
    vv.clf()
    a1 = vv.subplot(121)
    vv.title('Lewiner')
    m1 = vv.mesh(np.fliplr(vertices1), faces1)
    a2 = vv.subplot(122)
    vv.title('Classic')
    m2 = vv.mesh(np.fliplr(vertices2), faces2)
    a1.camera = a2.camera

    # visvis uses right-hand rule, gradient_direction param uses left-hand rule
    m1.cullFaces = m2.cullFaces = 'front'  # None, front or back

    vv.use().Run()
开发者ID:ThomasWalter,项目名称:scikit-image,代码行数:54,代码来源:visual_test.py

示例2: appInstance

def appInstance(useVisVis=True):
    """Create a suitable application instance"""
    print("Creating application instance...")
    
    global g_haveVisVis
    
    app = None
    
    if g_haveVisVis and useVisVis:
        print("Using VisVis application instance...")
        app = vv.use()
        app.Create()
    else:
        print("Trying Qt application instance...") 
        app = QtGui.QApplication.instance()
        if app is None:
            print("Creating new Qt application instance...")
            app = QtGui.QApplication(sys.argv)
        else:
            print("Reusing existing Qt application instance...")
        
        if app!=None:
            app.Run = app.exec_
            
    if app is None:
        print("No application instance found. Exiting...")
        sys.exit(-1)

    return app    
开发者ID:CALFEM,项目名称:calfem-python,代码行数:29,代码来源:ui.py

示例3: __init__

 def __init__(self, audiofile=None, fs=22050, bandwidth=300,freqRange= 5000, dynamicRange=48, noiseFloor =-72, parent = None):
     super(Spec, self).__init__()
     
     backend = 'pyqt4'
     app = vv.use(backend)
     Figure = app.GetFigureClass()
     self.fig= Figure(self)
     self.fig.enableUserInteraction = True
     self.fig._widget.setMinimumSize(700,350)
     self.axes = vv.gca()
     
     self.audiofilename = audiofile
     self.freqRange = freqRange
     self.fs = fs
     self.NFFT = int(1.2982804/bandwidth*self.fs)
     self.overlap = int(self.NFFT/2)
     self.noiseFloor = noiseFloor
     self.dynamicRange = dynamicRange
     self.timeLength = 60
     self.resize(700,250)
     
     layout = QtGui.QVBoxLayout()
     layout.addWidget(self.fig._widget)
     self.setLayout(layout)
     
     self.win = gaussian(self.NFFT,self.NFFT/6)
     self.show()
开发者ID:turapeach,项目名称:TOAK,代码行数:27,代码来源:visvisSpec.py

示例4: show

def show(items, normals=None):
    """Function that shows a mesh object.
    """
    for item in items:
        vv.clf()
        # convert to visvis.Mesh class
        new_normals = []
        new_vertices = []
        for k, v in item.vertices.iteritems():
            new_normals.append(item.normal(k))
            new_vertices.append(v)
        mesh = item.to_visvis_mesh()

        mesh.SetVertices(new_vertices)
        mesh.SetNormals(new_normals)
        mesh.faceColor = 'y'
        mesh.edgeShading = 'plain'
        mesh.edgeColor = (0, 0, 1)

    axes = vv.gca()
    if axes.daspectAuto is None:
        axes.daspectAuto = False
    axes.SetLimits()

    if normals is not None:
        for normal in normals:
            sl = solidLine(normal, 0.15)
            sl.faceColor = 'r'

    # Show title and enter main loop
    vv.title('Show')
    app = vv.use()
    app.Run()
开发者ID:simphony,项目名称:nfluid,代码行数:33,代码来源:show.py

示例5: main

def main():
    p = Path('/mri/images/DWI-Mono/42-1a/42-1a_ADCm.zip')
    image = Image.read(p, dtype='float32')
    image = image[image.mbb()]

    app = vv.use()
    # vv.figure()
    # vv.title(p.name)
    plot(image)
    app.Run()
开发者ID:jupito,项目名称:dwilib,代码行数:10,代码来源:vis.py

示例6: initControl

    def initControl(self):        
        self._form = QtGui.QWidget();layout = QtGui.QVBoxLayout();layout.setMargin(0);self._form.setLayout( layout )
        self._app = vv.use('pyqt4')

        Figure = self._app.GetFigureClass()
        self._fig = Figure(self._form)

        policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        widget = self._fig._widget
        widget.setSizePolicy(policy)

        layout.addWidget(widget)
开发者ID:sdcardoso,项目名称:pythonVideoAnnotator,代码行数:12,代码来源:ControlVisVis.py

示例7: crop3d

def crop3d(vol, fig=None):
    """ crop3d(vol, fig=None)
    Manually crop a volume. In the given figure (or a new figure if None),
    three axes are created that display the transversal, sagittal and 
    coronal MIPs (maximum intensity projection) of the volume. The user
    can then use the mouse to select a 3D range to crop the data to.
    """
    app = vv.use()
    
    # Create figure?    
    if fig is None:        
        fig = vv.figure()    
        figCleanup = True
    else:
        fig.Clear()
        figCleanup = False
    
    # Create three axes and a wibject to attach text labels to    
    a1 = vv.subplot(221)
    a2 = vv.subplot(222)
    a3 = vv.subplot(223)
    a4 = vv.Wibject(fig)
    a4.position = 0.5, 0.5, 0.5, 0.5
    
    # Set settings
    for a in [a1, a2, a3]:
        a.showAxis = False
    
    # Create cropper3D instance
    cropper3d = Cropper3D(vol, a1, a3, a2, a4)
    
    # Enter a mainloop
    while not cropper3d._finished:
        vv.processEvents()
        time.sleep(0.01)
    
    # Clean up figure (close if we opened it)
    fig.Clear()
    fig.DrawNow()
    if figCleanup:    
        fig.Destroy()
    
    # Obtain ranges
    rx = cropper3d._range_transversal._rangex
    ry = cropper3d._range_transversal._rangey
    rz = cropper3d._range_coronal._rangey
    
    # Perform crop
    vol2 = vol[rz.min:rz.max, ry.min:ry.max, rx.min:rx.max]
    
    # Done
    return vol2
开发者ID:binaryannamolly,项目名称:visvis,代码行数:52,代码来源:cropper.py

示例8: initForm

    def initForm(self):
        self._form = QtGui.QWidget();layout = QtGui.QVBoxLayout();layout.setMargin(0);self._form.setLayout( layout )
        self._app = vv.use('pyqt4')
        self._first=True

        Figure = self._app.GetFigureClass()
        self._fig = Figure(self._form)
        vv.figure(self._fig.nr)
        
        policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        widget = self._fig._widget
        widget.setSizePolicy(policy)
        widget.setMinimumSize(100, 100)

        layout.addWidget(widget)

        self._colorMap = vv.CM_AUTUMN
开发者ID:zhuangkechen,项目名称:pyforms,代码行数:17,代码来源:ControlVisVisVolume.py

示例9: __init__

    def __init__(self, sampleinterval=0.1, timewindow=10.0, size=(600, 350)):
        # Data stuff
        self._interval = int(sampleinterval * 1000)
        self._bufsize = int(timewindow / sampleinterval)
        self.databuffer = collections.deque([0.0] * self._bufsize, self._bufsize)
        self.x = np.linspace(-timewindow, 0.0, self._bufsize)
        self.y = np.zeros(self._bufsize, dtype=np.float)
        # Visvis stuff
        self.app = vv.use("qt4")
        vv.title("Dynamic Plotting with VisVis")
        self.line = vv.plot(self.x, self.y, lc="b", lw=3, ms="+")
        vv.xlabel("time")
        vv.ylabel("amplitude")
        self.ax = vv.gca()

        self.timer = vv.Timer(self.app, 50, oneshot=False)
        self.timer.Bind(self.updateplot)
        self.timer.Start()
开发者ID:ap--,项目名称:python-live-plotting,代码行数:18,代码来源:plot_visvis.py

示例10: psf_volume

def psf_volume(stack, xyz_ratio, filepath):

    app = vv.use()
    # Init a figure with two axes
    a1 = vv.subplot(121)
    vv.title('PSF Volume')
    a2 = vv.subplot(122)
    vv.title('PSF XYZ Cross Sections')
    
    # show
    t1 = vv.volshow(stack, axes=a1)  # volume
    t2 = vv.volshow2(stack, axes=a2)  # cross-section interactive
       
    # set labels for both axes
    vv.xlabel('Pixel X', axes=a1)
    vv.ylabel('Pixel Y', axes=a1)
    vv.zlabel('Z-Slice', axes=a1)
    vv.xlabel('Pixel X', axes=a2)
    vv.ylabel('Pixel Y', axes=a2)
    vv.zlabel('Z-Slice', axes=a2)
    
    # set colormaps
    t1.colormap = vv.CM_JET
    t2.colormap = vv.CM_JET

    # set correct aspect ration corresponding to voxel size    
    a1.daspect = 1, 1, xyz_ratio
    a2.daspect = 1, 1, xyz_ratio
    
    # show grid
    a1.axis.showGrid = 1
    a2.axis.showGrid = 1    
    
    # run visvis and show results
    app.Run()

    # save screenshot
    if filepath != 'nosave':
        print 'Saving PSF volume.'
        savename = filepath[:-4] + '_PSF_3D.png'
        # sf: scale factor
        vv.screenshot(savename, sf=1, bg='w')
开发者ID:sebi06,项目名称:PSF_XYZ_Bead_Fit,代码行数:42,代码来源:psfview.py

示例11: demo


#.........这里部分代码省略.........
    Rx = numpy.matrix([[1, 0, 0, 0],
                      [0, math.cos(rx), -math.sin(rx), 0],
                      [0, math.sin(rx), math.cos(rx), 0],
                      [0, 0, 0, 1]])

    Ry = numpy.matrix([[math.cos(ry), 0, math.sin(ry), 0],
                       [0, 1, 0, 0],
                       [-math.sin(ry), 0, math.cos(ry), 0],
                       [0, 0, 0, 1]])

    Rz = numpy.matrix([[math.cos(rz), -math.sin(rz), 0, 0],
                       [math.sin(rz), math.cos(rz), 0, 0],
                       [0, 0, 1, 0],
                       [0, 0, 0, 1]])

    # Rotation matrix
    R = Rx * Ry * Rz

    transformMat = numpy.matrix(numpy.identity(4))
    transformMat *= T
    transformMat *= R
    transformMat *= S

    # Transform data-matrix plus noise into model-matrix
    D = numpyTransform.transformPoints(transformMat, M)

    # Add noise to model and data
    M = M + 0.01 * numpy.random.randn(n, 3)
    D = D + 0.01 * numpy.random.randn(n, 3)

    # Run ICP (standard settings)
    initialGuess = numpy.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    lowerBounds = numpy.array([-pi, -pi, -pi, -100.0, -100.0, -100.0])
    upperBounds = numpy.array([pi, pi, pi, 100.0, 100.0, 100.0])
    icp = ICP(M, D, maxIterations=15, dataDownsampleFactor=1, minimizeMethod='fmincon', **kwargs)
#    icp = ICP(M, D, maxIterations=15, dataDownsampleFactor=1, minimizeMethod='point', **kwargs)
    transform, err, t = icp.runICP(x0=initialGuess, lb=lowerBounds, ub=upperBounds)

    # Transform data-matrix using ICP result
    Dicp = numpyTransform.transformPoints(transform[-1], D)

    # Plot model points blue and transformed points red
    if False:
        import matplotlib.pyplot as plt
        from mpl_toolkits.mplot3d import Axes3D
        fig = plt.figure()
        ax = fig.add_subplot(2, 2, 1, projection='3d')
        ax.scatter(M[:, 0], M[:, 1], M[:, 2], c='r', marker='o')
        ax.scatter(D[:, 0], D[:, 1], D[:, 2], c='b', marker='^')
        ax.set_xlabel('X Label')
        ax.set_ylabel('Y Label')
        ax.set_zlabel('Z Label')

        ax = fig.add_subplot(2, 2, 2, projection='3d')
        ax.scatter(M[:, 0], M[:, 1], M[:, 2], c='r', marker='o')
        ax.scatter(Dicp[:, 0], Dicp[:, 1], Dicp[:, 2], c='b', marker='^')
        ax.set_xlabel('X Label')
        ax.set_ylabel('Y Label')
        ax.set_zlabel('Z Label')

        ax = fig.add_subplot(2, 2, 3)
        ax.plot(t, err, 'x--')
        ax.set_xlabel('X Label')
        ax.set_ylabel('Y Label')

        plt.show()
    else:
        import visvis as vv
        app = vv.use()
        vv.figure()
        vv.subplot(2, 2, 1)
        vv.plot(M[:, 0], M[:, 1], M[:, 2], lc='b', ls='', ms='o')
        vv.plot(D[:, 0], D[:, 1], D[:, 2], lc='r', ls='', ms='x')
        vv.xlabel('[0,0,1] axis')
        vv.ylabel('[0,1,0] axis')
        vv.zlabel('[1,0,0] axis')
        vv.title('Red: z=sin(x)*cos(y), blue: transformed point cloud')

        # Plot the results
        vv.subplot(2, 2, 2)
        vv.plot(M[:, 0], M[:, 1], M[:, 2], lc='b', ls='', ms='o')
        vv.plot(Dicp[:, 0], Dicp[:, 1], Dicp[:, 2], lc='r', ls='', ms='x')
        vv.xlabel('[0,0,1] axis')
        vv.ylabel('[0,1,0] axis')
        vv.zlabel('[1,0,0] axis')
        vv.title('ICP result')

        # Plot RMS curve
        vv.subplot(2, 2, 3)
        vv.plot(t, err, ls='--', ms='x')
        vv.xlabel('time [s]')
        vv.ylabel('d_{RMS}')
        vv.title('KD-Tree matching')
        if 'optAlg' in kwargs:
            opt2 = nlopt.opt(kwargs['optAlg'], 2)
            vv.title(opt2.get_algorithm_name())
            del opt2
        else:
            vv.title('KD-Tree matching')
        app.Run()
开发者ID:vanossj,项目名称:pyAtlasBoneSegmentation,代码行数:101,代码来源:ICP.py

示例12: VisBaseCanvas

__author__ = "Mathew Cosgrove"
__copyright__ = ""
__license__ = ""
__version__ = "0.0.1"
__maintainer__ = "Mathew Cosgrove"
__email__ = "[email protected]"
__status__ = "Development"

from collections import deque

import numpy as np
from PyQt4 import QtGui

import visvis as vv
backend = 'pyqt4'
vv_app = vv.use(backend)


class VisBaseCanvas(QtGui.QWidget):

  """docstring for VisCanvas"""

  def __init__(self, parent):
    if parent is not None:
      super(VisBaseCanvas, self).__init__()
      # Setup figure to attach to the QtApp
      Figure = vv_app.GetFigureClass()

      self.fig = Figure(parent)
      self.fig.bgcolor = 0.1953, 0.1953, 0.1953
开发者ID:cosgroma,项目名称:qtbooty,代码行数:30,代码来源:visvis_be.py

示例13: refresh

 def refresh(self):
     vv.figure(self._fig.nr)
     self._app = vv.use()
     self.paint(vv)
开发者ID:sdcardoso,项目名称:pythonVideoAnnotator,代码行数:4,代码来源:ControlVisVis.py

示例14: MainWindow

#!/usr/bin/env python
""" 
This example illustrates embedding a visvis figure in a Qt application.
"""

from PyQt4 import QtGui, QtCore
import visvis as vv

# Create a visvis app instance, which wraps a qt4 application object.
# This needs to be done *before* instantiating the main window. 
app = vv.use('qt4')

class MainWindow(QtGui.QWidget):
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, *args)
        
        # Make a panel with a button
        self.panel = QtGui.QWidget(self)
        but = QtGui.QPushButton(self.panel)
        but.setText('Push me')
        
        # Make figure using "self" as a parent
        self.fig = vv.backends.backend_qt4.Figure(self)
        
        # Make sizer and embed stuff
        self.sizer = QtGui.QHBoxLayout(self)
        self.sizer.addWidget(self.panel, 1)
        self.sizer.addWidget(self.fig._widget, 2)
        
        # Make callback
        but.pressed.connect(self._Plot)
开发者ID:chiluf,项目名称:visvis.dev,代码行数:31,代码来源:embeddingInQt4.py

示例15: MainWindow

#!/usr/bin/env python
""" 
This example illustrates embedding a visvis figure in an FLTK application.
"""

import fltk
import visvis as vv

# Create a visvis app instance, which wraps an fltk application object.
# This needs to be done *before* instantiating the main window.
app = vv.use("fltk")


class MainWindow(fltk.Fl_Window):
    def __init__(self):
        fltk.Fl_Window.__init__(self, 560, 420, "Embedding in FLTK")

        # Make a panel with a button
        but = fltk.Fl_Button(10, 10, 70, 30, "Click me")
        but.callback(self._Plot)

        # Make figure to draw stuff in
        Figure = app.GetFigureClass()
        self.fig = Figure(100, 10, 560 - 110, 420 - 20, "")

        # Make box for resizing
        box = fltk.Fl_Box(fltk.FL_NO_BOX, 100, 50, 560 - 110, 420 - 60, "")
        self.resizable(box)
        box.hide()

        # Finish
开发者ID:gwdgithubnom,项目名称:visvis,代码行数:31,代码来源:embeddingInFLTK.py


注:本文中的visvis.use函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。