You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use dipy, I found that the radial_scale parameter of actor.odf_slicer has some issues.
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. And the member of dipy said This is a FURY issue.
Way to reproduce
Code example:
# %%importnumpyasnpfromdipy.sims.voxelimportmulti_tensor, multi_tensor_odffromdipy.dataimportget_spherefromdipy.core.sphereimportdisperse_charges, Sphere, HemiSpherefromdipy.core.gradientsimportgradient_tablefromfuryimportwindow, actorfromIPython.core.displayimportImagefromPILimportImageasPILImageimportos# %%# helper functions for visualization WINDOW_SIZE= (400,400)
SAVEIM_FOLDER="images"ifnotos.path.exists(SAVEIM_FOLDER):
os.mkdir(SAVEIM_FOLDER)
defscreenshot_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)
ifrot:
scene.add(sf_actor)
sf_actor.Rotatex(90)
n_frames=360//theta_stepimages=[]
foriinnp.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_stepfilename=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()
returnfilenamedefscreenshot_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()
returnoutfile# %% [markdown]# ### Part 1 - Apparent diffusion coefficient and spherical harmonics Generating a gradient table# %%n_pts=64bvalue=1000theta=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.verticesvalues=np.ones(vertices.shape[0])
bvecs=np.vstack((vertices))
bvals=np.hstack((bvalue*values))
#add some b=0 bvals/bvecsbvecs=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=100SNR=100N=2# change this value to try other number of fibersifN==1:
mevals=np.array([[0.0015, 0.0004, 0.0004]])
angles= [(0, 0)]
fractions= [100]
elifN==2:
separation_angle=90# play with this parameter to change the angle between fibersmevals=np.array([[0.0015, 0.0004, 0.0004],
[0.0015, 0.0004, 0.0004]])
angles= [(0, 0), (separation_angle, 0)]
fractions= [50, 50]
elifN==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:
raiseValueError('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 signalsignal_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,)
error png
python version
python 3.9.10
dipy version
1.9.0
fury version
0.11.0
The text was updated successfully, but these errors were encountered:
Description
When I use dipy, I found that the
radial_scale
parameter ofactor.odf_slicer
has some issues.In the attached code, the last line uses
actor.odf_slicer
. Whenradial_scale
is set toTrue
, it doesn't raise an error, but when set toFalse
, it does result in an error. And the member of dipy said This is a FURY issue.Way to reproduce
Code example:
error png
python version
python 3.9.10
dipy version
1.9.0
fury version
0.11.0
The text was updated successfully, but these errors were encountered: