plot_map(brain_map.get_data(), brain_map.get_affine(), cmap=cm.cold_hot, vmin=vmin, vmax=vmax, anat=None, figure=10, threshold=3) # More plots using 3D if True: # replace with False to skip this plot_map(brain_map.get_data(), brain_map.get_affine(), cmap=cm.cold_hot, vmin=vmin, vmax=vmax, anat=None, figure=11, threshold=3, do3d=True) from nipy.labs import viz3d try: viz3d.plot_map_3d(brain_map.get_data(), brain_map.get_affine(), cmap=cm.cold_hot, vmin=vmin, vmax=vmax, anat=None, threshold=4) except ImportError: print "Need mayavi for 3D visualization" plt.show()
from os import path import matplotlib.pyplot as plt from nibabel import load from nipy.labs.viz import plot_map, cm from nipy.labs import viz3d from mayavi import mlab # Local import from get_data_light import DATA_DIR, get_second_level_dataset ####################################### # Data and analysis parameters ####################################### input_image = path.join(DATA_DIR, 'spmT_0029.nii.gz') if not path.exists(input_image): get_second_level_dataset() brain_map = load(input_image) vmin, vmax = brain_map.get_data().min(), brain_map.get_data().max() viz3d.plot_map_3d(brain_map.get_data(), brain_map.get_affine(), cmap=cm.cold_hot, vmin=vmin, vmax=vmax, anat=None, threshold=4) mlab.savefig('viz_3d.png')
contrast_image = Nifti1Image(write_array, affine) save(contrast_image, contrast_path) vmax = max(-write_array.min(), write_array.max()) plot_map(write_array, affine, cmap=cm.cold_hot, vmin=-vmax, vmax=vmax, anat=None, figure=10, threshold=2.5) plt.savefig(op.join(write_dir, "%s_z_map.png" % contrast_id)) plt.clf() ######################################### # End ######################################### print "All the results were witten in %s" % write_dir # make a simple 2D plot plot_map(write_array, affine, cmap=cm.cold_hot, vmin=-vmax, vmax=vmax, anat=None, figure=10, threshold=3) # More plots using 3D if True: # replace with False to skip this plot_map(write_array, affine, cmap=cm.cold_hot, vmin=-vmax, vmax=vmax, anat=None, figure=11, threshold=3, do3d=True) from nipy.labs import viz3d try: viz3d.plot_map_3d(write_array, affine, cmap=cm.cold_hot, vmin=-vmax, vmax=vmax, anat=None, threshold=4) except ImportError: print "Need mayavi for 3D visualization" plt.show()
vmax=vmax, anat=None, figure=10, threshold=3) # More plots using 3D if True: # replace with False to skip this plot_map(write_array, affine, cmap=cm.cold_hot, vmin=-vmax, vmax=vmax, anat=None, figure=11, threshold=3, do3d=True) from nipy.labs import viz3d try: viz3d.plot_map_3d(write_array, affine, cmap=cm.cold_hot, vmin=-vmax, vmax=vmax, anat=None, threshold=4) except ImportError: print "Need mayavi for 3D visualization" plt.show()