Closed iPsych closed 4 years ago
Hi @iPsych ,
I think here you need to increment the faces_r
with the number of faces in the faces_l
because the number of vertices changed since it's concatenated over left and right hemispheres. Can you try something like this please :
(vert_l, faces_l) = read_gii(lh_surf_mesh)
(vert_r, faces_r) = read_gii(rh_surf_mesh)
faces_r += faces_l.shape[0]
faces = np.vstack([faces_l, faces_r])
Hi, @EtienneCmb, It seems, the error happens as below. I think some number mismatch between lh and rh cause it.
IndexError: index 258612 is out of bounds for axis 0 with size 258108
And with this ?
faces_r += faces_l.max() + 1
Perfect! it works : )
@EtienneCmb, After successful mesh loading, annotation with parcellize comment also show strange result. I guess it is somehow related faces # just changed above? when annotation file loaded single hemisphere, just yellow brain or yellow brain with one region shows in purple.
b_obj.parcellize(lh_annot, hemisphere='left')
b_obj.parcellize(rh_annot, hemisphere='right')
Hi @iPsych ,
Indeed, it might comes from the faces concatenation. A possible workaround could be to specify the indices that belongs to the left and to the right hemispheres (checkout the doc of the input lr_index
) :
vert = np.vstack([vert_l, vert_r])
# left = True / right = False
lr_index = np.array([True] * vert_l.shape[0] + [False] * vert_r.shape[0])
# define your BrainObj
b2 = BrainObj('Custom', vertices=vert, faces=faces, lr_index=lr_index)
# try again the parcellize
[...]
I already put the code as below, and seems to do the same function.
r _index = np.ones((vert_l.shape[0],), dtype=bool)
r_index = np.zeros((vert_r.shape[0],), dtype=bool)
lr_index = np.r_[l_index, r_index]
Tested both
b_obj.parcellize(lh_annot)
b_obj.parcellize(rh_annot)
and
b_obj.parcellize(lh_annot, hemisphere='left')
b_obj.parcellize(rh_annot, hemisphere='right')
but the only difference was the warning.
WARNING | left hemisphere(s) inferred from filename WARNING | right hemisphere(s) inferred from filename
It seems the code load annotation properly, but cannot map it properly. If I re-call the parcelize code as below, both hemisphere shows the proper segmented regions, but with changed color.
b_obj.parcellize(lh_annot, hemisphere='left')
b_obj.parcellize(rh_annot, hemisphere='right')
b_obj.parcellize(rh_annot, hemisphere='right')
Ok, indeed, there's probably an issue for selecting the correct left and right indices used for the parcellization.
The original purpose of your issue changed, could you please close this issue and reopen a new one, specifically for the parcelization issue?
Issue closed and new issue opened.
For same data, below code directly loading *.pial of freesurfer works fine.
However, when try to load gii file as faces and vertexes, then merge like below
The result is broken 3D shape as attached. Is there any specific step required before make brain Obj?