Skip to content

Commit

Permalink
Some minor final touches
Browse files Browse the repository at this point in the history
  • Loading branch information
Garyfallidis committed Nov 3, 2016
1 parent b817e3f commit 24f7e4e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
29 changes: 25 additions & 4 deletions dipy/viz/actor.py
Expand Up @@ -609,7 +609,32 @@ def display_extent(self, x1, x2, y1, y2, z1, z2):
def _odf_slicer_mapper(odfs, affine=None, mask=None, sphere=None, scale=2.2,
norm=True, radial_scale=True, opacity=1.,
colormap=None, global_cm=False):
""" Helper function for slicing spherical fields
Parameters
----------
odfs : ndarray
4D array of spherical functions
affine : array
4x4 transformation array from native coordinates to world coordinates
mask : ndarray
3D mask
sphere : Sphere
a sphere
scale : float
Distance between spheres.
norm : bool
Normalize `sphere_values`.
radial_scale : bool
Scale sphere points according to odf values.
opacity : float
Takes values from 0 (fully transparent) to 1 (non-transparent)
colormap : None or str
If None then no color is used.
global_cm : bool
If True the colormap will be applied in all ODFs. If False
it will be applied individually at each voxel (default False).
"""
if mask is None:
mask = np.ones(odfs.shape[:3])

Expand Down Expand Up @@ -662,16 +687,12 @@ def _odf_slicer_mapper(odfs, affine=None, mask=None, sphere=None, scale=2.2,
cells.SetCells(ncells, all_faces_vtk)

if colormap is not None:
# from dipy.viz.fvtk import create_colormap
if global_cm:
cols = create_colormap(all_ms.ravel(), colormap)
else:
from ipdb import set_trace
# set_trace()
cols = np.zeros((ijk.shape[0],) + sphere.vertices.shape,
dtype='f4')
for k in range(ijk.shape[0]):
# set_trace()
tmp = create_colormap(all_ms[k].ravel(), colormap)
cols[k] = tmp.copy()

Expand Down
5 changes: 0 additions & 5 deletions dipy/viz/tests/test_fvtk_actors.py
Expand Up @@ -283,17 +283,12 @@ def test_odf_slicer():

sphere = get_sphere('symmetric362')

# use memory maps
# odfs = np.ones((10, 10, 10, sphere.vertices.shape[0]))

shape = (11, 11, 11, sphere.vertices.shape[0])

with TemporaryDirectory() as tmpdir:
print(tmpdir)
fname = os.path.join(tmpdir, 'odf_slicer.mmap')
odfs = np.memmap(fname, dtype='float64', mode='w+',
shape=shape)

odfs[:] = 1
# odfs = np.random.rand(10, 10, 10, sphere.vertices.shape[0])

Expand Down

0 comments on commit 24f7e4e

Please sign in to comment.