Skip to content

Instantly share code, notes, and snippets.

@jhlegarreta
Created June 30, 2021 14:50
Show Gist options
  • Save jhlegarreta/8f901c4e6762c6402096bab009caf8ed to your computer and use it in GitHub Desktop.
Save jhlegarreta/8f901c4e6762c6402096bab009caf8ed to your computer and use it in GitHub Desktop.
fury streamline actor partially occluded by volume slice
import os
import nibabel as nib
from dipy.data import fetch_bundles_2_subjects, read_bundles_2_subjects
from fury import window, actor
fetch_bundles_2_subjects()
fname_t1 = os.path.join(
os.path.expanduser('~'), '.dipy', 'exp_bundles_and_maps',
'bundles_2_subjects', 'subj_1', 't1_warped.nii.gz')
dix = read_bundles_2_subjects(
subj_id='subj_1', bundles=['cg.left', 'cst.right'])
img = nib.load(fname_t1)
data = img.get_fdata()
affine = img.affine
scene = window.Scene()
mean, std = data[data > 0].mean(), data[data > 0].std()
value_range = (mean - 0.5 * std, mean + 1.5 * std)
slice_actor = actor.slicer(data, affine, value_range)
slice_of_interest = 116
slice_actor.display(slice_of_interest, None, None)
scene.add(slice_actor)
bundle = dix['cg.left']
stream_actor = actor.line(bundle)
scene.add(stream_actor)
scene.yaw(-90)
scene.roll(90)
window.show(scene, size=(900, 900))
scene.rm(slice_actor)
slice_actor = actor.slicer(data, affine, value_range, opacity=0.6)
slice_actor.display(slice_of_interest, None, None)
scene.add(slice_actor)
window.show(scene, size=(900, 900))
@jhlegarreta
Copy link
Author

Streamline parts hidden by volume slice:
cg_left_volume_slice

Opacity applied to volume slice:
cg_left_opacity_volume_slice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment