|
| 1 | +from visbrain.objects import BrainObj, ColorbarObj, SceneObj |
| 2 | +from nilearn import datasets, surface |
| 3 | + |
| 4 | +sc = SceneObj(bgcolor='black', size=(1000, 500)) |
| 5 | + |
| 6 | +# Colorbar default arguments |
| 7 | +CBAR_STATE = dict(cbtxtsz=20, txtsz=20., width=.1, cbtxtsh=3., |
| 8 | + rect=(-.3, -2., 1., 4.)) |
| 9 | +KW = dict(title_size=14., zoom=1.2) |
| 10 | + |
| 11 | +motor_images = datasets.fetch_neurovault_motor_task() |
| 12 | +stat_img = motor_images.images[0] |
| 13 | +# stat_img is a nifti file: "image_10426.nii.gz" |
| 14 | + |
| 15 | +print('AAAAA', stat_img) |
| 16 | + |
| 17 | +b_obj = BrainObj('white', |
| 18 | + translucent=False) |
| 19 | + |
| 20 | +mesh = [b_obj.vertices, b_obj.faces] |
| 21 | + |
| 22 | +# resample from nifti to mesh |
| 23 | +texture = surface.vol_to_surf(stat_img, mesh) |
| 24 | + |
| 25 | +# plot mesh across brain oject |
| 26 | +b_obj.add_activation(-1 * texture, |
| 27 | + cmap='Blues_r', |
| 28 | + clim=(1, 7.9), |
| 29 | + vmin=1, |
| 30 | + vmax=7.9, |
| 31 | + hide_under=1,) |
| 32 | + |
| 33 | +cb_proj = ColorbarObj(b_obj, |
| 34 | + cblabel='stats map (-)', |
| 35 | + cmap='Blues', |
| 36 | + vmin=-7.9, |
| 37 | + vmax=-1, |
| 38 | + clim=(-7.9, -1), |
| 39 | + #over='gainsboro', |
| 40 | + **CBAR_STATE) |
| 41 | + |
| 42 | +b_obj.add_activation(texture, |
| 43 | + cmap='Reds_r', |
| 44 | + vmin=1, |
| 45 | + vmax=7.9, |
| 46 | + clim=(1, 7.9), |
| 47 | + hide_under=1) |
| 48 | + |
| 49 | +cb_proj_2 = ColorbarObj(b_obj, |
| 50 | + cblabel='statsmap (+)', |
| 51 | + cmap='Reds_r', |
| 52 | + vmin = 1, |
| 53 | + vmax=7.9, |
| 54 | + #under='gainsboro', |
| 55 | + **CBAR_STATE) |
| 56 | + |
| 57 | +sc.add_to_subplot(b_obj, row=0, col=0, rotate='right') |
| 58 | + |
| 59 | +sc.add_to_subplot(cb_proj, |
| 60 | + row=0, col=1, |
| 61 | + width_max=200) |
| 62 | + |
| 63 | +sc.add_to_subplot(cb_proj_2, |
| 64 | + row=0, col=2, |
| 65 | + width_max=200) |
| 66 | + |
| 67 | +sc.preview() |
0 commit comments