Hi Francois,
Ken was having some weird coloring issue of ROI in BrainStorm. It seems that there are gray gaps between the rois (scouts in BrainStorm terminology). Please see the screenshot below:
I went through the BrainStorm code and it seems that each scout is made into a separate patch. Then each of these patches is colored and plotted separately.
So triangles with vertices with different labels do not get assigned to any patch and so are not plotted or colored, and stay gray.
This issue is due to the following code in BrainStorm (panel_scout.m, line 4262 onwards)
Original
% This syntax is faster but equivalent to:
% patchFaces = Faces(all(vertMask(Faces),2),:);
iFacesTmp = find(vertMask(Faces(:,1)));
iFacesTmp = iFacesTmp(vertMask(Faces(iFacesTmp,2)));
iFacesTmp = iFacesTmp(vertMask(Faces(iFacesTmp,3)));
patchFaces = Faces(iFacesTmp,:);
To try to fix it, I propose to make the following change:
patchFaces = Faces(sum(vertMask(Faces),2)>=2,:);
iScoutVert = unique(patchFaces(:));
patchVertices = GetScoutPosition(Vertices, VertexNormals, iScoutVert, 0.0002);
This way, a triangle is assigned a label if two or more of its vertices have that label. This mostly fixes the issue, except when each of the three vertices of triangle have different labels. In that case it is not assigned any label and stays gray. We could assign it a random label. Here is a screenshot.
With the new change, vertices on the boundary of scouts would be in both scouts.
Do you think this change would be acceptable in BrainStorm? I wanted to check with you before sending a pull request because this change seems like it might break some assumptions needed for some codes.
Is there a reason why each scout is separated into a patch? Could we make scout into sets of vertices rather than separate patches? That change might be too fundamental.
What are your thoughts on this? How should we go about the coloring issue?
Thank you,
best,
Anand