""" If you don't have access to a Nifti file, download one of the volume available at https://brainder.org/download/flair/. """ path_to_nifti1 = os.getenv("HOME") # Path to the Nifti file file_nifti1 = 'GG-853-GM-0.7mm.nii.gz' # Name of the Nifti file path1 = os.path.join(path_to_nifti1, file_nifti1) """ Load the Nifti file. The read_nifti function load the data and the transformation to convert data into the MNI space : """ data1, header1, tf1 = read_nifti(path1) # print(header1) # Add the volume to the GUI : vb.add_volume('Volume1', data1, transform=tf1) print('Add Volume1 to the list of volumes : ', vb.volume_list()) # You can add multiple volumes : path_to_nifti2 = os.getenv("HOME") file_nifti2 = 'GG-853-WM-0.7mm.nii.gz' path2 = os.path.join(path_to_nifti2, file_nifti2) data2, header2, tf2 = read_nifti(path2) vb.add_volume('Volume2', data2, transform=tf2) print('Add Volume2 to the list of volumes : ', vb.volume_list()) # Set the cross-section to be centered on the last source : vb.cross_sections_control(pos=s_xyz[3, :], volume='Volume2', cmap='gist_stern', split_view=True)
""" import os from visbrain import Brain from visbrain.io import read_nifti """Import the volume and the associated affine transformation """ volume_name = 'GG-853-WM-0.7mm' path_to_nifti = os.getenv("HOME") file_nifti = 'GG-853-WM-0.7mm.nii.gz' path = os.path.join(path_to_nifti, file_nifti) data, header, tf = read_nifti(path) vb = Brain() # Add the volume to the GUI vb.add_volume(volume_name, data, transform=tf) """Set the cross-section to be centered on the slice (70, 171, 80) with the gist_stern colormap. """ vb.cross_sections_control(center=(70, 171, 80), volume=volume_name, cmap='gist_stern') """Display the 3D volume using the translucent rendering method. """ vb.volume_control(volume_name, cmap='TransFire', rendering='translucent') """Finally, rotate the scene and hide the main brain. """ vb.rotate(custom=(142, 12)) vb.brain_control(visible=False) vb.show()