本文整理汇总了Python中visvis.use函数的典型用法代码示例。如果您正苦于以下问题:Python use函数的具体用法?Python use怎么用?Python use使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了use函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: hasattr
#
import sys
import wx
from events import post_event, EventThread, Event
vvPresent = False
if not hasattr(sys, "frozen"):
try:
import visvis as vv
from visvis.core.line import Line
app = vv.use("wx")
vvPresent = True
except ImportError:
pass
class PlotterPreview(object):
def __init__(self, notify, figure, settings):
self.notify = notify
self.figure = figure
self.settings = settings
self.axes = None
self.window = None
self.preview = None
self.__setup_plot()
开发者ID:kronoc,项目名称:RTLSDR-Scanner,代码行数:31,代码来源:plot_preview.py
示例17: while
t_end = 3600
epsilon = 1E-10
diff = epsilon * 2
zeros = np.zeros(Ci.shape)
while(t <= t_end and diff >= epsilon):
#solve for the gradients in each direction
l_xyz = ndimage.convolve(Ci, l, mode = "constant",
cval = c_out)
# l_y = ndimage.convolve(Ci, ly, mode = "constant",
# cval = c_out)
# l_z = ndimage.convolve(Ci, lz, mode = "constant",
# cval = c_out)
#first diffusion
C = Ci + (l_xyz)*D*dt
#MUST BE normalized by unit VOLUME
temp_sink = (-sink*dt) / grid_vol
temp_source = source*dt / grid_vol
C += temp_sink + temp_source
#get the summed difference
diff = np.sum(np.abs(Ci - C))
#make sure its positive
C = C * (C > 0.0)
#update the old
Ci = C
#update the time step
t += dt
vv.use('qt4')
vv.volshow3(C)
app = vv.use()
app.Run()
开发者ID:dwhite48,项目名称:Cell_Model,代码行数:31,代码来源:DiffusionTest.py
示例18: view
def view(mol, viewer='native'):
'''Render the molecule
The mayavi backend doesn't work under python 3. The native backend uses
visvis to render the molecule. This is very slow.
It's better to use the molecular viewer.
Args:
mol (molecule.Molecule): The molecule instance to render
viewer: The backend to use. Valid choices are 'native', 'maya'
and, 'avogadro' (default: native).
Rturns:
None
'''
# mayavi
if viewer == 'maya':
from mayavi import mlab
for atom in mol.atoms:
pts = mlab.points3d(atom.r[0], atom.r[1], atom.r[2],
scale_factor=0.75,
scale_mode='none',
resolution=20,
color=atom.color())
for i, j in mol.bonds():
mlab.plot3d([mol.atoms[i].r[0], mol.atoms[j].r[0]],
[mol.atoms[i].r[1], mol.atoms[j].r[1]],
[mol.atoms[i].r[2], mol.atoms[j].r[2]],
tube_radius=0.1,
tube_sides=20)
mlab.show()
# avogadro
if viewer == 'avogadro':
from subprocess import call
write_xyz(mol, 'avogadro.xyz')
call(['avogadro', 'avogadro.xyz'])
call(['rm', 'avogadro.xyz'])
# visvis
if viewer == 'native':
import visvis as vv
for atom in mol.atoms:
x, y, z = atom.r
at = vv.solidSphere((x, y, z), atom.radius()*0.25)
at.faceColor = atom.color()
for bond in mol.bonds():
pp = vv.Pointset(3)
pp.append(bond.atoms[0].r)
pp.append(bond.atoms[1].r)
vv.solidLine(pp, radius=0.15, N=16)
pp = vv.Pointset(3)
pp.append([3, 3, 3])
pp.append([4, 3, 3])
x = vv.solidLine(pp, radius=0.05)
x.faceColor = 'r'
conex = vv.solidCone([4, 3, 3], scaling=[0.1, 0.1, 0.1], direction=[1, 0, 0])
conex.faceColor = 'r'
pp = vv.Pointset(3)
pp.append([3, 3, 3])
pp.append([3, 4, 3])
y = vv.solidLine(pp, radius=0.05)
y.faceColor = 'g'
coney = vv.solidCone([3, 4, 3], scaling=[0.1, 0.1, 0.1], direction=[0, 1, 0])
coney.faceColor = 'g'
pp = vv.Pointset(3)
pp.append([3, 3, 3])
pp.append([3, 3, 4])
z = vv.solidLine(pp, radius=0.05)
z.faceColor = 'b'
conez = vv.solidCone([3, 3, 4], scaling=[0.1, 0.1, 0.1], direction=[0, 0, 1])
conez.faceColor = 'b'
# Set axes settings
axes = vv.gca()
axes.SetLimits(rangeX=(-5, 5), rangeY=(-5, 5), rangeZ=(-5, 5))
vv.axis('off')
app = vv.use()
app.Run()
开发者ID:andrekorte,项目名称:molviewer,代码行数:84,代码来源:molio.py
示例19: MainWindow
already loaded. If not, visvis tries to load the
vv.settings.preferredBackend first.
Note: the backend can be changed even when figures are created with
another backend, but this is not recommended.
Example embedding in Qt4
------------------------
# Near the end of the script:
# Get app instance and create native app
app = vv.use('pyside')
app.Create()
# Create window
m = MainWindow()
m.resize(560, 420)
m.show()
# Run main loop
app.Run()
"""
return vv.backends.use(backendName)
if __name__=='__main__':
app = vv.use() # No arg provided: select backend automatically
print('Selected backend is %s.' % app.GetBackendName())
app.Create() # Create the backend's application
app.Run() # Enter the backend's mainloop (not in interactive mode)
开发者ID:binaryannamolly,项目名称:visvis,代码行数:30,代码来源:use.py
示例20: axes
# Display a legend
a1.legend = "Lena's face", "Lena's shoulder"
# Create second axes (with a black background)
a2 = vv.subplot(122)
a2.bgcolor = 'k'
a2.axis.axisColor = 'w'
# Display a texture
vol = vv.aVolume(2) # returns a test volume as a numpy array
texture3d = vv.volshow(vol)
# Display a mesh using one of the "solid" functions
mesh = vv.solidTeapot((32,32,80), scaling=(50,50,50))
mesh.faceColor = 0.4, 1, 0.4
mesh.specular = 'r'
# Set orthographic projection
a2.camera.fov = 45
# Create labels for the axis
a2.axis.xLabel = 'x-axis'
a2.axis.yLabel = 'y-axis'
a2.axis.zLabel = 'z-axis'
# Enter main loop
app = vv.use() # let visvis chose a backend for me
app.Run()
开发者ID:binaryannamolly,项目名称:visvis,代码行数:29,代码来源:overview.py
注:本文中的visvis.use函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论