How to use the fury.actor function in fury

To help you get started, we’ve selected a few fury 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 scilus / scilpy / scilpy / viz / sampling_scheme.py View on Github external
if use_sphere:
        sphere = get_sphere('symmetric724')
        shape = (1, 1, 1, sphere.vertices.shape[0])
        fid, fname = mkstemp(suffix='_odf_slicer.mmap')
        odfs = np.memmap(fname, dtype=np.float64, mode='w+', shape=shape)
        odfs[:] = 1
        odfs[..., 0] = 1
        affine = np.eye(4)

    for i, shell in enumerate(ms):
        if same_color:
            i = 0
        ren = window.Renderer()
        ren.SetBackground(1, 1, 1)
        if use_sphere:
            sphere_actor = actor.odf_slicer(odfs, affine, sphere=sphere,
                                            colormap='winter', scale=1.0,
                                            opacity=opacity)
            ren.add(sphere_actor)
        pts_actor = actor.point(shell, vtkcolors[i], point_radius=rad)
        ren.add(pts_actor)
        if plot_sym_vecs:
            pts_actor = actor.point(-shell, vtkcolors[i], point_radius=rad)
            ren.add(pts_actor)
        window.show(ren)

        if ofile:
            window.snapshot(ren, fname=ofile + '_shell_' + str(i) + '.png',
                            size=ores)
github scilus / scilpy / scilpy / viz / sampling_scheme.py View on Github external
"""

    if len(ms) > 10:
        vtkcolors = fury.colormap.distinguishable_colormap(nb_colors=len(ms))

    ren = window.Renderer()
    ren.SetBackground(1, 1, 1)
    if use_sphere:
        sphere = get_sphere('symmetric724')
        shape = (1, 1, 1, sphere.vertices.shape[0])
        fid, fname = mkstemp(suffix='_odf_slicer.mmap')
        odfs = np.memmap(fname, dtype=np.float64, mode='w+', shape=shape)
        odfs[:] = 1
        odfs[..., 0] = 1
        affine = np.eye(4)
        sphere_actor = actor.odf_slicer(odfs, affine, sphere=sphere,
                                        colormap='winter', scale=1.0,
                                        opacity=opacity)

        ren.add(sphere_actor)

    for i, shell in enumerate(ms):
        if same_color:
            i = 0
        pts_actor = actor.point(shell, vtkcolors[i], point_radius=rad)
        ren.add(pts_actor)
        if use_sym:
            pts_actor = actor.point(-shell, vtkcolors[i], point_radius=rad)
            ren.add(pts_actor)
    window.show(ren)
    if ofile:
        window.snapshot(ren, fname=ofile + '.png', size=ores)
github fury-gl / fury / docs / tutorials / 04_others / viz_spiky.py View on Github external
point_actor = actor.point(vertices, point_radius=0.01, colors=(0, 1, 0))

##############################################################################
# Normals are the vectors that are perpendicular to the surface at each
# vertex. We specify the normals at the vertices to tell the system
# whether triangles represent curved surfaces.

normals = utils.normals_from_v_f(vertices, triangles)

##############################################################################
# The normals are usually used to calculate how the light will bounce on
# the surface of an object. However, here we will use them to direct the
# spikes (represented with arrows).
# So, let's create an arrow actor at the center of each vertex.

arrow_actor = actor.arrow(centers=vertices,
                          directions=normals, colors=(1, 0, 0), heights=0.2,
                          resolution=10, vertices=None, faces=None)

##############################################################################
# To be able to visualize the surface of the primitive sphere, we use
# ``get_actor_from_primitive``.

primitive_colors = np.zeros(vertices.shape)
primitive_colors[:, 2] = 180
primitive_actor = utils.get_actor_from_primitive(
    vertices=vertices, triangles=triangles, colors=primitive_colors,
    normals=normals, backface_culling=True)

##############################################################################
# We add all actors (visual objects) defined above to the scene.
github fury-gl / fury / bin / dipy_viz_grid.py View on Github external
print(color)
        stream_actor = actor.line(cluster, [color]*len(cluster), linewidth=1)
        pretty_actor = auto_orient(stream_actor, ren.camera_direction(), data_up=(0, 0, 1), show_bounds=True)
        pretty_actor_aabb = auto_orient(stream_actor, ren.camera_direction(), bbox_type="AABB", show_bounds=True)

        actors.append(stream_actor)
        actors.append(pretty_actor_aabb)
        actors.append(pretty_actor)

        text = actor.text_3d(str(len(cluster)), font_size=32, justification="center", vertical_justification="top")
        texts.append(text)

        text = actor.text_3d("AABB", font_size=32, justification="center", vertical_justification="top")
        texts.append(text)

        text = actor.text_3d("OBB", font_size=32, justification="center", vertical_justification="top")
        texts.append(text)

    grid = actor.grid(actors, texts, cell_padding=(50, 100), cell_shape="rect")


    #ren.add(grid)

    ren.reset_camera_tight()
    show_m = window.ShowManager(ren, interactor_style=interactor.InteractorStyleBundlesGrid(actor))
    show_m.start()
github fury-gl / fury / docs / examples / viz_bundles.py View on Github external
# Show every point with a value from a volume with your colormap
# ==============================================================
#
# Here we will need to input the ``fa`` map in ``streamtube``

renderer.clear()

hue = (0.0, 0.0)  # red only
saturation = (0.0, 1.0)  # white to red

lut_cmap = actor.colormap_lookup_table(hue_range=hue,
                                       saturation_range=saturation)

stream_actor3 = actor.line(bundle_native, fa, linewidth=0.1,
                           lookup_colormap=lut_cmap)
bar2 = actor.scalar_bar(lut_cmap)

renderer.add(stream_actor3)
renderer.add(bar2)

# window.show(renderer, size=(600, 600), reset_camera=False)
window.record(renderer, out_path='bundle3.png', size=(600, 600))

###############################################################################
# Show every bundle with a specific color
# ========================================
#
# You can have a bundle with a specific color. In this example, we are chosing
# orange.

renderer.clear()
stream_actor4 = actor.line(bundle_native, (1., 0.5, 0), linewidth=0.1)