# SPHARM-PDM Euler Number problem

**URL:** <https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745>\
**Category:** SlicerSALT\
**Created:** [May 1, 2018, 3:40pm UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745 "2018-05-01T15:40:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![doganarda](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@doganarda](https://discourse.slicer.org/u/doganarda)\
**Post date:** [May 1, 2018, 3:40pm UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745/1 "2018-05-01T15:40:49Z")

</div>

Hello everyone,

For my M.Sc. Thesis work, I need to apply SPHARM-PDM analysis to certain number of segmented hippocampi from an experiment but I am really new to the program and I still cannot make sense out of it clearly.

When I follow the tutorial, I open the Slicer 3D and I go to the Shape Analysis Model and I want to apply it to the segmented hippocampi mesh file .vtk (which is not empty, I can visualize it in MATLAB through trisurf command). It first converts it from mesh to label map (Step 0 folder is non-empty), then applies post process segmentation and I get the \_pp file but on second step I get the following error:

itk::ExceptionObject (0x7ffeb221f1a0)  
Location: “Unknown”  
File: /home/kitware/Dashboards/Stable/S-481-E-b/SPHARM-PDM/Libraries/Shape/Algorithms/BinaryMask3DEqualAreaParametricMeshSource.txx  
Line: 183  
Description: Warning: Euler equation not satisfied. Euler Number : 781156 - 781156 = 0

and I don’t know where to look for the problem - I looked through many forum posts and could not find a similar problem. Is it because I am using .vtk file instead of .nii.gz or something similar, a label map? Which I highly doubt because the tutorial says that .vtk files are valid inputs. Is it because there is something wrong in the segmentation or in the settings I have?

I would appreciate any help, thanks in advance.  
Arda

---

<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:** [May 2, 2018, 10:44pm UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745/2 "2018-05-02T22:44:40Z")

</div>

@bpaniagua @laurapascal

---

<div class="post-metadata">

**Author:** ![bpaniagua](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bpaniagua/32/20_2.png) [@bpaniagua](https://discourse.slicer.org/u/bpaniagua)\
**Post date:** [May 3, 2018, 2:33pm UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745/3 "2018-05-03T14:33:22Z")

</div>

Hi Arda,

Have you visualized the topology of your VTK / nii.gz object? If the Euler Number is not satisfied that means the spherical topology required by SPHARM is not met.

More information on the Euler Number is here [https://en.wikipedia.org/wiki/Euler\_characteristic#Surfaces](https://en.wikipedia.org/wiki/Euler_characteristic#Surfaces)

Thank you!  
Beatriz

---

<div class="post-metadata">

**Author:** ![doganarda](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@doganarda](https://discourse.slicer.org/u/doganarda)\
**Post date:** [May 4, 2018, 7:58am UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745/4 "2018-05-04T07:58:28Z")

</div>

Hi Beatriz,

I do not know exactly what you mean by visualizing the topology but when I visualized the .vtk file it was a normal right hippocampus of one subject which was segmented with another program that I used couple of weeks ago, named FSL. Interesting thing is that the program also gives the masks for segmenting out the subcortical structure in NIFTI format, which are label maps (1 for the structure 0 for background) and when I used these files I did not have any problem with applying SPHARM-PDM analysis - there was no Euler number error, I was able to extract SPHARM parameters and visualize the images in the tutorial. Thus, I was really confused. I am not exactly sure if it would be the same analysis doing it through the masks rather than segmented subcortical structure but I would feel more secure if I was able to carry out the analysis through the meshed segmented file .vtk. Do you have any idea what might be the cause of that? Because the structure is the same structure (probably same topology) just different representations, one mesh and one label map. At the end of the day it might not be any problem (especially since I was able to get different SPHARM parameters for different subjects as expected) but I would like to figure out why .vtk mesh file raises the problem of Euler number.

Thank you for your help,  
Arda

---

<div class="post-metadata">

**Author:** ![bpaniagua](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bpaniagua/32/20_2.png) [@bpaniagua](https://discourse.slicer.org/u/bpaniagua)\
**Post date:** [May 4, 2018, 1:04pm UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745/5 "2018-05-04T13:04:04Z")

</div>

Hi Arda,

I apologize for this error!

I would double check the SegPostprocess output. It is possible that the scan conversion from VTK to binary label map is causing topology errors. This is a new feature in SPHARM-PDM and I would recommend looking at the label created after the conversion in the Step1\_SegPostprocess folder to see if the VTK topology holds after scan conversion.

Thanks!  
Bea

---

<div class="post-metadata">

**Author:** ![Hamed\_RABIEI](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@Hamed\_RABIEI](https://discourse.slicer.org/u/Hamed_RABIEI)\
**Post date:** [June 19, 2018, 12:46pm UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745/6 "2018-06-19T12:46:27Z")

</div>

Hi,

I encountered the same problem for some triangulated mouse brain surfaces (Euler number = 0). I put here a heuristic solution that I found: I applied the “Close Holes” and “TwoStep Smooth” filters of MeshLab on problematic meshes and then the SPHARM worked properly. The intuition behind this idea is to close holes and refine the problematic regions by smoothing.

Hamed

P.S. I used PyMesh package to check whether a mesh is closed through the method mesh.is\_closed(). ([https://github.com/qnzhou/PyMesh](https://github.com/qnzhou/PyMesh))

---

<div class="post-metadata">

**Author:** ![bpaniagua](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bpaniagua/32/20_2.png) [@bpaniagua](https://discourse.slicer.org/u/bpaniagua)\
**Post date:** [June 21, 2018, 1:50pm UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745/7 "2018-06-21T13:50:23Z")

</div>

Hi Hamed,

This is great information, thank you so much!  
Best,

Beatriz

---

<div class="post-metadata">

**Author:** ![debin\_zeng](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/debin_zeng/32/7963_2.png) [@debin\_zeng](https://discourse.slicer.org/u/debin_zeng)\
**Post date:** [September 2, 2020, 9:08am UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745/8 "2020-09-02T09:08:08Z")

</div>

Hi Hamed,

I also encountered the same problem for some binary segmented hippocampal image (voxel), how can i use this tool(MeshLab) to close holes in the voxel-image? Is there any other method to deal with this issue? Thank you very much!

Zeng

---

<div class="post-metadata">

**Author:** ![Hamed\_RABIEI](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@Hamed\_RABIEI](https://discourse.slicer.org/u/Hamed_RABIEI)\
**Post date:** [September 4, 2020, 3:41pm UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745/9 "2020-09-04T15:41:18Z")

</div>

Hi Zeng,

You can find the close hole tool in MeshLab ([https://www.meshlab.net/](https://www.meshlab.net/)) under the menu “Filters \> Remeshing, simplification and reconstruction \> Close holes”. I’ve never tried it for voxel-images but for triangulated mesh surfaces. I’m not aware of any other tool to fix this issue.

Best,  
Hamed

---

<div class="post-metadata">

**Author:** ![yuanzhen\_cui](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yuanzhen_cui/32/15624_2.png) [@yuanzhen\_cui](https://discourse.slicer.org/u/yuanzhen_cui)\
**Post date:** [June 12, 2022, 2:54pm UTC](https://discourse.slicer.org/t/spharm-pdm-euler-number-problem/2745/10 "2022-06-12T14:54:44Z")

</div>

Hi Beatriz

I also encountered the same problems when I try to execute “GenParaMesh”:

GenParaMesh standard output:  
itk::ExceptionObject (0x304bef2f0)  
Location: “Unknown”  
File: /Volumes/D/S/S-1-E-b/SPHARM-PDM/Libraries/Shape/Algorithms/BinaryMask3DEqualAreaParametricMeshSource.txx  
Line: 183  
Description: Warning: Euler equation not satisfied. Euler Number : 158040 - 158032 = 8

So how can I get the right Euler Number and how to correct the Euler Number.

Thanks!  
Cui
