def redraw_scene3(self, scene): # Notice how each mlab call points explicitely to the figure it # applies to. xx = self.xx yy = self.yy zz = self.zz vxyz = self.vxyz mlab.clf(figure=scene.mayavi_scene) s = mlab.volume_slice(xx, yy, zz, vxyz, plane_orientation='x_axes', colormap=self.color, vmin=self.vmin, vmax=self.vmax, figure=scene.mayavi_scene) t = mlab.volume_slice(xx, yy, zz, vxyz, plane_orientation='y_axes', colormap=self.color, vmin=self.vmin, vmax=self.vmax, figure=scene.mayavi_scene) u = mlab.volume_slice(xx, yy, zz, vxyz, plane_orientation='z_axes', colormap=self.color, vmin=self.vmin, vmax=self.vmax, figure=scene.mayavi_scene) if self.n == 1: lut = s.module_manager.scalar_lut_manager.lut.table.to_array() ilut = lut[::-1] s.module_manager.scalar_lut_manager.lut.table = ilut lut = t.module_manager.scalar_lut_manager.lut.table.to_array() ilut = lut[::-1] t.module_manager.scalar_lut_manager.lut.table = ilut lut = u.module_manager.scalar_lut_manager.lut.table.to_array() ilut = lut[::-1] u.module_manager.scalar_lut_manager.lut.table = ilut scene.mlab.colorbar() mlab.axes(ranges=[np.min(xx), np.max(xx), np.min(yy), np.max(yy), np.min(zz), np.max(zz)], figure=scene.mayavi_scene) mlab.outline(figure=scene.mayavi_scene)
def volume_slice(self, data, save_name=None, cmap='viridis', vmin=None, vmax=None, show=False, bgcolor=(1., 1., 1.)): '''Open Mayavi scene New function ''' # Import mlab from mayavi import mlab # try: # engine = mayavi.engine # except NameError: # from mayavi.api import Engine #engine = Engine() # engine.start() if vmin is None: vmin = np.nanpercentile(data, 0.1) if vmax is None: vmax = np.nanpercentile(data, 99.9) # if len(engine.scenes) == 0: # engine.new_scene() mlab.figure(size=(1000, 1000), bgcolor=bgcolor) mlab.clf() mlab.volume_slice(data.values, plane_orientation='x_axes') mlab.view(azimuth=azimuth, elevation=elevation, distance=distance, roll=roll) #module_manager = engine.scenes[0].children[0].children[0] #module_manager.scalar_lut_manager.lut_mode = cmap #scene = engine.scenes[0] # scene.scene.x_minus_view() if save_name != None: mlab.savefig(save_name, size=(1000, 1000)) if show_slice: mlab.show() return None
def plot_vortex(): field = read_wavelet_integrals(2, 4, 4) noise = np.random.randn(3, 4, 1, 1, 1) noise_field = np.ma.sum([ noise[2] * field.y - noise[1] * field.z, noise[0] * field.z - noise[2] * field.x, noise[1] * field.x - noise[0] * field.y ], axis=1) dnf = div(np.moveaxis(noise_field, 0, -1), 2. / 32.) mlab.figure() mlab.quiver3d(noise_field[0], noise_field[1], noise_field[2], mode='arrow') mlab.volume_slice(dnf)
def plot_field(sf, level, **kwds): s = slice(sf.r - sf.r // 2, sf.r + sf.r // 2) v = sf.compute(level, **kwds)[s, s, s] o_mag = np.sqrt(np.sum(vorticity(v, 2. / v.shape[0])**2, axis=-1)) dv = div(v, 2. / v.shape[0]) mlab.figure() mlab.quiver3d(v[..., 0], v[..., 1], v[..., 2], mode='arrow', mask_points=128, scale_factor=16) mlab.contour3d(o_mag) mlab.volume_slice(o_mag) mlab.volume_slice(dv)
def plot_3d(img, slice=False, axis='z', color=None, size=(1000, 800)): """Visualize 3D segmentation results via mayavi""" res = None try: img = img.astype(np.uint16) assert img.ndim == 3, "Invalid dimension of 3D image: {}".format( img.ndim) bg_color = colors.to_rgb("black") depth, height, width = img.shape mlab.figure(bgcolor=bg_color, size=size) axes_extent = [0, height, 0, width, 0, depth] xlabel, ylabel, zlabel = 'X', 'Y', 'Z' if slice: if axis == 'z': res = mlab.volume_slice(img, colormap='Vega20') axes_extent = [0, depth, 0, height, 0, width] xlabel, zlabel = 'Z', 'X' else: res = mlab.volume_slice(img.transpose((1, 2, 0)), colormap='Vega20') else: if color is not None: res = mlab.contour3d(img.transpose((1, 2, 0)), color=color) else: res = mlab.contour3d(img.transpose((1, 2, 0)), contours=10, transparent=True) # axes feature configuration ax = mlab.axes(line_width=0.5, extent=axes_extent, xlabel=xlabel, ylabel=ylabel, zlabel=zlabel) ax.axes.font_factor = 0.75 mlab.outline() except FileNotFoundError: print("3D segmentation array loading unsuccessful") return res
def volume_slice_wrap( data, plane_orientation='x_axes', # options: 'x_axes', 'y_axes', 'z_axes' slice_index=0, figure=None): if figure is None: figure = mlab.gcf() plot = mlab.volume_slice(data, plane_orientation=plane_orientation, slice_index=slice_index, figure=figure) return plot
def disp_3d_slice(self, axis='z'): """Display 3D segmentation results interactively along z-axis or y-axis""" depth, height, width = self.masks.shape bg_color = colors.to_rgb("black") axes_extent = [0, depth, 0, height, 0, width] xlabel, ylabel, zlabel = 'X', 'Y', 'Z' if axis == 'z': res = mlab.volume_slice(self.masks, colormap='Vega20') axes_extent = [0, depth, 0, height, 0, width] xlabel, zlabel = 'Z', 'X' else: res = mlab.volume_slice(self.masks.transpose((1, 2, 0)), colormap='Vega20') ax = mlab.axes(line_width=0.5, extent=axes_extent, xlabel=xlabel, ylabel=ylabel, zlabel=zlabel) ax.axes.font_factor = 0.75 mlab.outline() return res
def show3Dslice(image): """ 查看3D体,切片模式 :param image: :return: """ mlab.volume_slice(image, colormap='gray', plane_orientation='x_axes', slice_index=10) # 设定x轴切面 mlab.volume_slice(image, colormap='gray', plane_orientation='y_axes', slice_index=10) # 设定y轴切面 mlab.volume_slice(image, colormap='gray', plane_orientation='z_axes', slice_index=10) # 设定z轴切面 mlab.colorbar(orientation='vertical') mlab.show()
def gaussian_fn(sigma, size=31, plot=False): (z, y, x) = np.meshgrid(np.arange(-size, size + 1), np.arange(-size, size + 1), np.arange(-size, size + 1)) g = np.exp(-(x**2 / float(size) + y**2 / float(size) + z**2 / float(size))) gauss = g / g.sum() if plot: mlab.volume_slice(g, plane_orientation='x_axes', slice_index=31) mlab.volume_slice(g, plane_orientation='y_axes', slice_index=31) mlab.volume_slice(g, plane_orientation='z_axes', slice_index=31) mlab.show() return gauss
def generatePlotVolumeData(self): z_step = np.median(self.dz) * self.z_reduction vx, vy, vz = np.arange(0, np.max(self.x) + 1), np.arange( 0, np.max(self.y) + 1), np.arange(np.min(self.z), np.max(self.z), z_step) scalars = np.zeros( (np.size(vx), np.size(vy), np.size(vz)), dtype=np.int8) scalar_z_idx = 0 scalar_tz = vz[scalar_z_idx] scalar_z_th = scalar_tz + z_step for z_idx, tz in enumerate(self.z): if tz >= scalar_z_th: scalar_z_idx += 1 scalar_tz = vz[scalar_z_idx] scalar_z_th = scalar_tz + z_step tx, ty, ts = int(self.x[z_idx]), int(self.y[z_idx]), self.s[z_idx] scalars[tx, ty, scalar_z_idx] += ts mlab.clf(figure=self.volume_scene.mayavi_scene) valueLimit = max(abs(np.min(scalars)), np.max(scalars)) self.slicer = mlab.volume_slice(scalars, figure=self.volume_scene.mayavi_scene, colormap="seismic", plane_orientation="z_axes", vmin=-valueLimit, vmax=valueLimit, extent=[np.min(self.x), np.max(self.x), np.min(self.y), np.max(self.y), 0, np.size(vz)]) self.slicer.module_manager.scalar_lut_manager.lut.table[128] = (255.0, 255.0, 245.0, 255.0)
def gabor_fn(sigma, thetas, Lambda, psi, gamma, size, plot=False, slices=False): sigma_x = sigma sigma_y = float(sigma) / gamma sigma_z = float(sigma) / gamma # Bounding box (z, y, x) = np.meshgrid(np.arange(-size, size + 1), np.arange(-size, size + 1), np.arange(-size, size + 1)) # Rotation R = rotation(thetas) z_prime = z * R[0, 0] + y * R[0, 1] + x * R[0, 2] y_prime = z * R[1, 0] + y * R[1, 1] + x * R[1, 2] x_prime = z * R[2, 0] + y * R[2, 1] + x * R[2, 2] gb = np.exp( -.5 * (x_prime**2 / sigma_x**2 + y_prime**2 / sigma_y**2 + z_prime**2 / sigma_z)) * np.cos(2 * np.pi * x_prime / Lambda + psi) if plot: if slices: mlab.volume_slice(gb, plane_orientation='x_axes', slice_index=31) mlab.volume_slice(gb, plane_orientation='y_axes', slice_index=31) mlab.volume_slice(gb, plane_orientation='z_axes', slice_index=31) mlab.show() mlab.contour3d(gb) mlab.show() return gb
# cmap = colorcet.linear_bmy_10_95_c78 cmap = list(reversed(colorcet.linear_bmy_10_95_c78)) # cmap = list( reversed( colorcet.rainbow_bgyrm_35_85_c71 ) ) colormap = 'spectral' if cmap_key == 'spectral': colormap = 'spectral' elif cmap_key == 'div': colormap = 'RdBu' if plot_type == 'vslice': plot = mlab.volume_slice(data, colormap=colormap, plane_orientation='x_axes', slice_index=data.shape[0] / 2) elif plot_type == 'contour': m = np.amax(data) contours = list(np.linspace(m / 4, m - 2, 3)) plotting.contour3d_wrap(data, contours=contours, opacity=0.1) # print( cmap[2] ) if cmap_key == 'linear': lut_table = np.zeros((len(cmap), 3)) new_table = np.append(255 * np.array(cmap), 255 * np.ones((len(cmap), 1)), axis=1) print(new_table.shape)
def prepare(self, System: Schroedinger): prob_3d = np.abs(System.psi_val)**2 prob_plot = mlab.contour3d(System.x_mesh, System.y_mesh, System.z_mesh, prob_3d, colormap="spectral", opacity=self.alpha_psi, transparent=True) slice_x_plot = mlab.volume_slice( System.x_mesh, System.y_mesh, System.z_mesh, prob_3d, colormap="spectral", plane_orientation="x_axes", slice_index=self.slice_indices[0], ) slice_y_plot = mlab.volume_slice( System.x_mesh, System.y_mesh, System.z_mesh, prob_3d, colormap="spectral", plane_orientation="y_axes", slice_index=self.slice_indices[1], ) slice_z_plot = mlab.volume_slice( System.x_mesh, System.y_mesh, System.z_mesh, prob_3d, colormap="spectral", plane_orientation="z_axes", slice_index=self.slice_indices[2], ) if self.plot_V: V_plot = mlab.contour3d(System.x_mesh, System.y_mesh, System.z_mesh, System.V_val, colormap="hot", opacity=self.alpha_V, transparent=True) else: V_plot = None if System.psi_sol_val is not None: if self.plot_psi_sol: psi_sol_plot = mlab.contour3d(System.x_mesh, System.y_mesh, System.z_mesh, System.psi_sol_val, colormap="cool", opacity=self.alpha_psi_sol, transparent=True) else: psi_sol_plot = None else: psi_sol_plot = None axes_style() return prob_plot, slice_x_plot, slice_y_plot, slice_z_plot, V_plot, psi_sol_plot
#vx, vy, vz = np.arange(np.min(x), np.max(x) + 1), np.arange(np.min(y), np.max(y) + 1), np.arange(np.min(z), np.max(z) + 1, z_step) #vx, vy, vz = np.ogrid[np.min(x):np.max(x), np.min(y):np.max(y), np.min(z):np.max(z):z_step] #vx, vy, vz = *np.ogrid[np.min(rdx):np.max(rdx), np.min(rdy):np.max(rdy)], np.moveaxis(np.atleast_3d(rdz), 1, 2) #coords = zip(x, y, z) scalars = np.zeros((np.size(vx), np.size(vy), np.size(vz)), dtype=np.int8) scalar_z_idx = 0 scalar_tz = vz[scalar_z_idx] scalar_z_th = scalar_tz + z_step for z_idx, tz in enumerate(z): if tz >= scalar_z_th: scalar_z_idx += 1 scalar_tz = vz[scalar_z_idx] scalar_z_th = scalar_tz + z_step tx, ty, ts = int(x[z_idx]), int(y[z_idx]), s[z_idx] scalars[tx, ty, scalar_z_idx] += ts slicer = mlab.volume_slice( scalars, colormap="coolwarm", plane_orientation="z_axes", vmin=np.min(s), vmax=np.max(s), extent=[np.min(x), np.max(x), np.min(y), np.max(y), 0, np.size(vz)])
def test_volume_slice(): x, y, z = np.ogrid[-5:5:64j, -5:5:64j, -5:5:64j] scalars = x * x * 0.5 + y * y + z * z * 2.0 obj = mlab.volume_slice(scalars, plane_orientation='x_axes') return obj
#!/usr/bin/env python3 import h5py import sys from mayavi import mlab import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D with h5py.File(sys.argv[1], 'r') as f: print("Available keys:") for key in f.keys(): print(key) data = np.array(f[sys.argv[2]]) s = mlab.contour3d(data, colormap="YlGnBu") mlab.show() s = mlab.volume_slice(data, colormap="YlGnBu") mlab.show()
verts, faces = measure.marching_cubes_classic(p,threshold) fig = plt.figure(figsize=(10, 10)) ax = fig.add_subplot(111, projection='3d') # Fancy indexing: `verts[faces]` to generate a collection of triangles mesh = Poly3DCollection(verts[faces], alpha=0.70) face_color = [0.45, 0.45, 0.75] mesh.set_facecolor(face_color) ax.add_collection3d(mesh) ax.set_xlim(0, p.shape[0]) ax.set_ylim(0, p.shape[1]) ax.set_zlim(0, p.shape[2]) plt.show() #%% lassion_path=findDicomfile(INPUT_FOLDER + "001/Texturanalyse/001 CT Läsion")[0] #%% first_patient_Lassion = dicom.read_file(lassion_path) first_patient_Lassion.pixel_array.shape #%% from mayavi import mlab import vtk first_patient_Lassion = dicom.read_file(lassion_path) mlab.volume_slice(first_patient_Lassion.pixel_array) mlab.show()
x,y,z = r*np.cos(theta)*np.sin(phi),r*np.sin(theta)*np.sin(phi),r*np.cos(phi) mlab.mesh(x,y,z,representation='wireframe') points = np.array([[0,0,0],[0,1,0],[1,1,0],[1,0,0],[0.5,0.5,1]]) t = [[0,1,2],[0,3,2],[0,1,4],[1,2,4],[2,3,4],[3,0,4]] x,y,z = points.T mlab.triangular_mesh(x,y,z,t) vals = np.random.random((2<<6,2<<6)) mlab.imshow(vals) x,y,z = np.mgrid[-5:5:64j,-5:5:64j,-5:5:64j] mlab.contour3d(0.5*x**2 + y**2 + 2*z**2) mlab.volume_slice(x,y,z,0.5*x*x + y*y + 2*z*z) mlab.test_quiver3d() x,y,z = np.mgrid[-2:3:50j,-2:3:50j,-2:3:50j] r = np.sqrt(x**2 + y**2 + z**2) u = y*np.sin(r)/(r+0.001) v = -x*np.sin(r)/(r+0.001) w = np.ones_like(z)*0.1 mlab.flow(x,y,z,u,v,w,seedtype='plane') def lorenz(x,y,z,s=10,r=28,b=8/3): u = s*(y-x) v = r*x-y-x*z
def vis_sliced(data, axis_order='xyz', **kwargs): if axis_order != 'xyz': data = data.transpose(tuple(_dim[w] for w in axis_order)) if data.dtype not in (np.float32, np.float64): data = data.astype(np.float32) mlab.volume_slice(data, **kwargs)
import numpy as np from mayavi import mlab from other_utils import read_cbin size = 1 fname = '19-02T22-47-38/outputs/pred_val_image_21cm.bin' data = read_cbin(fname) print(data.shape) x, y, z = np.mgrid[0:128:64j, 0:128:64j, 0:128:64j] mlab.volume_slice(x, y, z, data, plane_opacity=0., transparent=True) #mlab.figure(bgcolor=(0,0,0)) mlab.outline() mlab.show() mlab.clf()
idx = 30 tristan_data.load_indices([idx]) print(tristan_data.data.bx[30].shape) sys.exit(0) # x, y, z = np.ogrid[-5:5:64j, -5:5:64j, -5:5:64j] # print( x ) # print( x.shape ) # print # scalars = x * x * 0.5 + y * y + z * z * 2.0 obj = mlab.volume_slice(tristan_data.data.bz[idx], plane_orientation='x_axes') mlab.show() bx, by, bz = [tristan_data.data[key][idx] for key in ['bx', 'by', 'bz']] mlab.quiver3d(bx, by, bz) mlab.show() mlab.flow(bx, by, bz) mlab.show()
def test_volume_slice(self): x, y, z = np.ogrid[-5:5:20j, -5:5:20j, -5:5:20j] scalars = x * x * 0.5 + y * y + z * z * 2.0 ipw = mlab.volume_slice(scalars, plane_orientation='y_axes') self.assertEqual(ipw.ipw.plane_orientation, 'y_axes')
# using mayavi elem_data = oncstruct.process_file(structname.name) print('elem_data',elem_data[0,:], np.shape(elem_data),type(elem_data)) # with open("test.csv","w+") as my_csv: # writing the file as my_csv # csvWriter = csv.writer(my_csv,delimiter=',') # using the csv module to write the file # csvWriter.writerows(elem_data) # using matplotlib # elem_data = oncstruct.process_file(structname.name, fig, ax) if args.dose: dosename = args.dose print(dosename.name) x, y, z, dx, dy, dz, volume = oncdose.process_file(dosename.name) # using mayavi mlab.volume_slice(x, y, z, volume, plane_orientation="z_axes") # mlab.contour3d(x,y,z,volume,contours=15,opacity=1) mlab.colorbar(title="Dose [cGy]", orientation="vertical") if args.plan: planname = args.plan print(planname.name) xs, ys, zs, ts = oncplan.process_file(planname.name) # using mayavi mlab.points3d(xs, ys, zs, ts) ax = mlab.axes(nb_labels=8) ax.axes.font_factor = 1
def plotIsosurfaces3D(x3D, y3D, z3D, surface3Dlist, contourList, slice3Dlist=(None, ), boundSurface=(None, ), customColors=(None, ), figDir='./', name='UntitledIsosurface', sliceOriantations=(None, ), sliceOffsets=(None, ), boundSlice=(None, ), sliceValRange=(None, )): from mayavi import mlab from mayavi.modules.contour_grid_plane import ContourGridPlane from mayavi.modules.outline import Outline from mayavi.api import Engine import numpy as np from warnings import warn x3D, y3D, z3D = np.array(x3D), np.array(y3D), np.array(z3D) engine = Engine() engine.start() # if len(engine.scenes) == 0: # engine.new_scene() if customColors[0] is not None: customColors = iter(customColors) else: customColors = iter( ('inferno', 'viridis', 'coolwarm', 'Reds', 'Blues') * 2) contourList = iter(contourList) if sliceOriantations[0] is not None: sliceOriantations = iter(sliceOriantations) else: sliceOriantations = iter(('z_axes', ) * len(slice3Dlist)) if boundSurface[0] is None: boundSurface = (x3D.min(), x3D.max(), y3D.min(), y3D.max(), z3D.min(), z3D.max()) if boundSlice[0] is None: boundSlice = (x3D.min(), x3D.max(), y3D.min(), y3D.max(), z3D.min(), z3D.max()) if sliceOffsets[0] is None: sliceOffsets = iter((0, ) * len(slice3Dlist)) else: sliceOffsets = iter(sliceOffsets) if sliceValRange[0] is None: sliceValRange = iter((None, None) * len(slice3Dlist)) else: sliceValRange = iter(sliceValRange) mlab.figure(name, engine=engine, size=(1200, 900), bgcolor=(1, 1, 1), fgcolor=(0.5, 0.5, 0.5)) for surface3D in surface3Dlist: color = next(customColors) # If a colormap given if isinstance(color, str): mlab.contour3d(x3D, y3D, z3D, surface3D, contours=next(contourList), colormap=color, extent=boundSurface) # If only one color of (0-1, 0-1, 0-1) given else: mlab.contour3d(x3D, y3D, z3D, surface3D, contours=next(contourList), color=color, extent=boundSurface) # cgp = ContourGridPlane() # engine.add_module(cgp) # cgp.grid_plane.axis = 'y' # cgp.grid_plane.position = x3D.shape[1] - 1 # cgp.contour.number_of_contours = 20 # # contour_grid_plane2.actor.mapper.scalar_range = array([298., 302.]) # # contour_grid_plane2.actor.mapper.progress = 1.0 # # contour_grid_plane2.actor.mapper.scalar_mode = 'use_cell_data' # cgp.contour.filled_contours = True # cgp.actor.property.lighting = False for slice3D in slice3Dlist: sliceOriantation = next(sliceOriantations) sliceOffset = next(sliceOffsets) if sliceOriantation == 'z_axes': origin = np.array([boundSlice[0], boundSlice[2], sliceOffset]) point1 = np.array([boundSlice[1], boundSlice[2], sliceOffset]) point2 = np.array([boundSlice[0], boundSlice[3], sliceOffset]) elif sliceOriantation == 'x_axes': origin = np.array([sliceOffset, boundSlice[2], boundSlice[4]]) point1 = np.array([sliceOffset, boundSlice[3], boundSlice[4]]) point2 = np.array([sliceOffset, boundSlice[2], boundSlice[5]]) else: origin = np.array([boundSlice[0], sliceOffset, boundSlice[4]]) point1 = np.array([boundSlice[1], sliceOffset, boundSlice[4]]) point2 = np.array([boundSlice[0], sliceOffset, boundSlice[5]]) image_plane_widget = mlab.volume_slice( x3D, y3D, z3D, slice3D, plane_orientation=sliceOriantation, colormap=next(customColors), vmin=next(sliceValRange), vmax=next(sliceValRange)) image_plane_widget.ipw.reslice_interpolate = 'cubic' image_plane_widget.ipw.origin = origin image_plane_widget.ipw.point1 = point1 image_plane_widget.ipw.point2 = point2 # image_plane_widget.ipw.slice_index = 2 image_plane_widget.ipw.slice_position = sliceOffset # Contour grid plane at last y if the last slice is in xy plane if sliceOriantation == 'z_axes': cgp2 = ContourGridPlane() engine.add_module(cgp2) cgp2.grid_plane.axis = 'y' cgp2.grid_plane.position = x3D.shape[1] - 1 cgp2.contour.number_of_contours = 20 cgp2.contour.filled_contours = True cgp2.actor.property.lighting = False outline = Outline() engine.add_module(outline) outline.actor.property.color = (0.2, 0.2, 0.2) outline.bounds = np.array(boundSurface) outline.manual_bounds = True mlab.view(azimuth=270, elevation=45) mlab.move(-500, 0, 0) mlab.savefig(figDir + '/' + name + '.png', magnification=3) print('\nFigure ' + name + ' saved at ' + figDir) mlab.show()
mlab.show() elif TYPES == 4: S = S.reshape(N, N, N) mlab.pipeline.image_plane_widget( mlab.pipeline.scalar_field(S), plane_orientation='x_axes', slice_index=int(N / 2), ) mlab.pipeline.image_plane_widget( mlab.pipeline.scalar_field(S), plane_orientation='y_axes', slice_index=int(N / 2), ) mlab.outline() mlab.volume_slice(S, plane_orientation='x_axes', slice_index=30) mlab.show() elif TYPES == 5: S = S.reshape(N, N, N) mlab.contour3d(S) mlab.show() """ import numpy as np from scipy.interpolate import RegularGridInterpolator def f(x, y, z): return 2 * x**3 + 3 * y**2 - z x = np.linspace(1, 4, 11) y = np.linspace(4, 7, 22)
def show_slice(self, data): mlab.volume_slice(data, plane_orientation='z_axes', slice_index=50) mlab.show()
import numpy as np from mayavi import mlab from time import sleep DATFILE = r"C:\Users\rdboylan\Documents\Kornak\bifs\bifs\src\ep1.npz" x = np.load(DATFILE) m = x["mean"] sd = x["sd"] x.close() aSlice = mlab.volume_slice(m) iMin = np.min(m.shape) # we know it will be the x axis iMin = m.shape[0] m0 = m #m = np.zeros_like(m0) #m[m0>100] = 1.0 m = np.log(m0) mlab.pipeline.volume(mlab.pipeline.scalar_field(m)) mlab.show_pipeline() #mlab.show() @mlab.animate(delay=200) def anim(): for i in range(iMin): aSlice.ipw.slice_index = i #mlab.process_ui_events() yield mlab.outline()