How to use the fury.window.Renderer 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 / scripts / scil_visualize_seeds.py View on Github external
tractogram = load_tractogram(args.tractogram, 'same')
    # Streamlines are saved in RASMM but seeds are saved in VOX
    # This might produce weird behavior with non-iso
    tractogram.to_vox()

    streamlines = tractogram.streamlines
    if 'seeds' not in tractogram.data_per_streamline:
        parser.error('Tractogram does not contain seeds')
    seeds = tractogram.data_per_streamline['seeds']

    # Make display objects
    streamlines_actor = actor.line(streamlines)
    points = actor.dots(seeds, color=(1., 1., 1.))

    # Add display objects to canvas
    r = window.Renderer()
    r.add(streamlines_actor)
    r.add(points)

    # Show and record if needed
    if args.save is not None:
        window.record(r, out_path=args.save, size=(1000, 1000))
    window.show(r)
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))

    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 fury-gl / fury / bin / dipy_viz_grid.py View on Github external
def main():
    fetch_bundles_2_subjects()
    dix = read_bundles_2_subjects(subj_id='subj_1', metrics=['fa'],
                                bundles=['cg.left', 'cst.right'])

    streamlines = []
    streamlines += [dix['cg.left']]
    streamlines += [dix['cst.right']]

    bg = (0, 0, 0)
    colormap = distinguishable_colormap(bg=bg)

    ren = window.Renderer()
    ren.background(bg)
    ren.projection("parallel")

    actors = []
    texts = []
    for cluster, color in zip(streamlines, colormap):
        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")
github nipy / dipy / 1.0.0 / _downloads / 9e2cbc5c5fa85aa87daeeb09eb9cb092 / bundle_extraction.py View on Github external
recognized_af_l, af_l_labels = rb.recognize(model_bundle=model_af_l,
                                            model_clust_thr=5.,
                                            reduction_thr=10,
                                            reduction_distance='mam',
                                            slr=True,
                                            slr_metric='asymmetric',
                                            pruning_distance='mam')

"""
let's visualize extracted Arcuate Fasciculus Left bundle and model bundle
together
"""

interactive = False

ren = window.Renderer()
ren.SetBackground(1, 1, 1)
ren.add(actor.line(model_af_l, colors=(.1, .7, .26)))
ren.add(actor.line(recognized_af_l, colors=(.1, .1, 6)))
ren.set_camera(focal_point=(320.21296692, 21.28884506,  17.2174015),
               position=(2.11, 200.46, 250.44), view_up=(0.1, -1.028, 0.18))
window.record(ren, out_path='AF_L_recognized_bundle.png',
              size=(600, 600))
if interactive:
    window.show(ren)

"""
.. figure:: AF_L_recognized_bundle.png
   :align: center

   Extracted Arcuate Fasciculus Left bundle and model bundle
github scilus / scilpy / scilpy / viz / screenshot.py View on Github external
if peaks_actor:
            peaks_actor.display(slices[0], None, None)
        view_up_vector = (0, 0, 1)
    elif axis_name == 'coronal':
        volume_actor.display(None, slices[1], None)
        if peaks_actor:
            peaks_actor.display(None, slices[1], None)
        view_up_vector = (0, 0, 1)
    else:
        volume_actor.display(None, None, slices[2])
        if peaks_actor:
            peaks_actor.display(None, None, slices[2])
        view_up_vector = (0, 1, 0)

    # Generate the scene, set the camera and take the snapshot
    ren = window.Renderer()
    ren.add(volume_actor)
    if streamlines_actor:
        ren.add(streamlines_actor)
    elif peaks_actor:
        ren.add(peaks_actor)
    ren.set_camera(position=view_position,
                   view_up=view_up_vector,
                   focal_point=focal_point)

    window.snapshot(ren, size=(1920, 1080), offscreen=True,
                    fname=output_filename)
github scilus / scilpy / scripts / scil_visualize_bundles_mosaic.py View on Github external
j = height * view_number

            draw_bundle_information(draw, bundle_file_name, number_streamlines,
                                    i + text_pos_x, j + text_pos_y, font)

        else:
            # Select the streamlines to plot
            bundle_tractogram_file = nib.streamlines.load(bundle_file)
            streamlines = bundle_tractogram_file.streamlines

            tubes = actor.line(streamlines)

            number_streamlines = len(streamlines)

            # Render
            ren = window.Renderer()
            zoom = args.zoom
            opacity = args.opacity_background

            # Structural data
            slice_actor = actor.slicer(data, affine, value_range)
            slice_actor.opacity(opacity)
            ren.add(slice_actor)

            # Streamlines
            ren.add(tubes)
            ren.reset_camera()
            ren.zoom(zoom)
            view_number = 0
            set_img_in_cell(mosaic, ren, view_number,
                            output_paths[view_number], width, height, i)
github nipy / dipy / 1.0.0 / _downloads / 9e2cbc5c5fa85aa87daeeb09eb9cb092 / bundle_extraction.py View on Github external
"""
We save the transform generated in this registration, so that we can use
it in the bundle profiles example
"""

np.save("slr_transform.npy", transform)


"""
let's visualize atlas tractogram and target tractogram after registration
"""

interactive = False

ren = window.Renderer()
ren.SetBackground(1, 1, 1)
ren.add(actor.line(atlas, colors=(1, 0, 1)))
ren.add(actor.line(moved, colors=(1, 1, 0)))
window.record(ren, out_path='tractograms_after_registration.png',
              size=(600, 600))
if interactive:
    window.show(ren)

"""
.. figure:: tractograms_after_registration.png
   :align: center

   Atlas and target after registration.

"""