Plot mesh and fluence data

12 views
Skip to first unread message

Xiuxiu Zhang

unread,
Nov 13, 2025, 4:28:51 PMNov 13
to iso2mesh-users

Dear Dr. Qianqian Fang and iso2mesh users, 

Thanks for your responses to my mmclab questions. I am now trying to plot the outcomes of mmclab onto a mesh, and am encountering some plotmesh function issues that hope to get your inputs. 

I set up a widefield source right on top of the mesh (attachment #1 and 2), and set up a pencil beam going down into the mesh. I want to plot the x-z plane of the mesh and visualize the fluence there. So I followed the code in demo_mmclab_basic.m and run 

plotmesh([cfg.node(:, 1:3), log10(abs(fluence.data(1:size(cfg.node, 1))))], cfg.elem, 'y=200', 'facecolor', 'interp', 'linestyle', 'none');

Instead of the fluence data we see from demo code(that can be successfully run on my end), I get this error:

Error using
Incorrect number or types of inputs or outputs for function find.
Error in  (line 185)
        idx = eval(['find(' selector ')']);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I was wondering if there is anything I could check or change that potentially causes this error. 

Secondly, when I run 

plotmesh([cfg.node(:, 1:3), log10(abs(fluence.data(1:size(cfg.node, 1))))], cfg.elem, 'y>200 & y<202', 'facecolor', 'interp', 'linestyle', 'none');

as a workaround, it gives a figure like the third attachment. 

I was wondering if you could think of any reasons that around the brain soft tissue looks empty(my guess was coarse elements/ nodes) and what you would propose to fix it.

Let me know if you need additional details or code.

Best regards,

Xiuxiu


Screenshot 2025-11-13 at 3.47.44 PM.pngScreenshot 2025-11-13 at 4.23.23 PM.pngresult_1e6.png

Qianqian Fang

unread,
Nov 13, 2025, 4:46:57 PMNov 13
to iso2mes...@googlegroups.com, Xiuxiu Zhang

hi Xiuxiu, 

the `y>200 & y<202'` condition tests for the centroids of all tetrahedra. because of the small range, it is likely most of those empty areas have centroids outside of this range. Also, if your fluence.data contains NaN, it will be rendered as holes.


make sure you have the latest version of iso2mesh (prefer github version). if you still have trouble getting y=200 to run, can you save your cfg and fluence.data to a .mat file, and pace it on a shared drive/url?

--
You received this message because you are subscribed to the Google Groups "iso2mesh-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iso2mesh-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/iso2mesh-users/b8514828-e3c0-46a5-83e3-0c3a86e72883n%40googlegroups.com.

Xiuxiu Zhang

unread,
Nov 13, 2025, 9:43:46 PMNov 13
to iso2mesh-users
I redownloaded iso2mesh fromn github and am still running into this issue. I uploaded cfg+fluence.mat in this folder.


Thanks,
Xiuxiu

Qianqian Fang

unread,
Nov 13, 2025, 10:20:32 PMNov 13
to iso2mes...@googlegroups.com, Xiuxiu Zhang

hi Xiuxiu,

you can create the expected plot by using the below command

plotmesh([cfg.node(:, 1:3), log10(abs(fluence.data(1:size(cfg.node, 1))))], [], cfg.elem, 'y=200', 'facecolor', 'interp', 'linestyle', 'none');

notice that I inserted the 2nd input as []. if you type "help plotmesh", you can see the input list of plotmesh is plotmesh(node, face, elem, opt)

the '{x/y/z}=value' selector only works on tetrahedral meshes. when a user specify the 2nd input of plotmesh(node, elem) as a 4-column array, plotmesh uses an internal heuristic to determine whether elem is a tetrahedral mesh with 4-node per element, or it is a triangular mesh with the 4th column being the label. This heuristic may not always work, and can make the incorrect judgement. 

In this case, it falsely decided that the input, cfg.elem, is a triangular mesh with a label, which does not support y=200 selector.

by moving cfg.elem to the 3rd, and setting the face input as [], plotmesh will unmistakably treat cfg.elem as tetrahedral mesh, and thus, y=200 works.

Qianqian

On 11/13/25 16:27, Xiuxiu Zhang wrote:
--
Reply all
Reply to author
Forward
0 new messages