本文整理汇总了Python中mayavi.mlab.contour3d函数的典型用法代码示例。如果您正苦于以下问题:Python contour3d函数的具体用法?Python contour3d怎么用?Python contour3d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了contour3d函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: view_thresholdedT
def view_thresholdedT(design, contrast, threshold, inequality=np.greater):
"""
A mayavi isosurface view of thresholded t-statistics
Parameters
----------
design : {'block', 'event'}
contrast : str
threshold : float
inequality : {np.greater, np.less}, optional
"""
maska = np.asarray(MASK)
tmap = np.array(load_image_fiac('group', design, contrast, 't.nii'))
test = inequality(tmap, threshold)
tval = np.zeros(tmap.shape)
tval[test] = tmap[test]
# XXX make the array axes agree with mayavi2
avganata = np.array(AVGANAT)
avganat_iso = mlab.contour3d(avganata * maska, opacity=0.3, contours=[3600],
color=(0.8,0.8,0.8))
avganat_iso.actor.property.backface_culling = True
avganat_iso.actor.property.ambient = 0.3
tval_iso = mlab.contour3d(tval * MASK, color=(0.8,0.3,0.3),
contours=[threshold])
return avganat_iso, tval_iso
示例2: test3
def test3():
import numpy as np
from mayavi import mlab
sdf = np.load('/Users/yue/data/segment/sdf_diff_3d_1/imseg_iter_100.npz')['sdf']
mlab.contour3d(sdf[0], contours=[0])
# mlab.savefig('/Users/yue/data/segment/sdf_diff_3d_1/imseg_iter_100.png')
mlab.show()
示例3: visual_test1
def visual_test1():
poly = polygon_gaussian_density(3)
#s = mlab.contour3d(poly)
#mlab.show()
grid_dimesions = poly.shape
grid_center = np.array(grid_dimesions) / 2.0
radii = np.arange(2.0, 10.0)
L_max = 25
shg = SphHarmGrid(grid_dimesions, grid_center, radii, L_max)
coeff = shg(poly)
reconstructed_poly = shg.expand_sph_harm(coeff)
print 'magnitudes'
print 'real:', np.sum(np.abs(reconstructed_poly.real)), 'imag:', np.sum(np.abs(reconstructed_poly.imag))
poly /= poly.sum()
rpoly = np.abs(reconstructed_poly)
rpoly /= rpoly.sum()
err = np.sum( np.abs(poly - rpoly) / float(np.product(grid_dimesions)) )
print "Reconstruction error:", err
print 'showing model'
s1 = mlab.contour3d(rpoly)
mlab.show()
print 'showing error'
s2 = mlab.contour3d(rpoly - poly)
mlab.show()
return
示例4: vis_breakups
def vis_breakups():
"""
This function allows to visualize break-ups as the highlighted branches in
the original skeleton.
"""
data_sk = glob.glob('/backup/yuliya/vsi05/skeletons_largdom/*.h5')
data_sk.sort()
data_br = glob.glob('/backup/yuliya/vsi05/breakups_con_correction/dict/*.npy')
data_br.sort()
for i,j in zip(data_sk[27:67][::-1], data_br[19:][::-1]):
d = tb.openFile(i, mode='r')
bran1 = np.copy(d.root.branches)
skel1 = np.copy(d.root.skel)
d.close()
br = np.load(j).item()
mlab.figure(1, bgcolor=(1,1,1), size=(1200,1200))
surf_skel = mlab.contour3d(skel1, colormap='hot')
surf_skel.actor.property.representation = 'points'
surf_skel.actor.property.line_width = 2.3
mask = np.zeros_like(skel1)
for k in br:
sl = br[k]
mask[sl] = (bran1[sl] == k)
surf_mask = mlab.contour3d(mask.astype('uint8'))
surf_mask.actor.property.representation = 'wireframe'
surf_mask.actor.property.line_width = 5
mlab.savefig('/backup/yuliya/vsi05/breakups_con_correction/video_hot/' + i[39:-3] + '.png')
mlab.close()
示例5: showContour
def showContour(self):
"""
Display real space model using contour
"""
mlab.contour3d(self.array, contours=8, opacity=0.3, transparent=True)
mlab.outline()
mlab.show()
示例6: short_branches
def short_branches():
"""
Visualization of short branches of the skeleton.
"""
data1_sk = glob.glob('/backup/yuliya/vsi05/skeletons_largdom/*.h5')
data1_sk.sort()
for i,j, k in zip(d[1][37:47], data1_sk[46:56], ell[1][37:47]):
g = nx.read_gpickle(i)
dat = tb.openFile(j)
skel = np.copy(dat.root.skel)
bra = np.copy(dat.root.branches)
mask = np.zeros_like(skel)
dat.close()
length = nx.get_edge_attributes(g, 'length')
number = nx.get_edge_attributes(g, 'number')
num_dict = {}
for m in number:
for v in number[m]:
num_dict.setdefault(v, []).append(m)
find_br = ndimage.find_objects(bra)
for l in list(length.keys()):
if length[l]<0.5*k: #Criteria
for b in number[l]:
mask[find_br[b-1]] = bra[find_br[b-1]]==b
mlab.figure(bgcolor=(1,1,1), size=(1200,1200))
mlab.contour3d(skel, colormap='hot')
mlab.contour3d(mask)
mlab.savefig('/backup/yuliya/vsi05/skeletons/short_bran/'+ i[42:-10] + '.png')
mlab.close()
示例7: plot_LAM_contours
def plot_LAM_contours(self, readfile):
if self.LAMgauss == None:
print "Reading file..."
self.LAMgauss = self.load_data(readfile)
print "Plotting..."
mlab.contour3d(self.LAMgauss, contours = 75, opacity=0.10)
mlab.show()
示例8: show_scatterer
def show_scatterer(scatterer, spacing=None):
mlab = import_mayavi()
if spacing == None:
# if no spacing given, represent the object with 100 voxels
# along each dimension
spacing = [(b[1]-b[0])/100 for b in scatterer.bounds]
vol = scatterer.voxelate(spacing, 0)
mlab.contour3d(vol)
示例9: plotParcels
def plotParcels(self, brain, label = None, contourVals = [], opacity = 0.5, cmap='autumn'):
''' plot an isosurface using Mayavi, almost the same as skull plotting '''
if not(label):
label = self.getAutoLabel()
if contourVals == []:
self.isosurfacePlots[label] = mlab.contour3d(brain.parcels, opacity = opacity, colormap=cmap)
else:
self.isosurfacePlots[label] = mlab.contour3d(brain.parcels, opacity = opacity, contours = contourVals, colormap=cmap)
示例10: plot
def plot(ply):
'''
Plot vertices and triangles from a PlyData instance. Assumptions:
`ply' has a 'vertex' element with 'x', 'y', and 'z'
properties;
`ply' has a 'face' element with an integral list property
'vertex_indices', all of whose elements have length 3.
'''
vertex = ply['vertex']
(x, y, z) = (vertex[t] for t in ('x', 'y', 'z'))
# mlab.points3d(x, y, z, color=(1, 1, 1), mode='point')
if 'face' in ply:
tri_idx = ply['face']['vertex_indices']
print type(tri_idx)
idx_dtype = tri_idx[0].dtype
print "idx_dtype" , idx_dtype
triangles = numpy.fromiter(tri_idx, [('data', idx_dtype, (3,))],
count=len(tri_idx))['data']
k = triangles.byteswap()
# p.from_array(numpy.array([[1,2,3],[3,4,5]], dtype=numpy.float32))
p.from_array((triangles.byteswap().newbyteorder().astype('<f4')))
# p1.add_points_from_input_cloud()
p1.set_input_cloud(p)
fil = p.make_statistical_outlier_filter()
# cloud_filtered = fil.filter()
# fil = p1.make_statistical_outlier_filter()
fil.set_mean_k(20)
fil.set_std_dev_mul_thresh(0.1)
pointx = triangles[:,0]
pc_1 = pcl.PointCloud()
pc_1 = p
pc_2 = pcl.PointCloud()
pc_2 = p
kd = pcl.KdTreeFLANN(pc_1)
print('pc_1:')
print type(triangles)
# file1 = open("values.txt",'w')
# file1.write(str(triangles[:]))
# mlab.mesh(x,y,z)
print numpy.shape(p)
print numpy.shape(z)
print numpy.shape(y)
print numpy.shape(x)
mlab.contour3d(x, y, z, p)
示例11: plotIsosurface
def plotIsosurface(self, brain, label = None, contourVals = [], opacity = 0.1, cmap='autumn'):
''' plot an isosurface using Mayavi, almost the same as skull plotting '''
if not(label):
label = self.getAutoLabel()
if contourVals == []:
s = mlab.contour3d(brain.iso, opacity = opacity, colormap=cmap)
else:
s = mlab.contour3d(brain.iso, opacity = opacity, contours = contourVals, colormap=cmap)
# get the object for editing
self.isosurfacePlots[label] = s
示例12: show_fitting
def show_fitting(self, depth_image, offsets, model_transform):
v, u = np.nonzero(depth_image != 0)
depth = depth_image[(v,u)]/1000.0
points = np.vstack([depth*(u+offsets[0]), depth*(v+offsets[1]), depth])
model_points = np.dot(d.K_default_inv, points)
model_points = np.vstack([model_points, np.ones_like(model_points[0])])
transformed_points = np.dot(inv(model_transform), model_points)[0:3,:]
mlab.contour3d(self.x/self.scale[0], self.y/self.scale[1], self.z/self.scale[2], self.sdf, contours=[0.05], opacity=0.5)
mlab.points3d(transformed_points[0], transformed_points[1], transformed_points[2], color=(1,0,0), mode='point')
mlab.show()
示例13: plotBackground
def plotBackground(self, brain, label = None, contourVals = [3000,9000], opacity = 0.1, cmap='Spectral'):
''' plot the skull using Mayavi '''
if not(label):
label = self.getAutoLabel()
if contourVals == []:
s = mlab.contour3d(brain.background, opacity = opacity, colormap=cmap)
else:
s = mlab.contour3d(brain.background, opacity = opacity, contours = contourVals, colormap=cmap)
# get the object for editing
self.skullPlots[label] = s
示例14: plotSkull
def plotSkull(self, brain, label = None, contourVals = [], opacity = 0.1, cmap='Spectral'):
''' plot the skull using Mayavi '''
if not(label):
label = self.getAutoLabel()
# remove old version
if not(label in self.skullPlots):
self.skullPlots[label].remove()
if contourVals == []:
self.skullPlots[label] = mlab.contour3d(brain.background, opacity = opacity, colormap=cmap)
else:
self.skullPlots[label] = mlab.contour3d(brain.background, opacity = opacity, contours = contourVals, colormap=cmap)
示例15: plot_volume
def plot_volume(nifti_file,v_color=(.98,.63,.48),v_opacity=.1, fliplr=False, newfig=False):
"""
Render a volume from a .nii file
Use fliplr option if scan has radiological orientation
"""
import nibabel as nib
if newfig:
mlab.figure(bgcolor=(1, 1, 1), size=(400, 400))
input = nib.load(nifti_file)
input_d = input.get_data()
d_shape = input_d.shape
if fliplr:
input_d = input_d[range(d_shape[0]-1,-1,-1), :, :]
mlab.contour3d(input_d, color=v_color, opacity=v_opacity) # good natural color is (.98,.63,.48)