MICA-MNI / BrainSpace

BrainSpace is an open-access toolbox that allows for the identification and analysis of gradients from neuroimaging and connectomics datasets | available in both Python and Matlab |
http://brainspace.readthedocs.io
BSD 3-Clause "New" or "Revised" License
180 stars 72 forks source link

Parcellation Schaefer 1000 - Support request #102

Closed Yvonneser closed 1 year ago

Yvonneser commented 1 year ago

Hey Team,

The labels that I have (That are not Zero ) = 18741 The fsaverage5 data lh/rh.inflated are 18715(9354 +9361)

This is the code that I used using Brain space: image

Here is an example of the plot that I am trying to create and the output:

surf_labels_lh = nib.freesurfer.read_annot('parcellation/lh.Schaefer2018_1000Parcels_7Networks_order.annot')[0]
surf_labels_rh = nib.freesurfer.read_annot('parcellation/rh.Schaefer2018_1000Parcels_7Networks_order.annot')[0]
surf_labels_rh[surf_labels_rh != 0] += 500 # different labels for lh and rh
surf_labels = np.concatenate([surf_labels_lh, surf_labels_rh])

mask = surf_labels != 0 # discard medial wall
cort_lh = nib.freesurfer.read_label('parcellation/lh.cortex.label')
cort_rh = nib.freesurfer.read_label('parcellation/rh.cortex.label')
surf_lh_loc = nib.freesurfer.read_geometry('parcellation/lh.inflated')
surf_rh_loc = nib.freesurfer.read_geometry('parcellation/rh.inflated')
cort = np.concatenate((cort_lh, cort_rh + 10242))
"""
# Visualize group-level average components
# """

for v,se in enumerate(ses):
for k, s in enumerate(subjs):
n_comps = 5

n_views = 4 # number of brains to show per component
fig_width = 10

eigenVal = []
from nilearn.plotting import plot_surf_stat_map

fig = plt.figure(figsize=(fig_width, fig_width * n_comps * 0.25), dpi=400)
for component in range(n_comps):
ax1 = fig.add_subplot(n_comps, n_views, component * n_views + 1, projection='3d')
ax2 = fig.add_subplot(n_comps, n_views, component * n_views + 2, projection='3d')
ax3 = fig.add_subplot(n_comps, n_views, component * n_views + 3, projection='3d')
ax4 = fig.add_subplot(n_comps, n_views, component * n_views + 4, projection='3d')
res = np.zeros(10242)
res[cort_lh] = np.asarray(split_sets[v][k])[component][cort_lh]
plax1 = plot_surf_stat_map(surf_lh_loc, res, hemi='left', view='medial', axes=ax1, colorbar=False, cmap=mymap1)
plax2 = plot_surf_stat_map(surf_lh_loc, res, hemi='left', view='lateral', axes=ax2, colorbar=False, cmap=mymap1)
res = np.zeros(10242)
res[cort_rh] = np.asarray(split_sets[v][k])[component][cort_rh]

plax3 = plot_surf_stat_map(surf_rh_loc, res, hemi='right', view='lateral', axes=ax3, colorbar=False, cmap=mymap1)
plax4 = plot_surf_stat_map(surf_rh_loc, res, hemi='right', view='medial', axes=ax4, colorbar=False, cmap=mymap1)
plt.figtext(0.5, 0.96 - (1. / n_comps) * component, 'G %i' % int(int(component) + 1),
horizontalalignment='center', fontsize='large',fontweight='bold')

plt.tight_layout()
plt.subplots_adjust(hspace=0.1,wspace=0.05)
filename = f'PCA-{s}-{se}-procrustes.png'
plt.savefig(filename, dpi=400)
plt.show()
  | ReplyForward -- | --

This is the output: image

I am trying to understand why I am getting these "NAN" values in the plot, and how can I fix it , Is there something in the files I am using wring or the flow is not correct?

Thanks In advance , and Appreciate any help

Yvonne Serhan

  • Other information
Yvonneser commented 1 year ago

Fixed Thanks