Search code examples
pythonplotcube

Plot a cube of 3D intensity data


I have k cubes of (n,n,n) intensity values and I would like to plot them.

I consider them as diffusion tensors in diffusion MRI and I would like to visualize them (maybe as ellipsoids) and then try to "align" in some way. At present I simply plot for each cube its n "slice" (n,n).

Is there any python module for this task?


Solution

  • You can use mayavi2 for this. Since I don't have a representation of your data, I gave a minimal working example with some random spheres over a grid below:

    import numpy
    import mayavi.mlab as mlab
    
    # Create some random data
    N = 20
    x, y, z = numpy.mgrid[-5:5:20j, -5:5:20j, -5:5:20j]
    val = numpy.random.random(z.shape)
    
    # Plot and show in mayavi2
    pts = mlab.points3d(x, y, z, val, scale_factor=.5,transparent=True)
    mlab.show()
    

    enter image description here