# FEM Mesh Analysis & Visualization in Model Module

**URL:** <https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376>\
**Category:** Support\
**Tags:** visualization, 3d-model, fem, meshing\
**Created:** [December 4, 2019, 6:16am UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376 "2019-12-04T06:16:53Z")\
**Posts on this page:** 18\
**Page:** 2

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 10, 2019, 5:25am UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/21 "2019-12-10T05:25:59Z")

</div>

You can do that by using Segment Editor module (before FEM mesh generation). You can grow a shell on the skin using “Hollow” effect, then cut out rectangular shapes using “Scissors” effect.  
==\> good but, in the aspect of user, like fiducial tools(below picture),  
based on user fiducial 3d point on the surface mesh, it is good to draw for the attaching cube (below picture by the hand) which follows surface normal vector

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/9/c90ccea4fe2a3592e4a61b5bf2abd1e96f07733f.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/c/ec19015c9ed6b6e26b39bd4cd3eb969b761bd852.png)

You can hide the background mesh in Models module / Display / Scalars section, enable Threshold and set lower value to 1.  
**==\>I think it is homogenous mesh than tetzen. i am now tunning cleaver parameter^^**

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/0/00c3a1591663eb9a7e4289927af7fda6122e0253.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 10, 2019, 9:36pm UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/22 "2019-12-10T21:36:10Z")

</div>

What is your end goal? Why do you need to define those rectangles?

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 11, 2019, 12:15am UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/23 "2019-12-11T00:15:02Z")

</div>

like below, attaching pads(cube structure) on the surface of the brain, and generating mesh for brain electric fields analysis

related paper :  
COMETS2: An advanced MATLAB toolbox for the numerical analysis of  
electric fields generated by transcranial direct current stimulation

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/c/1cba729ef71bdd4d1939b40d1d5c9420da137d44.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/2/d21e26b1df5ccb403f9ecfde103efaab85fb5c3e.jpeg)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 11, 2019, 1:51am UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/24 "2019-12-11T01:51:03Z")

</div>

For this, the approach that I described (create a shell using “Hollow” effect and cut out rectangular parts using “Scissors” effect) should work very well. You can automate everything by writing Python scripts (see examples [here](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Segmentations)). For example, the user defines pad position using a markup fiducial and from your script you generate a box-shaped segment around that point and intersect that with the shell segment to generate the pad segment.

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 11, 2019, 3:49pm UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/25 "2019-12-11T15:49:29Z")

</div>

For this, the approach that I described (create a shell using “Hollow” effect and cut out rectangular parts using “Scissors” effect) **should work very well.** You can automate everything by writing Python scripts (see examples [here](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Segmentations)). For example, the user defines pad position using a markup fiducial and from your script you generate a box-shaped segment around that point and intersect that with the shell segment to generate the pad segment

==\> should work very well. ==\> GOOD. very interesting expression^^ ==\> I will do it and let the result shared in this page ==\> in korea, there’s  
Ultrafine dust issue from the China, my body condition is not good today. i am also image processing engineer. i think you lassoan are very enthusiast in 3d slicer image analysis& visualization. thank you for your concern sincerly in my heart .^^

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 12, 2019, 12:40pm UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/26 "2019-12-12T12:40:46Z")

</div>

Normally you assign scalar values to points or cells of your mesh when generate the mesh (e.g., you can have a scalar attribute to specify material or a physical quantity).  
**==\> How am i set Custom Scalar Table(the Scalars-\>Color Table) or assign the scalar array when generating mesh(cleaver parameter?)**

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/a/3a34c94ee75a7784d217c00fb24b059777bef64a.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 12, 2019, 2:29pm UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/27 "2019-12-12T14:29:07Z")

</div>

You can create/edit colormaps in Colors module. Built-in colormaps are read-only, so you need to make a copy if you want to customize one. A color table is created automatically from current segment names and colors if you export segmentation node to labelmap, so you may use that for coloring, too.

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 12, 2019, 3:35pm UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/29 "2019-12-12T15:35:06Z")

</div>

is it possible custmized assigning color to the segmentation or cell by the color map. in other words, custmized color function(or linear fomular like y=3x+5) can be built in Color table?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 12, 2019, 4:19pm UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/30 "2019-12-12T16:19:21Z")

</div>

Yes, you can create/modify color nodes using Python or C++ in any way you want. See [API specification](https://apidocs.slicer.org/v4.8/classvtkMRMLColorTableNode.html).

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 13, 2019, 12:50am UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/31 "2019-12-13T00:50:55Z")

</div>

I will do it and let the result share in this pages.

My final goal is to add FEM Analysis after mesh generation.final equation will be more complex and burden to CPU, Intel Math Kernel Library(MKL Solver DSS) may be used for global matrix equation.

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 16, 2019, 9:52am UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/32 "2019-12-16T09:52:27Z")

</div>

Could u indicate contents name about this hollow effect to rectagle on the surface of segment pointed by fiducials? I can’t find similar script^^

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/5/45b7ba9c8137d2ebd15dbf95c3082e9c78b93cec.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 16, 2019, 10:09pm UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/33 "2019-12-16T22:09:43Z")

</div>

See examples here: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How\_to\_run\_segment\_editor\_effects\_from\_a\_script](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How_to_run_segment_editor_effects_from_a_script)

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 17, 2019, 5:20am UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/34 "2019-12-17T05:20:59Z")

</div>

It is hard to me to hollow and scissor exactly

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/a/da80a8aaf8054bebd4b7ef7c7692c9af8fd3f875.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/e/9e9339c3345f3b25c037bad36cf6100ceaf3621f.png)

1. Markup - Fiducial Mark on Skin face
2. SegmentEditor - Hollow Effect and Scissors

For this, the approach that I described (create a shell using “Hollow” effect and cut out rectangular parts using “Scissors” effect) should work very well. You can automate everything by writing Python scripts (see examples [here](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Segmentations)). For example, the user defines pad position using a markup fiducial and from your script you generate a box-shaped segment around that point and intersect that with the shell segment to generate the pad segment.

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 17, 2019, 5:23am UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/35 "2019-12-17T05:23:55Z")

</div>

Hi, Andras, all of the source in the segmentation section is python script, but not related this issue.

Could you help me to write script

Workflow

1. Markup - Fiducial Marks on Skin face
2. SegmentEditor - Hollow Effect and Scissors to generate pad segm.

For this, the approach that I described (create a shell using “Hollow” effect and cut out rectangular parts using “Scissors” effect) should work very well. You can automate everything by writing Python scripts (see examples [here](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Segmentations)). For example, the user defines pad position using a markup fiducial and from your script you generate a box-shaped segment around that point and intersect that with the shell segment to generate the pad segment.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/e/4e947b184a03e1efed00a4e0bc5e2c4fb46e8638.png)

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 17, 2019, 5:29am UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/36 "2019-12-17T05:29:52Z")

</div>

> [@lausiv](#):
>
> i

i am now cutting rectangle by scissor effect drawn by left to right mouse clicked^^

ok. i will duplicate original segment and apply scissor effect and generate mesh

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/2/b2cd76b78871a60e76a8ca3f0da242fefa761d1e.png)

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 17, 2019, 1:19pm UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/37 "2019-12-17T13:19:47Z")

</div>

i succedd in attatching pad on the skin  
but when i generating mesh  
it was not applied.

segment\_1 : pad on the skin  
segment\_2 : surface of face generated by threshold 30 & smooth 6mm

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/7/470517eab4b9a6e99a0bcb05e03d0aed274dfb8e.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/d/0df413b98fd85a7bdd7a5527972f4198ea8901f2.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/2/b22044c3267e6ca777f7a381fd8251699b3d173d.jpeg)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 17, 2019, 1:46pm UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/38 "2019-12-17T13:46:36Z")

</div>

You need to increase the mesh resolution. With default parameters, a quick coarse mesh is generated.

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [December 18, 2019, 1:50am UTC](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376/39 "2019-12-18T01:50:35Z")

</div>

Thank you 🙂 i will refer cleaver parameter.

And i will make this python script adding fiducial mark basement^^ refering below segmentation script link

1. fiducial mark -\> 2. hollow and sccisors -\> 3.generate mesh

[[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How\_to\_run\_segment\_editor\_effects\_from\_a\_script](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How_to_run_segment_editor_effects_from_a_script) ]

[Previous page](https://discourse.slicer.org/t/fem-mesh-analysis-visualization-in-model-module/9376.md?page=1)
