Created
July 26, 2021 20:54
-
-
Save jhlegarreta/1cd2d674e130f3643058761d4dda83d8 to your computer and use it in GitHub Desktop.
fury camera tighten not working as expected
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) | |
# Try to tighten around the contents | |
margin_factor = 0.4 | |
scene.reset_camera_tight(margin_factor=margin_factor) | |
size = (900, 900) | |
window.show(scene, size=size) | |
filename = "scene_snapshot_tighten1.png" | |
window.snapshot(scene, fname=filename, size=size) | |
# Try to tighten around the contents with a different factor | |
margin_factor = 1.2 | |
scene.reset_camera_tight(margin_factor=margin_factor) | |
size = (900, 900) | |
window.show(scene, size=size) | |
filename = "scene_snapshot_tighten2.png" | |
window.snapshot(scene, fname=filename, size=size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
File
scene_snapshot_tighten1.png
:File
scene_snapshot_tighten2.png
: