Created
June 30, 2021 14:50
-
-
Save jhlegarreta/8f901c4e6762c6402096bab009caf8ed to your computer and use it in GitHub Desktop.
fury streamline actor partially occluded by volume slice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Streamline parts hidden by volume slice:
Opacity applied to volume slice: