本文整理汇总了Python中mayavi.mlab.close函数的典型用法代码示例。如果您正苦于以下问题:Python close函数的具体用法?Python close怎么用?Python close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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()
示例2: toggleshow3
def toggleshow3(self):
if not self.show3On:
self.show3On = True
self.show3()
elif self.show3On:
mlab.close()
self.show3On = False
示例3: test_empty
def test_empty(self):
data=numpy.zeros((20,20,20))
mlab.figure( bgcolor=(0,0,0), size=(1000,845) )
ATMA.GUI.DataVisualizer.segmentation( data )
mlab.close()
示例4: Main
def Main(outputFolder, isData, normalized = True):
assert isinstance(outputFolder, str)
min, max = 0., 1.
if os.path.splitext(args.file)[1] == '.arff':
datasets, targets, targetMap = loadFromArff(args.file)
elif os.path.splitext(args.file)[1] == '.npy':
datasets = numpy.load(args.file)
min = -1.
else:
assert False
datasets = (lambda x : histogramEqualization(x, min=min, max=max) if normalized else x)(datasets)
if normalized : assert (datasets.min(), datasets.max()) == (min, max)
if not os.path.isdir("%s/Pictures" % outputFolder):
os.makedirs("%s/Pictures" % outputFolder)
global listIndex
if listIndex is None or (len(listIndex) >= len(datasets)):
listIndex = xrange(len(datasets))
for index in listIndex:
assert 0 <= index < len(datasets)
mlab.figure("Index : %d" % index, bgcolor=(1,1,1))
showArray(datasets[index], isData)
mlab.savefig("%s/Pictures/Index_%d.png" % (outputFolder, index))
if isData:
saveData('%s/Pictures/%s_Index_%d.txt' % (outputFolder, targetMap.reverse_mapping[targets[index]], index), datasets[index])
else:
saveData('%s/Pictures/Index_%d.txt' % (outputFolder, index), datasets[index])
mlab.close()
示例5: test_rawData
def test_rawData(self):
raw=numpy.uint32(numpy.random.rand(200,200,200)*255)
mlab.figure( bgcolor=(0,0,0), size=(1000,845) )
ATMA.GUI.DataVisualizer.rawSlider( raw )
mlab.close()
示例6: savefig
def savefig(filename,mlabview=[],magnification = 3):
"""
Save mayavi figure
Parameters
----------
name : str
name of the figure
mlabview : [] | (x,y,z, np.array([ xroll,yroll,zroll]))
specifyy angle of camera view ( see mayavi.view )
magnification : int
resolution of the generated image ( see mayavi.savefig)
"""
import os
path = os.path.dirname(filename)
if not mlabview == []:
mlab.view(mlabview)
if os.path.exists(path):
mlab.savefig(filename+'.png',magnification=magnification )
else:
os.mkdir(path)
mlab.savefig(filename+'.png',magnification=magnification )
mlab.close()
示例7: mayavi_scraper
def mayavi_scraper(block, block_vars, gallery_conf):
"""Scrape Mayavi images.
Parameters
----------
block : tuple
A tuple containing the (label, content, line_number) of the block.
block_vars : dict
Dict of block variables.
gallery_conf : dict
Contains the configuration of Sphinx-Gallery
Returns
-------
rst : str
The ReSTructuredText that will be rendered to HTML containing
the images. This is often produced by
:func:`sphinx_gallery.gen_rst.figure_rst`.
"""
from mayavi import mlab
image_path_iterator = block_vars['image_path_iterator']
image_paths = list()
e = mlab.get_engine()
for scene, image_path in zip(e.scenes, image_path_iterator):
mlab.savefig(image_path, figure=scene)
# make sure the image is not too large
scale_image(image_path, image_path, 850, 999)
image_paths.append(image_path)
mlab.close(all=True)
return figure_rst(image_paths, gallery_conf['src_dir'])
示例8: 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()
示例9: test_close
def test_close(self):
""" Various tests for mlab.close().
"""
f = mlab.figure()
self.assertTrue(f.running)
mlab.close(f)
self.assertFalse(f.running)
f = mlab.figure(314)
self.assertTrue(f.running)
mlab.close(314)
self.assertFalse(f.running)
f = mlab.figure('test_figure')
self.assertTrue(f.running)
mlab.close('test_figure')
self.assertFalse(f.running)
f = mlab.figure()
self.assertTrue(f.running)
mlab.close()
self.assertFalse(f.running)
figs = [mlab.figure() for i in range(5)]
for f in figs:
self.assertTrue(f.running)
mlab.close(all=True)
for f in figs:
self.assertFalse(f.running)
示例10: plot_inverse_operator
def plot_inverse_operator(subject, fnout_img=None, verbose=None):
""""Reads in and plots the inverse solution."""
# get name of inverse solution-file
subjects_dir = os.environ.get('SUBJECTS_DIR')
fname_dir_inv = os.path.join(subjects_dir,
subject)
for files in os.listdir(fname_dir_inv):
if files.endswith(",cleaned_epochs_avg-7-src-meg-inv.fif"):
fname_inv = os.path.join(fname_dir_inv,
files)
break
try:
fname_inv
except NameError:
print "ERROR: No forward solution found!"
sys.exit()
# read inverse solution
inv = min_norm.read_inverse_operator(fname_inv)
# print some information if desired
if verbose is not None:
print "Method: %s" % inv['methods']
print "fMRI prior: %s" % inv['fmri_prior']
print "Number of sources: %s" % inv['nsource']
print "Number of channels: %s" % inv['nchan']
# show 3D source space
lh_points = inv['src'][0]['rr']
lh_faces = inv['src'][0]['tris']
rh_points = inv['src'][1]['rr']
rh_faces = inv['src'][1]['tris']
# create figure and plot results
fig_inverse = mlab.figure(size=(1200, 1200),
bgcolor=(0, 0, 0))
mlab.triangular_mesh(lh_points[:, 0],
lh_points[:, 1],
lh_points[:, 2],
lh_faces)
mlab.triangular_mesh(rh_points[:, 0],
rh_points[:, 1],
rh_points[:, 2],
rh_faces)
# save result
if fnout_img is not None:
mlab.savefig(fnout_img,
figure=fig_inverse,
size=(1200, 1200))
mlab.close(all=True)
示例11: close
def close(self):
"""Close the figure and cleanup data structure."""
try:
from mayavi import mlab
except ImportError:
from enthought.mayavi import mlab
mlab.close(self._f)
示例12: close
def close(self):
for f in self.figures.itervalues():
plt.close(f)
self.figures = {}
self.figMslices.close()
mlab.close(self.fig1)
if self.show_grad:
self.figdMslices.close()
示例13: test_save_load_visualization_with_mlab
def test_save_load_visualization_with_mlab(self):
# test mlab.get_engine
engine = mlab.get_engine()
try:
self.check_save_load_visualization(engine)
finally:
mlab.clf()
mlab.close(all=True)
示例14: surfacePlot
def surfacePlot(
Hmap,
nrows,
ncols,
xyspacing,
zscale,
name,
hRange,
file_path,
lutfromfile,
lut,
lut_file_path,
colorbar_on,
save,
show,
):
# Create a grid of the x and y coordinates corresponding to each pixel in the height matrix
x, y = np.mgrid[0 : ncols * xyspacing : xyspacing, 0 : nrows * xyspacing : xyspacing]
# Create a new figure
mlab.figure(size=(1000, 1000))
# Set the background color if desired
# bgcolor=(0.16, 0.28, 0.46)
# Create the surface plot of the reconstructed data
plot = mlab.surf(x, y, Hmap, warp_scale=zscale, vmin=hRange[0], vmax=hRange[1], colormap=lut)
# Import the LUT from a file if necessary
if lutfromfile:
plot.module_manager.scalar_lut_manager.load_lut_from_file(lut_file_path)
# Draw the figure with the new LUT if necessary
mlab.draw()
# Zoom in to fill the entire window
f = mlab.gcf()
f.scene.camera.zoom(1.05)
# Change the view to a top-down perspective
mlab.view(270, 0)
# Add a colorbar if indicated by colorbar_on (=True)
if colorbar_on:
# mlab.colorbar(title='Height (nm)', orientation='vertical')
mlab.colorbar(orientation="vertical")
# Save the figure if indicated by save (=True)
if save:
mlab.savefig(file_path, size=(1000, 1000))
if show == False:
mlab.close()
# Keep the figure open if indicated by show (=True)
if show:
mlab.show()
示例15: mayavi_plt
def mayavi_plt():
ml.test_plot3d()
arr = ml.screenshot()
ml.close()
plt.imshow(arr)
plt.axis('off')
plt.show()