# can be applied to Cohen’s D (C as done here) or # statistical values (statscondCluster.F_obs or F_obs_plot) # of inter-individual brain connectivity # defining manually bad channel for viz test epo1.info['bads'] = ['F8', 'Fp2', 'Cz', 'O2'] epo2.info['bads'] = ['F7', 'O1'] # Visualization of inter-brain connectivity in 2D # defining head model and adding sensors fig, ax = plt.subplots(1, 1) ax.axis("off") vertices, faces = viz.get_3d_heads() camera = Camera("ortho", theta=90, phi=180, scale=1) mesh = Mesh(ax, camera.transform @ glm.yrotate(90), vertices, faces, facecolors='white', edgecolors='black', linewidths=.25) camera.connect(ax, mesh.update) plt.gca().set_aspect('equal', 'box') plt.axis('off') viz.plot_sensors_2d(epo1, epo2, lab=True) # bads are represented as squares # plotting links according to sign (red for positive values, # blue for negative) and value (line thickness increases # with the strength of connectivity) viz.plot_links_2d(epo1, epo2, C=C, threshold=2, steps=10) plt.tight_layout() plt.show() # Visualization of inter-brain connectivity in 3D # defining head model and adding sensors vertices, faces = viz.get_3d_heads()
mesh = Mesh(ax, camera, vertices, faces, facecolors=white, edgecolors=black, linewidths=.25) ax.text(.99, .99, "Orthographic (XZ)", transform=ax.transAxes, ha="right", va="top") ax = subplot(223) camera = ortho @ glm.yrotate(90) mesh = Mesh(ax, camera, vertices, faces, facecolors=white, edgecolors=black, linewidths=.25) ax.text(.99, .99, "Orthographic (XY)", transform=ax.transAxes, ha="right", va="top") ax = subplot(224)
import matplotlib.pyplot as plt import nibabel as nb fig = plt.figure(figsize=(6, 6)) ax = fig.add_axes([0, 0, 1, 1], xlim=[-1, +1], ylim=[-1, +1], aspect=1) ax.axis("off") vertices, faces = nb.freesurfer.io.read_geometry('data/lh.pial') vertices = glm.fit_unit_cube(vertices) facecolors = lighting(vertices[faces], direction=(-1, 0, 0.25), color=(1.0, 0.5, 0.5), specular=True) camera = glm.ortho(-1, +1, -1, +1, 1, 100) camera = camera @ glm.scale(1.9) @ glm.yrotate(90) @ glm.xrotate(270) start = time.time() Mesh(ax, camera, vertices, faces, facecolors=facecolors, linewidths=0, mode="front") elapsed = time.time() - start text = "{0} vertices, {1} faces rendered in {2:.2f} second(s) with matplotlib" text = text.format(len(vertices), len(faces), elapsed) ax.text(0, 0,