Esempio n. 1
0
"""
vb = Brain(source_obj=s_obj, connect_obj=c_obj)
vb.brain_control(alpha=0.1, hemisphere='both')

rotation = 'axial_0'
vb.rotate('axial_0')  # top
#vb.rotate('axial_1') #bottom
#vb.rotate('sagittal_0') # left
#vb.rotate('sagittal_1') # right
#vb.rotate('coronal_0') # front
#vb.rotate('coronal_1') # back

# Save the brain
vb.screenshot('main2.png',
              canvas='main',
              print_size=(10, 20),
              dpi=300,
              autocrop=True)

# What is left to do here is to take different shot of the brain to create a figure of the overal connectivity
# through time

#vb.show()
'''
    Bottom line: We can't set the width of our edges to be bigger or smaller
    We can modify the colormap thought.

    we can use a combination of vmin,under, vmax,over and cmap to highlight
    different connection stength

    to rotate the view in the image we need to do:
Esempio n. 2
0
n_connections = 150
rnd_selection = np.random.randint(0, N**2, n_connections)
connect = np.random.randint(0, 20, (N, N))
mask = np.ones(N**2, dtype=bool)
mask[rnd_selection] = False
mask = mask.reshape(N, N)
connect = np.ma.masked_array(connect, mask=mask)
kwargs['c_connect'] = connect

kwargs['ui_bgcolor'] = 'white'

vb = Brain(**kwargs)

# ============= Sources =============
# # Screenshot of the default view :
vb.screenshot('default.png', autocrop=True)

# Hide sources that are not in the brain :
vb.sources_display('inside')
vb.screenshot('inside.png', autocrop=True)

# ============= Connectivity =============
# Colorby network density :
vb.sources_display('none')
vb.connect_control(show=True,
                   cmap='magma',
                   colorby='density',
                   clim=(0., 35.),
                   vmin=10.,
                   vmax=30.,
                   under='gray',
Esempio n. 3
0
             idx_4_6[1]: 'green'}
roi_obj.select_roi(idx_4_6, unique_color=True, roi_to_color=roi_color,
                   smooth=7)

"""Create a brain object
"""
b_obj = BrainObj('B1', hemisphere='both', translucent=True)

"""Pass the brain, source and ROI object to the GUI
"""
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
Esempio n. 4
0
rnd_selection = np.random.randint(0, N ** 2, n_connections)
connect = np.random.randint(0, 20, (N, N))
mask = np.ones(N ** 2, dtype=bool)
mask[rnd_selection] = False
mask = mask.reshape(N, N)
connect = np.ma.masked_array(connect, mask=mask)
kwargs['c_connect'] = connect

kwargs['ui_bgcolor'] = 'white'

vb = Brain(**kwargs)


# ============= Sources =============
# # Screenshot of the default view :
vb.screenshot('default.png', autocrop=True)

# Hide sources that are not in the brain :
vb.sources_display('inside')
vb.screenshot('inside.png', autocrop=True)

# ============= Connectivity =============
# Colorby network density :
vb.sources_display('none')
vb.connect_control(show=True, cmap='magma', colorby='density', clim=(0., 35.),
                   vmin=10., vmax=30., under='gray', over='darkred',
                   dynamic=(.7, 1.))
vb.screenshot('density.png', autocrop=True)
# Color by number of connections per node :
vb.connect_control(show=True, cmap='viridis', colorby='count', clim=(1., 5.),
                   vmin=0., vmax=10., dynamic=(.1, 1.))
Esempio n. 5
0
    idx_4_6[1]: 'green'
}
roi_obj.select_roi(idx_4_6,
                   unique_color=True,
                   roi_to_color=roi_color,
                   smooth=7)
"""Create a brain object
"""
b_obj = BrainObj('B1', hemisphere='both', translucent=True)
"""Pass the brain, source and ROI object to the GUI
"""
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