# Steps to calculate the Euler characteristics and Betti number

**URL:** <https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777>\
**Category:** ParaView Support\
**Created:** [March 31, 2023, 7:19pm UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777 "2023-03-31T19:19:11Z")\
**Posts on this page:** 17\
**Page:** 2

<div class="post-metadata">

**Author:** ![kokebdese](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kokebdese/32/11182_2.png) [@kokebdese](https://discourse.paraview.org/u/kokebdese)\
**Post date:** [April 21, 2023, 8:43pm UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/21 "2023-04-21T20:43:32Z")

</div>

@Charles_Gueunet

Hi  
I have been executing the Betti numbers from Paraview, unfortunately, I missed the Debug level of PD under the Property section and I tried my best to restore it again but I can’t. How can I bring the debug level indicator back? Thanks

 ![debug](https://discourse.paraview.org/uploads/default/original/2X/e/ed27058625b805751389125f235c065765930812.jpeg)

---

<div class="post-metadata">

**Author:** ![kokebdese](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kokebdese/32/11182_2.png) [@kokebdese](https://discourse.paraview.org/u/kokebdese)\
**Post date:** [April 22, 2023, 7:50pm UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/22 "2023-04-22T19:50:37Z")

</div>

Hi, I got it. It is cool reading the ‘ParaViewTutorial-5.10.1.pdf’ under help.  
But, I need if there is a way to save the persistence features from the data.

 ![toggle](https://discourse.paraview.org/uploads/default/original/2X/d/d6d5508c62b73fbcc235db77b0017c84aec2bcf1.png)

---

<div class="post-metadata">

**Author:** ![Charles\_Gueunet](https://discourse.paraview.org/user_avatar/discourse.paraview.org/charles_gueunet/32/40_2.png) [@Charles\_Gueunet](https://discourse.paraview.org/u/Charles_Gueunet)\
**Post date:** [April 24, 2023, 7:10am UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/23 "2023-04-24T07:10:57Z")

</div>

Hello @kokebdese  
The terminal is the only place this information is displayed as far as I know.

You already found the **Advanced properties toggle**.

You can save the persistance diagram as any other data sets in ParaView:

- File \> Save As…
- Press Ctrl-s

Then you can choose the format, **.vtp** for a vtk file format, **.csv** may be better if you want to compute some statistics outside of ParaView …

---

<div class="post-metadata">

**Author:** ![kokebdese](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kokebdese/32/11182_2.png) [@kokebdese](https://discourse.paraview.org/u/kokebdese)\
**Post date:** [April 24, 2023, 11:29am UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/24 "2023-04-24T11:29:07Z")

</div>

@Charles_Gueunet  
Hi  
I have been checking for the Betti numbers for just a simple torus ~open inside (not solid one).  
I expected the B2 (cavities: which I thought 2d holes) = 1. However, it displayed zero cavities. Is there something that I missed? Thank you.

 ![Torus](https://discourse.paraview.org/uploads/default/original/2X/5/5a34224a9eb270fb84a8efb5f376b191d6ed9410.png)  
 ![cavity](https://discourse.paraview.org/uploads/default/original/2X/2/2115bc217386f2a871482f4414e1f9a2a5f2b4a9.png)  
[torus2.stl](https://discourse.paraview.org/uploads/short-url/7vHKYsocUBbzT9P74oPufrGv9Wf.stl) (424.9 KB)

---

<div class="post-metadata">

**Author:** ![Charles\_Gueunet](https://discourse.paraview.org/user_avatar/discourse.paraview.org/charles_gueunet/32/40_2.png) [@Charles\_Gueunet](https://discourse.paraview.org/u/Charles_Gueunet)\
**Post date:** [April 24, 2023, 11:59am UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/25 "2023-04-24T11:59:33Z")

</div>

@kokebdese

Looking at the code, the number of cavities is only updated for 3 dimensional meshes in the TTK packages. It seems wrong indeed, I started a discussion [here](https://github.com/topology-tool-kit/ttk/commit/30b8ad73270715b9f5868b6c3259fde08664ea62#r110321595).

---

<div class="post-metadata">

**Author:** ![kokebdese](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kokebdese/32/11182_2.png) [@kokebdese](https://discourse.paraview.org/u/kokebdese)\
**Post date:** [May 2, 2023, 10:57am UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/26 "2023-05-02T10:57:57Z")

</div>

@Charles_Gueunet

Hi  
When to expect the latest version of ParaView? 🙂 Thanks!

---

<div class="post-metadata">

**Author:** ![kokebdese](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kokebdese/32/11182_2.png) [@kokebdese](https://discourse.paraview.org/u/kokebdese)\
**Post date:** [May 3, 2023, 3:02pm UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/27 "2023-05-03T15:02:08Z")

</div>

@Charles_Gueunet  
Hi  
I thought I could able to see all the betti numbers on the PD (Persistence diagram). However, if you look at this figure, the number of handles(1D holes) are 10, but I can only see 2 in PD. What could be the reason? I want to see all of them in the PD. Thank you for your help.

 ![pdhole](https://discourse.paraview.org/uploads/default/original/2X/8/87ab06ee94ac127af394dc71e8408b3147fc2781.png)

---

<div class="post-metadata">

**Author:** ![kokebdese](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kokebdese/32/11182_2.png) [@kokebdese](https://discourse.paraview.org/u/kokebdese)\
**Post date:** [May 3, 2023, 3:04pm UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/28 "2023-05-03T15:04:32Z")

</div>

@Charles_Gueunet  
In case you need here is the data. Thanks  
[rect2.stl](https://discourse.paraview.org/uploads/short-url/qVuZ1fiRjwhE1qYtgGE2HGXybgo.stl) (788.4 KB)

---

<div class="post-metadata">

**Author:** ![Charles\_Gueunet](https://discourse.paraview.org/user_avatar/discourse.paraview.org/charles_gueunet/32/40_2.png) [@Charles\_Gueunet](https://discourse.paraview.org/u/Charles_Gueunet)\
**Post date:** [May 25, 2023, 2:21pm UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/29 "2023-05-25T14:21:41Z")

</div>

Hello @kokebdese

Sorry for the late reply.  
Previously, we where looking at the Betti numbers, which are only related to the geometry. The persistence diagram however make sense for a **scalar field** defined on a domain. It will track how the connected component of the scalar fields evolve as we sweep the scalar values. The full explanation would be available [here](https://youtu.be/oYLjB4QTlAA?t=806).

Also, be careful, if visually this diagram seems to have 3 branches + the diagonal, it has 13 cells in the information tab on my side (it may be a bit different for you depending on the elevation you used). If you have watched the video, this is because the elevation may have induced very small features (noise).  
In my case, by removing the pair with a very small persistence using a threshold, I could get the good result:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/2/243bcc1be1c651660896724149306954d2ddde72.png)  
Ten pairs + the diagonal that correspond to the min-max feature.  
This is definitely not the way to count topological holes.  
You may want to try the persistence generator if you want to extract those holes, an example can be found [here](https://topology-tool-kit.github.io/examples/persistentGenerators_casting/).

---

<div class="post-metadata">

**Author:** ![kokebdese](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kokebdese/32/11182_2.png) [@kokebdese](https://discourse.paraview.org/u/kokebdese)\
**Post date:** [May 25, 2023, 5:36pm UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/30 "2023-05-25T17:36:40Z")

</div>

@Charles_Gueunet  
Thanks!

---

<div class="post-metadata">

**Author:** ![Daniel\_Brito](https://discourse.paraview.org/user_avatar/discourse.paraview.org/daniel_brito/32/11889_2.png) [@Daniel\_Brito](https://discourse.paraview.org/u/Daniel_Brito)\
**Post date:** [June 26, 2023, 10:44pm UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/31 "2023-06-26T22:44:52Z")

</div>

Hi, could you shed some light on how the debugging actually calculates these Betti numbers? Is it by chance using the algorithms shown in the paper mentioned in [TTK - the Topology ToolKit - Topological Data Analysis and Visualization](https://topology-tool-kit.github.io/bettiNumbers.html)?

---

<div class="post-metadata">

**Author:** ![Charles\_Gueunet](https://discourse.paraview.org/user_avatar/discourse.paraview.org/charles_gueunet/32/40_2.png) [@Charles\_Gueunet](https://discourse.paraview.org/u/Charles_Gueunet)\
**Post date:** [June 27, 2023, 11:22am UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/32 "2023-06-27T11:22:20Z")

</div>

It is using the same geometric properties to reduce the computation, like the Euler characteristics.  
The Betti number are extracted after a Discrete Morse Sandwich execution which is different from the Union Find (Merge Tree) approach described in the paper. So in short, same tricks, same results, but slightly different approach.

---

<div class="post-metadata">

**Author:** ![Daniel\_Brito](https://discourse.paraview.org/user_avatar/discourse.paraview.org/daniel_brito/32/11889_2.png) [@Daniel\_Brito](https://discourse.paraview.org/u/Daniel_Brito)\
**Post date:** [June 27, 2023, 5:08pm UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/33 "2023-06-27T17:08:02Z")

</div>

Do you happen to have a reference to the algorithm or a particular paper detailing the mathematics behind it?

---

<div class="post-metadata">

**Author:** ![Ivan\_B\_G](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ivan_b_g/32/13731_2.png) [@Ivan\_B\_G](https://discourse.paraview.org/u/Ivan_B_G)\
**Post date:** [September 1, 2024, 11:09am UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/34 "2024-09-01T11:09:41Z")

</div>

Hi @Charles_Gueunet,

This is probably quite late from when the original post was put up, but I have tried following your steps but I cant seem to view the results. How do I get access to the terminal output? I have extracted the mesh surface and triangulated it as well as set-up the Persistance diagram but I just don’t know how to access the logs in Paraview and there doesn’t seem to be a lot of info out there regarding this.

Best regards.

---

<div class="post-metadata">

**Author:** ![Charles\_Gueunet](https://discourse.paraview.org/user_avatar/discourse.paraview.org/charles_gueunet/32/40_2.png) [@Charles\_Gueunet](https://discourse.paraview.org/u/Charles_Gueunet)\
**Post date:** [September 2, 2024, 8:01am UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/35 "2024-09-02T08:01:15Z")

</div>

Hello @Ivan_B_G  
You need to start paraview from a terminal to see those logs (on linux / mac)  
If you are on windows, you can:

- use git bash, or
- redirect the log to a file with: `paraview -l=messages.log`

Hope that helps,  
Charles

---

<div class="post-metadata">

**Author:** ![Ivan\_B\_G](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ivan_b_g/32/13731_2.png) [@Ivan\_B\_G](https://discourse.paraview.org/u/Ivan_B_G)\
**Post date:** [September 5, 2024, 11:29pm UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/36 "2024-09-05T23:29:47Z")

</div>

Thank you for the response! I have launched paraview from terminal and got the following results for a mesh that deforms to obtain the surface mesh of a sphere (3D but I have attached a slice view).

![image](https://discourse.paraview.org/uploads/default/original/2X/f/f05a3ef00ec8a55d47770909f8c3142779e9b83e.png)

 ![LMD3D](https://discourse.paraview.org/uploads/default/original/2X/e/e9cb3d959c580af8ab899d8a7ddd5acea6372224.png)

What I am wondering is why the “Boundary components” is equal to 0. Would you happen to have any idea?

Best regards and thank you in advance,  
Ivan

---

<div class="post-metadata">

**Author:** ![Charles\_Gueunet](https://discourse.paraview.org/user_avatar/discourse.paraview.org/charles_gueunet/32/40_2.png) [@Charles\_Gueunet](https://discourse.paraview.org/u/Charles_Gueunet)\
**Post date:** [September 6, 2024, 7:26am UTC](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777/37 "2024-09-06T07:26:05Z")

</div>

Hello @Ivan_B_G ,  
Boundary components are related to the resistance diagram computation.  
If I remember well, this number describes the number of un-closed pairs, phenomenon which can occurs on periodic meshes for example (where the left boundary is virtually stitched to the right one, the top boundary corresponds to the bottom one… and so forth).

To make it short, this is not related to the Betti numbers per sei, and should not occurs in usual 3D meshes.

[Previous page](https://discourse.paraview.org/t/steps-to-calculate-the-euler-characteristics-and-betti-number/11777.md?page=1)
