Example #1
0
Illustration and main functionalities and inputs of the cross-section object.

.. image:: ../../picture/picobjects/ex_cs_obj.png
"""
from visbrain.objects import CrossSecObj, SceneObj
from visbrain.io import download_file

sc = SceneObj()

print("""
# =============================================================================
#                              Brodmann area
# =============================================================================
""")
cs_brod = CrossSecObj('brodmann',
                      interpolation='nearest',
                      section=(70, 80, 90))
cs_brod.localize_source((-10., -15., 20.))
sc.add_to_subplot(cs_brod, row=0, col=0, title='Brodmann area')

print("""
# =============================================================================
#                              Nii.gz file
# =============================================================================
""")
path = download_file('GG-853-GM-0.7mm.nii.gz')
cs_cust = CrossSecObj(path, section=(90, 80, 100), cmap='gist_stern')
sc.add_to_subplot(cs_cust, row=0, col=1, title='Nii.gz file')

sc.preview()
from visbrain.objects import VolumeObj, CrossSecObj, SourceObj
from visbrain.io import download_file

"""Download two NIFTI files
"""
path_1 = download_file('GG-853-GM-0.7mm.nii.gz', astype='example_data')
path_2 = download_file('GG-853-WM-0.7mm.nii.gz', astype='example_data')

"""Define four sources sources and a Source object
"""
s_xyz = np.array([[29.9, -37.3, -19.3],
                  [-5.33, 14.00, 20.00],
                  [25.99, 14.00, 34.66],
                  [0., -1.99, 10.66]])
s_obj = SourceObj('MySources', s_xyz)

"""Define a volume object and a cross-section object
"""
vol_obj = VolumeObj(path_1)
cross_sec_obj = CrossSecObj(path_2)

"""Localize a source in the cross-section object
"""
cross_sec_obj.localize_source(s_xyz[2, :])

"""Define a Brain instance and pass the source, volume and cross-section
object
"""
vb = Brain(source_obj=s_obj, vol_obj=vol_obj, cross_sec_obj=cross_sec_obj)
vb.show()
                       pic_height=21., cmap='viridis')
sc.add_to_subplot(pic_obj, row=1, col=2, title='3D pictures')
sc.add_to_subplot(BrainObj('B2'), use_this_cam=True, row=1, col=2)

###############################################################################
# Connectivity
###############################################################################

arch = np.load(download_file('phase_sync_delta.npz', astype='example_data'))
nodes, edges = arch['nodes'], arch['edges']
c_count = ConnectObj('default', nodes, edges, select=edges > .7,
                     color_by='count', antialias=True, line_width=2.,
                     dynamic=(.1, 1.))
s_obj_c = SourceObj('sources', nodes, color='#ab4642', radius_min=5.)
sc.add_to_subplot(c_count, row=2, col=0, row_span=2, title='3D connectivity')
sc.add_to_subplot(s_obj_c, row=2, col=0)
sc.add_to_subplot(BrainObj('B3'), use_this_cam=True, row=2, col=0)

###############################################################################
# Cross-sections
###############################################################################

cs_brod = CrossSecObj('brodmann', interpolation='nearest',
                      coords=(70, 80, 90), cmap='viridis')
cs_brod.localize_source((-10., -15., 20.))
sc.add_to_subplot(cs_brod, row=2, col=1, col_span=2, row_span=2,
                  title='Cross-sections')


sc.preview()
from visbrain.objects import VolumeObj, CrossSecObj, SourceObj
from visbrain.io import download_file

"""Download two NIFTI files
"""
path_1 = download_file('GG-853-GM-0.7mm.nii.gz')
path_2 = download_file('GG-853-WM-0.7mm.nii.gz')

"""Define four sources sources and a Source object
"""
s_xyz = np.array([[29.9, -37.3, -19.3],
                  [-5.33, 14.00, 20.00],
                  [25.99, 14.00, 34.66],
                  [0., -1.99, 10.66]])
s_obj = SourceObj('MySources', s_xyz)

"""Define a volume object and a cross-section object
"""
vol_obj = VolumeObj(path_1)
cross_sec_obj = CrossSecObj(path_2)

"""Localize a source in the cross-section object
"""
cross_sec_obj.localize_source(s_xyz[2, :])

"""Define a Brain instance and pass the source, volume and cross-section
object
"""
vb = Brain(source_obj=s_obj, vol_obj=vol_obj, cross_sec_obj=cross_sec_obj)
vb.show()