How to use the mayavi.mlab.view function in mayavi

To help you get started, we’ve selected a few mayavi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BNUCNL / FreeROI / froi / widgets / surfaceview.py View on Github external
self.surf.remove()
                    self.surf = self.visualization.scene.mlab.pipeline.surface(self.mesh)
                self.surf.module_manager.scalar_lut_manager.lut.table = self.tmp_lut
        elif self._show_cbar:
            self.mesh.mlab_source.scalars = self.scalars
            self.surf.remove()
            self.surf = self.visualization.scene.mlab.pipeline.surface(self.mesh,
                                                                       vmin=self.top_ol.get_vmin(),
                                                                       vmax=self.top_ol.get_vmax())
            self.surf.module_manager.scalar_lut_manager.lut.table = self.lut_opaque
            # FIXME In this case, I can't use 'mlab.colorbar' to recreate the color bar and
            # it is only able to be turned on its visibility if I want to show it again. But,
            # it will appear with strange size, and I can't adjust it by using 'position' and 'position2'.
            self.cbar.visible = True

        azimuth, elevation, distance, focalpoint = mlab.view()
        roll = mlab.roll()
        self.surface_model.camera_to_edit(azimuth, elevation, distance, focalpoint, roll)
github lambdaloop / anipose / anipose / label_videos_3d.py View on Github external
fig = mlab.figure(bgcolor=(1,1,1), size=(500,500))
    fig.scene.anti_aliasing_frames = 2

    low, high = np.percentile(points[good, 0], [10,90])
    scale_factor = (high - low) / 10.0

    mlab.clf()
    pts = mlab.points3d(points[:, 0], -points[:, 1], points[:, 2], s,
                        scale_mode='none', scale_factor=scale_factor)
    lines = connect_all(points, scheme, bp_dict, cmap)
    mlab.orientation_axes()

    view = list(mlab.view())

    mlab.view(focalpoint='auto', distance='auto')

    for framenum in trange(data.shape[0], ncols=70):
        fig.scene.disable_render = True

        if framenum in framedict:
            points = all_points[:, framenum]
        else:
            points = np.ones((nparts, 3))*np.nan

        s = np.arange(points.shape[0])
        good = ~np.isnan(points[:, 0])

        new = np.vstack([points[:, 0], points[:, 1], points[:, 2]]).T
        pts.mlab_source.points = new
        update_all_lines(lines, points, scheme, bp_dict)
github JenningsL / PointRCNN / visualize / mayavi / mayavi_utils.py View on Github external
sc=tvtk.UnsignedCharArray()
    sc.from_array(color)
    pts.mlab_source.dataset.point_data.scalars=sc
    pts.mlab_source.dataset.modified()
    #draw origin
    mlab.points3d(0, 0, 0, color=(1,1,1), mode='sphere', scale_factor=0.02)
    #draw axis
    axes=np.array([
        [2.,0.,0.,0.],
        [0.,2.,0.,0.],
        [0.,0.,2.,0.],
    ],dtype=np.float64)
    mlab.plot3d([0, axes[0,0]], [0, axes[0,1]], [0, axes[0,2]], color=(1,0,0), tube_radius=None, figure=fig)
    mlab.plot3d([0, axes[1,0]], [0, axes[1,1]], [0, axes[1,2]], color=(0,1,0), tube_radius=None, figure=fig)
    mlab.plot3d([0, axes[2,0]], [0, axes[2,1]], [0, axes[2,2]], color=(0,0,1), tube_radius=None, figure=fig)
    mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=62.0, figure=fig)
    return fig
github nipy / PySurfer / surfer / viz.py View on Github external
current_view = mlab.view(figure=brain._f)
        colorbars = self._get_colorbars(row, col)
        colorbars_visibility = dict()
        for cb in colorbars:
            if cb is not None:
                colorbars_visibility[cb] = cb.visible

        images = self.save_imageset(None, views, colorbar=colorbar, row=row,
                                    col=col)
        out = make_montage(filename, images, orientation, colorbar,
                           border_size)

        # get back original view and colorbars
        if current_view is not None:  # can be None with test backend
            with warnings.catch_warnings(record=True):  # traits focalpoint
                mlab.view(*current_view, figure=brain._f)
        for cb in colorbars:
            if cb is not None:
                cb.visible = colorbars_visibility[cb]
        return out
github raysearchlabs / dicomutils / viewer / mlc.py View on Github external
def move_camera_to_bev(self):
        # Okay, so there is a better solution to inclination and azimuth, but in
        # the interest of getting things done, I leave this as an 
        # exercise to the reader to solve exactly.
        M = (np.linalg.inv(coordinates.Mfg(self.gantry_pitch_angle, self.gantry_angle))
             * np.linalg.inv(coordinates.Mgb(self.sad, self.beam_limiting_device_angle)))
        p = transform3d([0,0,0], M)
        inclination = np.arccos(p[2]/np.linalg.norm(p)) * 180 / np.pi
        azimuth = np.arctan2(p[1], p[0]) * 180 / np.pi
        mlab.view(azimuth = azimuth[0], elevation = inclination[0], focalpoint = [0,0,0],
                  distance = self.sad, roll = -self.beam_limiting_device_angle)
github enthought / mayavi / mayavi / _downloads / mri.py View on Github external
cut_plane2.implicit_plane.widget.enabled = False

# Extract two views of the outside surface. We need to define VOIs in
# order to leave out a cut in the head.
voi2 = mlab.pipeline.extract_grid(src)
voi2.set(y_min=112)
outer = mlab.pipeline.iso_surface(voi2, contours=[1776, ],
                                        color=(0.8, 0.7, 0.6))

voi3 = mlab.pipeline.extract_grid(src)
voi3.set(y_max=112, z_max=53)
outer3 = mlab.pipeline.iso_surface(voi3, contours=[1776, ],
                                         color=(0.8, 0.7, 0.6))


mlab.view(-125, 54, 326, (145.5, 138, 66.5))
mlab.roll(-175)

mlab.show()

import shutil
shutil.rmtree('mri_data')
github boutproject / BOUT-dev / tools / pylib / boututils / plotpolslice.py View on Github external
# IF KEYWORD_SET(profile) THEN var2d[x,ypos] = var2d[x,ypos] + profile[x,ny-1]
        r[x,ypos] = rxy[x,ny-1]
        z[x,ypos] = zxy[x,ny-1]
           
 
    if(fig==1):  
    
        f = mlab.figure(size=(600,600))
        # Tell visual to use this as the viewer.
        visual.set_viewer(f)


        s = mlab.mesh(r,z,var2d, colormap='PuOr')#, wrap_scale='true')#, representation='wireframe')
        s.enable_contours=True
        s.contour.filled_contours=True
        mlab.view(0,0)
        
    else:   
        # return according to opt 
        if rz==1 :
            return r,z,var2d
        else:
            return var2d
github AaltoImagingLanguage / conpy / scripts / figure_connectivity.py View on Github external
fig = mlab.figure(size=(300, 300))
brain = stc.plot(
    subject='fsaverage',
    hemi='both',
    background='white',
    foreground='black',
    time_label='',
    initial_time=0,
    smoothing_steps=5,
    figure=fig,
)
brain.scale_data_colormap(0, 1, stc.data.max(), True)
brain.add_annotation('aparc', borders=2)

# Save some views
mlab.view(0, 90, 450, [0, 0, 0])
mlab.savefig('../paper/figures/degree_rh.png', magnification=4)
mlab.view(180, 90, 450, [0, 0, 0])
mlab.savefig('../paper/figures/degree_lh.png', magnification=4)
mlab.view(180, 0, 450, [0, 10, 0])
mlab.savefig('../paper/figures/degree_top.png', magnification=4)
mlab.view(180, 180, 480, [0, 10, 0])
mlab.savefig('../paper/figures/degree_bottom.png', magnification=4)

# Plot the connectivity diagram
fig, _ = con_parc.plot(title='Parcel-wise Connectivity', facecolor='white',
                       textcolor='black', node_edgecolor='white',
                       colormap='plasma_r', vmin=0, show=False)
fig.savefig('../paper/figures/squircle.pdf', bbox_inches='tight')
github jeffmahler / GPIS / src / grasp_selection / check_grasps.py View on Github external
# show metrics
            logging.info('Displaying grasp %d (%d of %d)' %(grasp.grasp_id, i, len(grasps)))
            metrics = grasp_metrics[grasp.grasp_id]
            for metric_name, val in metrics.iteritems():
                logging.info('Metric %s = %f' %(metric_name, val))


            # plot
            mlab.clf()
            T_obj_world = mv.MayaviVisualizer.plot_stable_pose(obj.mesh, stable_pose, T_table_world, d=0.1, style='surface',
                                                               color=(0.4,0.4,0.4))
            mv.MayaviVisualizer.plot_gripper(grasp, T_obj_world, gripper=gripper, color=(0.65,0.65,0.65))

            for j in range(num_grasp_views):
                az = j * delta_view
                mlab.view(az)
                time.sleep(delay)
github AaltoImagingLanguage / conpy / scripts / figure_power.py View on Github external
figs = []
for i, freq in enumerate(freq_bands):
    fig5 = mlab.figure(size=(300, 300))
    mlab.clf()
    #brain3 = stc_contrast.copy().crop(i, i).plot(
    brain3 = stc_contrast.plot(
        subject='sub002',
        hemi='both',
        background='white',
        foreground='black',
        time_label='',
        colormap='mne',
        initial_time=i,
        figure=fig5,
    )
    mlab.view(-90, 110, 420, [0, 0, 0], figure=fig5)
    figs.append(fig5)

    mlab.savefig('../paper/figures/power_contrast_%s-%s-occ.png' % (freq[0], freq[1]), figure=fig5, magnification=4)