Esempio n. 1
0
and 20 columns
"""
pic_data = 50. * np.random.rand(n_sources, 10, 20)
"""
Define the Brain instance and pass variables for sources, pictures and
connections
"""
vb = Brain(s_xyz=s_xyz,
           s_data=s_data,
           a_template='B3',
           c_connect=c_connect,
           pic_data=pic_data)
"""
Set the Brain opaque to visualize the cortical projection :
"""
vb.brain_control(transparent=False)
"""
The colormap of the projection can't be controlled without running it. So we
print the list of controllable objects before and after the cortical
projection. Note that the code below is the same for the cortical_repartition()
method.
"""
print("List of controllable objects before projection : ", vb.cbar_list())
vb.cortical_projection()
print("List of controllable objects after projection : ", vb.cbar_list())
"""
Control the colorbar / colormap of cortical projection
"""
vb.cbar_control('Projection',
                cmap='Spectral_r',
                clim=(10.2, 95.1),
Esempio n. 2
0
vb = Brain(brain_obj=b_obj, source_obj=s_obj, roi_obj=roi_obj)
"""Render the scene and save the jpg picture with a 300dpi
"""
save_as = os.path.join(save_pic_path, '0_main_brain.jpg')
vb.screenshot(save_as, dpi=300, print_size=(10, 10), autocrop=True)
"""Project source's activity onto the surface
"""
vb.cortical_projection(clim=(0, 50),
                       cmap='Spectral_r',
                       vmin=10.1,
                       under='black',
                       vmax=41.2,
                       over='green')
vb.sources_control('Sobj', visible=False)  # Hide sources
vb.rotate(custom=(-160., 10.))  # Rotate the brain
vb.brain_control(translucent=False)  # Make the brain opaque
"""Now, we take a screenthot of the scene but this time, we used the
autocrop argument to crop the image as close as possible to the brain.

Then, we used the print_size, dpi and unit inputs to get higher resolution
image.
Taken together, this mean that the image should have a sufficient size to be
(20 centimeters x 20 centimeters) at 300 dpi.
"""
save_as = os.path.join(save_pic_path, '1_proj_brain.tiff')
vb.screenshot(save_as,
              autocrop=True,
              print_size=(20, 20),
              unit='centimeter',
              dpi=300.)
"""Colorbar screenshot
Esempio n. 3
0
                   vmin=0.,
                   vmax=10.,
                   dynamic=(.1, 1.))
vb.screenshot('count.png', autocrop=True)

# ============= Projection =============
vb.connect_control(show=False)
vb.sources_display('all')
vb.cortical_repartition(cmap='viridis',
                        clim=(1., 6.),
                        vmin=2.,
                        under='gray',
                        vmax=4.,
                        over='#ab4642',
                        radius=16.)
vb.brain_control(transparent=False)
vb.sources_opacity(show=False)
vb.rotate(custom=(-125., 0.))
vb.screenshot('repartition.jpg', autocrop=True)

vb.sources_display('all')
vb.roi_control(selection=[4, 6], roi_type='Brodmann', smooth=5)
vb.cortical_projection(project_on='roi',
                       radius=12.,
                       cmap='inferno',
                       clim=(.1, .5),
                       vmin=0.,
                       vmax=6.)
vb.sources_display('none')
vb.brain_control(template='B3')
vb.brain_control(transparent=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()