zp1008611 opened a new issue, #1941: URL: https://github.com/apache/fury/issues/1941
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/fury/issues) and found no similar issues. ### Version dipy 1.9.0 fury 0.11.0 ### Component(s) Python ### Minimal reproduce step import numpy as np from dipy.sims.voxel import multi_tensor, multi_tensor_odf from dipy.data import get_sphere from dipy.core.sphere import disperse_charges, Sphere, HemiSphere from dipy.core.gradients import gradient_table from fury import window, actor from IPython.core.display import Image from PIL import Image as PILImage import os # %% # helper functions for visualization WINDOW_SIZE = (400,400) SAVEIM_FOLDER = "images" if not os.path.exists(SAVEIM_FOLDER): os.mkdir(SAVEIM_FOLDER) def screenshot_animated_sf(sf, sphere, rot=True, norm=True, scale=True, title='Modeling', theta_step=30): """ Render a spherical function to file. Returns path to image. """ scene = window.Scene() scene.background(window.colors.white) sf_actor = actor.odf_slicer(sf[None, None, None,:], sphere=sphere, colormap='jet', norm=norm, radial_scale=scale) if rot: scene.add(sf_actor) sf_actor.Rotatex(90) n_frames = 360//theta_step images=[] for i in np.arange(n_frames): sf_actor.Rotatex(theta_step) scene.reset_clipping_range() images.append(PILImage.fromarray(window.snapshot(scene, size=WINDOW_SIZE))) frame_duration = 15000 // theta_step filename = os.path.join(SAVEIM_FOLDER, '{0}.gif'.format(title)) images[0].save(filename, save_all=True, append_images=images[1:], duration=frame_duration, optimize=False, loop=0) scene.clear() return filename def screenshot_gradients(sph_gtab, title='Modeling'): scene = window.Scene() scene.background(window.colors.white) scene.add(actor.point(sph_gtab.vertices, window.colors.green, point_radius=0.05)) outfile = os.path.join(SAVEIM_FOLDER, '{0}.png'.format(title)) window.snapshot(scene, size=WINDOW_SIZE, fname=outfile) scene.clear() return outfile # %% [markdown] # ### Part 1 - Apparent diffusion coefficient and spherical harmonics Generating a gradient table # %% n_pts = 64 bvalue = 1000 theta = np.pi * np.random.rand(n_pts) phi = 2 * np.pi * np.random.rand(n_pts) hsph_initial = HemiSphere(theta=theta, phi=phi) hsph_updated, potential = disperse_charges(hsph_initial, 5000) vertices = hsph_updated.vertices values = np.ones(vertices.shape[0]) bvecs = np.vstack((vertices)) bvals = np.hstack((bvalue * values)) #add some b=0 bvals/bvecs bvecs = np.insert(bvecs, (0, bvecs.shape[0]), np.array([0, 0, 0]), axis=0) bvals = np.insert(bvals, (0, bvals.shape[0]), 0) gtab = gradient_table(bvals, bvecs) sph_gtab = Sphere(xyz=np.vstack((vertices, -vertices))) print('bvecs:\n', bvecs) print('bvals:\n', bvals) # %% image = screenshot_gradients(sph_gtab, title='Example directions') Image(filename=image) # %% [markdown] # #### Playing with different single and multi-tensor signal generation # # %% S0 = 100 SNR = 100 N = 2 # change this value to try other number of fibers if N == 1: mevals = np.array([[0.0015, 0.0004, 0.0004]]) angles = [(0, 0)] fractions = [100] elif N == 2: separation_angle = 90 # play with this parameter to change the angle between fibers mevals = np.array([[0.0015, 0.0004, 0.0004], [0.0015, 0.0004, 0.0004]]) angles = [(0, 0), (separation_angle, 0)] fractions = [50, 50] elif N == 3: mevals = np.array([[0.0015, 0.0004, 0.0004], [0.0004, 0.0015, 0.0004], [0.0004, 0.0004, 0.0015]]) angles = [(0, 0), (90, 0), (0, 90)] fractions = [33, 33, 34] else: raise ValueError('Invalid number of fibers.') signal, sticks = multi_tensor(gtab, mevals, S0 = S0, angles = angles, fractions = fractions, snr = SNR) print(signal) # %% # we generate an antipodally symmetric spherical function from our signal signal_sph = np.zeros(vertices.shape[0]*2) signal_sph[0:vertices.shape[0]] = signal[1:-1] signal_sph[vertices.shape[0]:] = signal[1:-1] actor.odf_slicer(signal_sph[None, None, None,:], sphere=sph_gtab, colormap='jet', norm=False, radial_scale=False,) ### What did you expect to see? In the attached code, the last line uses actor.odf_slicer. When radial_scale set to False, it does not result in an error. ### What did you see instead? In the attached code, the last line uses actor.odf_slicer. When radial_scale is set to True, it doesn't raise an error, but when set to False, it does result in an error. ### Anything Else? _No response_ ### Are you willing to submit a PR? - [ ] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
