qmeshcut

137 views
Skip to first unread message

Cristiano

unread,
Feb 28, 2012, 6:28:00 AM2/28/12
to iso2mesh-users
Dear iso2mesh users,
I am running the routine qmeshcut to generate a plane section of a
tetrahedral brain mesh. When I visualize the result in Matlab I can
see the projection of the edges of the mesh on the plane, and they
look reasonable to me (generated in tetgen).
But if I assign a color value to each of the the plane-projected
elements (in this case triangles), the values appear scattered,
whereas I was expecting to see structure (i.e. gray/white matter
typical sulcal patterns).
Why is that?
I use the following instructions:

plane = [0 0 0;0 22 70;0 44 70]; % axial slice, z-axis oriented along
the inferior-superior brain axis
[aa,bb,cc] = qmeshcut(mesh.cell,mesh.node,value,plane);
hold on,
patch('Vertices',aa,'Faces',cc,'FaceVertexCData',bb,'FaceColor','flat');

Note that the same mesh can be correctly visualized using SCIrun.

Regards,
Cristiano


Qianqian Fang

unread,
Feb 28, 2012, 9:23:58 AM2/28/12
to iso2mes...@googlegroups.com, Cristiano
On 02/28/2012 06:28 AM, Cristiano wrote:
> Dear iso2mesh users,
> I am running the routine qmeshcut to generate a plane section of a
> tetrahedral brain mesh. When I visualize the result in Matlab I can
> see the projection of the edges of the mesh on the plane, and they
> look reasonable to me (generated in tetgen).
> But if I assign a color value to each of the the plane-projected
> elements (in this case triangles), the values appear scattered,
> whereas I was expecting to see structure (i.e. gray/white matter
> typical sulcal patterns).
> Why is that?

hi Cristiano

what are the dimensions of your input arrays?

Qianqian

> I use the following instructions:
>
> plane = [0 0 0;0 22 70;0 44 70]; % axial slice, z-axis oriented along
> the inferior-superior brain axis
> [aa,bb,cc] = qmeshcut(mesh.cell,mesh.node,value,plane);
> hold on,
> patch('Vertices',aa,'Faces',cc,'FaceVertexCData',bb,'FaceColor','flat');
>
> Note that the same mesh can be correctly visualized using SCIrun.
>
> Regards,
> Cristiano
>
>

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

Qianqian Fang

unread,
Feb 28, 2012, 10:50:52 AM2/28/12
to Cristiano Micheli, iso2mes...@googlegroups.com
On 02/28/2012 09:37 AM, Cristiano Micheli wrote:
> Dear Qianqian Fang,
> the dimensions of all input arguments to the qmeshcut function are:
>
> [aa,bb,cc] = qmeshcut(mesh.cell,mesh.node,value,plane);
>
> mesh.cell=[3431765x4]
> mesh.node=[606551x3]
> value = [3431765X1]

hi Cristiano

qmeshcut only accepts nodal-based values,
i.e. the values are attached to nodes, not
elements. I just committed a change and
extended qmeshcut for element-oriented
value list. The update can be found at:

http://iso2mesh.svn.sf.net/viewvc/iso2mesh?view=revision&revision=357

When plotting, you should use


patch('Vertices',cutpos,'Faces',facedata,'CData',cutvalue,'FaceColor','flat');

please let me know if this new feature works
for you.

Qianqian

> plane = [3X3]
>
> Please let me know if you need further details.
> Thank you,
> Cristiano

Micheli, C.

unread,
Feb 28, 2012, 11:27:06 AM2/28/12
to iso2mes...@googlegroups.com
Dear Qianqian Fang,
the new functionality of qmeshcut gives the result in attachment. It seems that the elements' values are now correctly located, but the coloring of the triangles on the plane looks a bit sketchy.
Thanks so far.

Cristiano

----- "Qianqian Fang" <fa...@nmr.mgh.harvard.edu> schreef:

> --
> You received this message because you are subscribed to the Google
> Groups "iso2mesh-users" group.
> To post to this group, send email to iso2mes...@googlegroups.com.
> To unsubscribe from this group, send email to
> iso2mesh-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/iso2mesh-users?hl=en.

4Fang.jpg

Qianqian Fang

unread,
Feb 28, 2012, 11:52:29 AM2/28/12
to iso2mes...@googlegroups.com, Micheli, C.
On 02/28/2012 11:27 AM, Micheli, C. wrote:
> Dear Qianqian Fang,
> the new functionality of qmeshcut gives the result in attachment. It seems that the elements' values are now correctly located, but the coloring of the triangles on the plane looks a bit sketchy.

that doesn't look right. There are lots of hollow
elements, which I assume they are NaNs. You need
to find out where they come from.

You can also disable the lines by appending
'linestyle','none' in the patch command.

Do a "help qmeshcut", and double check each
of your input. It is supposed to be easy to use.

Qianqian

The information in this e-mail is intended only for the person to whom it is

Micheli, C.

unread,
Feb 28, 2012, 12:47:55 PM2/28/12
to iso2mes...@googlegroups.com
Dear Qianqian Fang,
thank you for the swift reply,
I attach a version of the qmeshcut output, where the faces have no color, in order to view the edges' pattern on the plane.

Matlab command:
patch('Vertices',cutpos,'Faces',facedata)

Maybe the edges are projected in a different way with the new implementation, and this results in a weird representation of the triangles (I see a lot of 'black holes').
Actually none of the output variables contains NaNs, therefore it is difficult for me to understand what is going on, and I agree that it does not look correct.

Cristiano

4Fang2.jpg

Qianqian Fang

unread,
Feb 28, 2012, 7:15:18 PM2/28/12
to Micheli, C., iso2mes...@googlegroups.com
On 02/28/2012 01:12 PM, Micheli, C. wrote:
> Dear Fang,
> Here you find the script I use to plot data (in attachment, 4Fang_script.m) and the values that have to be assigned to each element of the tetrahedral mesh (CI1.mat).
> Given the limited space of mailboxes I attach the remaining files as 'sendspace' links. You can download the files by clicking on them.

hi Cristiano

I tried your script, qmeshcut works as expected.

3 minor suggestions:

1. newer qmeshcut function accepts logical expressions
for the "plane" input. In your case, you can do

[aa,bb,cc] = qmeshcut(mesh.cell,mesh.node,value,'x=0');

2. see the output x-axis is in the range of +-10^-16. These
are virtual 0 and are results of numerical errors of double
precision numbers. When you plot them, you will see rough
surfaces due to the magnified x-axis range. You can either
use set(gca,'xlim',[-1 1]) to flatten the roughness, or use
aa(find(aa<eps))=0, or aa(:,1)=0 to zerorize these tiny
elements.

3. when plotting, I used

patch('Vertices',aa,'Faces',cc,'CData',bb,'FaceColor','flat','linestyle','none');
view([1 0 0]);

notice the last property, this removes the distracting edges.
let me know if you can replicate.


Qianqian

> ...
>
> Please, let me know if you have all the necessary information.
> Cristiano
>
>
>
> ----- "Qianqian Fang"<fan...@gmail.com> schreef:


>
>> Van: "Qianqian Fang"<fan...@gmail.com>
>> Aan: "C. Micheli"<c.mi...@fcdonders.ru.nl>
>> Verzonden: Dinsdag 28 februari 2012 18:51:46
>> Onderwerp: Re: [iso2mesh-users] qmeshcut
>>

>> On 02/28/2012 12:47 PM, Micheli, C. wrote:
>>> Dear Qianqian Fang,

>>> thank you for the swift reply,
>>> I attach a version of the qmeshcut output, where the faces have no
>> color, in order to view the edges' pattern on the plane.
>>> Matlab command:
>>> patch('Vertices',cutpos,'Faces',facedata)
>>>
>>> Maybe the edges are projected in a different way with the new
>> implementation, and this results in a weird representation of the
>> triangles (I see a lot of 'black holes').
>>> Actually none of the output variables contains NaNs, therefore it is
>> difficult for me to understand what is going on, and I agree that it
>> does not look correct.
>>

>> it will be helpful if you can send me your data and
>> sample script, otherwise, it difficult to debug the problem
>> just by looking at an image.

qmeshcut_output.png

Micheli, C.

unread,
Feb 29, 2012, 4:05:07 AM2/29/12
to iso2mes...@googlegroups.com
Dear Qianqian,
I can replicate the result and I am very satisfied with it!
I also appreciate your quick replying and the efficient fixes.

All the best,

Reply all
Reply to author
Forward
0 new messages