enthought/mayavi

Data containing NaN values

Opened this issue · 0 comments

How to display the nan values in the 3D data body as transparent or white colors when using 'volume_slice'?
In the below image, brown represents the area with nan value. How can I replace brown with transparent or white color?
Hope to receive an answer, thanks a lot!!!
image
my code is as follows:
import numpy as np
from mayavi import mlab
pre_cwt = np.load('predicted_Zp_better.npy')
fig = mlab.figure(figure='PI', bgcolor=(1, 1, 1), fgcolor=(0, 0, 0))
pre_cwt[pre_cwt == 0] = np.nan
scalars = pre_cwt # specifying the data array
mlab.volume_slice(scalars, slice_index=0, plane_orientation='x_axes', figure=fig, colormap='jet') # Time slice
mlab.volume_slice(scalars, slice_index=0, plane_orientation='y_axes', figure=fig, colormap='jet') # Inline slice
mlab.volume_slice(scalars, slice_index=0, plane_orientation='z_axes', figure=fig, colormap='jet') # Xline slice
mlab.axes(xlabel='Times(ms)', ylabel='Inline', zlabel='Xline', nb_labels=1) # Add axes labels
mlab.colorbar()
mlab.outline()
mlab.show()