Back to the main page.

Bug 1833 - update ft_plot_mesh for hexahedra and tetrahedra

Status ASSIGNED
Reported 2012-11-15 15:45:00 +0100
Modified 2014-07-04 15:27:57 +0200
Product: FieldTrip
Component: plotting
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to: Lilla Magyari
URL:
Tags:
Depends on:
Blocks:
See also:

Robert Oostenveld - 2012-11-15 15:45:16 +0100

I think tetrahedra already work, but hexahedra don't. We should have enough test data for this, see bug 1819, bug 1819 and bug 1820.


Robert Oostenveld - 2012-11-16 10:18:07 +0100

Lilla, can you work on this one?


Robert Oostenveld - 2012-11-20 12:05:54 +0100

I have just added a test script mac001> svn commit test_bug1833.m Adding test_bug1833.m Transmitting file data . Committed revision 6964. At this moment it still fails on my apple desktop because ft_read_mesh cannot (yet) read a vista *.v file, as the mex file is missing (see bug 1840). On linux it might work.


Robert Oostenveld - 2012-11-21 18:06:54 +0100

Just made a small extension, it does not look too weird if I do mesh.hex = mesh.hex(1,:) % discard all but the first element ft_plot_mesh(mesh) mac001> svn commit Sending plotting/ft_plot_mesh.m Transmitting file data . Committed revision 6971. @Johannes, could you look at the FIXME in line 148?


Johannes Vorwerk - 2012-11-22 10:26:18 +0100

(In reply to comment #3) Just checked it, should be fine like it is now.


Robert Oostenveld - 2012-11-22 13:15:45 +0100

I now realize that double faces still need to be removed. No reason to plot two faces/patches for the interface between two voxels. That should speed up plotting with about 2x.


Robert Oostenveld - 2012-11-23 06:45:07 +0100

Although not in MATLAB as ft_plot_mesh, http://www.paraview.org seems a useful tool as it has the right level of abstraction. Since I already had a matlab reader and writer for the vtk format, I just added them. mbp> svn commit Sending fileio/ft_read_headshape.m Sending fileio/ft_write_headshape.m Sending fileio/private/read_vtk.m Sending fileio/private/write_vtk.m Transmitting file data .... Committed revision 6974. The http://www.meshlab.org viewer is another one that I have used in the past (with stl files).


Robert Oostenveld - 2012-11-23 07:08:27 +0100

(In reply to comment #6) I have just also added the stanford ply format as output option in ft_write_headshape. It can be used with meshlab and also paraview. I have tested it with triangles and hexaheders, both work fine. mbp> svn commit Sending fileio/ft_write_headshape.m Adding fileio/private/write_ply.m Sending fileio/private/write_vtk.m Transmitting file data ... Committed revision 6975.


Lilla Magyari - 2013-01-22 18:24:59 +0100

(In reply to comment #7) hi Robert, I have tested your function (mesh2edge) to plot hexahedral meshes. It works but it is efficient only for a few hundreds of points. When more thousands elements have to be plotted, the mesh2edge function "gets stuck" around line 70 in the for loop, and it works for really long. Is there a way to reduce computational time for that for loop? I attached a test script which you can also use yourself. (I do not want to put it into the test directory until it is not "final" test script.) Lilla


Lilla Magyari - 2013-01-22 18:25:48 +0100

Created attachment 410 test script for mesh plotting


Lilla Magyari - 2013-01-22 21:26:26 +0100

(In reply to comment #8) I have realized meanwhile, that may I could try to use reduce_patch first.


Robert Oostenveld - 2013-01-23 09:43:12 +0100

(In reply to comment #8) with >> profile on >> ft_plot_mesh(mesh2,'edgeonly','yes'); >> profile report I indeed see that it spends almost all of the ~20 seconds on the for loop around line 65. It should be possible to make that smarter and faster. I'll work on that.


Robert Oostenveld - 2013-01-23 10:17:10 +0100

(In reply to comment #11) The following is a helper function that makes it much faster. It sorts the rows vertically and then finds the difference (i.e. subsequent rows that are different). The diff is done twice, otherwise the first or last of a sequence would also be found. function indx = findsingleoccurringrows(X) [X, indx] = sortrows(X); sel = any(diff([X(1,:)-1; X],1),2) & any(diff([X; X(end,:)+1],1),2); indx = indx(sel); It now happens in a jiffie (*). Even the large mesh in your test is plotted in 2 seconds or so (and looks nice, try "alpha 0.5" on the command line) . I hope it is now fast enough for real-world meshes. mac001> svn commit private/mesh2edge.m Sending private/mesh2edge.m Transmitting file data . Committed revision 7372. *) see http://en.wikipedia.org/wiki/Jiffy_(time)


Lilla Magyari - 2013-02-19 10:50:07 +0100

This is just a reminder for myself that once the simbio pipeline is ready, the 'edgeonly' option should be documented in ft_plot_mesh. Lilla


Robert Oostenveld - 2014-07-04 15:27:57 +0200

I added the attached test script to the existing test script code. mac011> svn commit test/ Sending test/test_ft_plot_mesh.m Transmitting file data . Committed revision 9701.