# DentalSegmentator result mesh is inverted

**URL:** <https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408>\
**Category:** Support\
**Tags:** segmentation, ai, dental\
**Created:** [July 16, 2024, 8:19am UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408 "2024-07-16T08:19:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Romulo\_Alfaro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/romulo_alfaro/32/77327_2.png) [@Romulo\_Alfaro](https://discourse.slicer.org/u/Romulo_Alfaro)\
**Post date:** [July 16, 2024, 8:19am UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/1 "2024-07-16T08:19:21Z")

</div>

Hello, can someone help me please. I am using the DentalSegmentator Extension but the meshes come out inverted. I’ve been trying to change the settings for several hours but I haven’t been able to solve it. I thank you for your responses.

 ![Captura de pantalla 2024-07-16 a la(s) 2.32.33 a. m.](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/8/089d5356c5b88e8415fe5247ca30ccb1ea95b134.jpeg)

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [July 16, 2024, 2:34pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/3 "2024-07-16T14:34:21Z")

</div>

If that’s a surface (or mesh or, as Slicer calls them, modelNode) then you just need to execute a filter to flip the normals.  
In Slicer you can do it like this:

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

Hope it helps

---

<div class="post-metadata">

**Author:** ![Romulo\_Alfaro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/romulo_alfaro/32/77327_2.png) [@Romulo\_Alfaro](https://discourse.slicer.org/u/Romulo_Alfaro)\
**Post date:** [July 16, 2024, 5:04pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/4 "2024-07-16T17:04:52Z")

</div>

Thanks for your answer. I did what you told me but when exporting to STL it still gives me an inverted mesh. I still need help.

 ![Captura de pantalla 2024-07-16 a la(s) 12.03.18 p. m.](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/9/4911de7a33232e9fec54b2d7fc1cb44296e84f2d.jpeg)  
 ![Captura de pantalla 2024-07-16 a la(s) 12.04.11 p. m.](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/6/6613ab04ffb7cff097f2727329d94acc894d17d2.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:** [July 16, 2024, 6:30pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/5 "2024-07-16T18:30:58Z")

</div>

STL file cannot save surface normals, so you would need to reorient triangles if you want to turn the surface inside out. You could do that by applying [vtkReverseSense](https://vtk.org/doc/nightly/html/classvtkReverseSense.html) filter (by running a [couple of lines of Python code](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#apply-vtk-filter-on-a-model-node)).

But it is probably better to fix the root cause of having an inverted surface.

What file format was the input image stored in? If NIFTI then you have a chance of getting into issues with image orientation. Using the latest Slicer Preview Release contain some error mitigation mechanisms that can help with NIFTI files.

How have you created the STL file? Have you applied any transforms? Are all the segments inverted? If you smooth the inverted segment a bit does the surface orientation gets fixed?

Why is it a problem that the triangles are oriented? What processing do you want to do in what software?

---

<div class="post-metadata">

**Author:** ![Romulo\_Alfaro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/romulo_alfaro/32/77327_2.png) [@Romulo\_Alfaro](https://discourse.slicer.org/u/Romulo_Alfaro)\
**Post date:** [July 16, 2024, 6:39pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/6 "2024-07-16T18:39:43Z")

</div>

This is the second time I have used DentalSegmentator. The first time the meshes were oriented normally.  
This second time all the meshes are inverted.  
I haven’t done any transformations, this is how DentalSegmentation generated the segments.  
Or is this how DentalSegmentator usually generates segmentation?

No specific program, it’s just my curiosity to be able to correct this orientation.

Thank you for reading.

PD. I’m afraid that Python code is something very complex for me.

---

<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:** [July 16, 2024, 6:43pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/7 "2024-07-16T18:43:12Z")

</div>

Did you load the image from DICOM, NIFTI, NRRD, or other file format?

If you don’t have any specific task in mind then a simple option is to ignore the polygon ordering. Most software that can process meshes can also reorient the polygons automatically or when it is needed.

---

<div class="post-metadata">

**Author:** ![Romulo\_Alfaro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/romulo_alfaro/32/77327_2.png) [@Romulo\_Alfaro](https://discourse.slicer.org/u/Romulo_Alfaro)\
**Post date:** [July 16, 2024, 6:48pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/8 "2024-07-16T18:48:08Z")

</div>

They were loaded from DICOM (CBCT).

The first time I did it through CT and this second time through CBCT.

I will continue testing. I still hope to correct the orientation.

---

<div class="post-metadata">

**Author:** ![Thibault\_Pelletier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thibault_pelletier/32/4767_2.png) [@Thibault\_Pelletier](https://discourse.slicer.org/u/Thibault_Pelletier)\
**Post date:** [July 17, 2024, 3:01pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/9 "2024-07-17T15:01:56Z")

</div>

Hi @Romulo_Alfaro,

For the cases where you have the inverted mesh problem, could you test the following :

- Load the data
- Go to the segment editor
- Add segment
- Select brush + Sphere brush
- Paint a sphere in a 2D view
- Export to files in STL (see screen capture below)
- Check if the inversion is present in the exported sphere STL file

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

From my tests, an inversion case was coming from the input data frame of reference which didn’t match the expected one in 3D Slicer.

I implemented a tentative fixe for that in ([#7627](https://github.com/Slicer/Slicer/pull/7627)) which was successively patched by @lassoan for regressions by ([#7773](https://github.com/Slicer/Slicer/pull/7773), [#7746](https://github.com/Slicer/Slicer/pull/7746)).

If the same behavior is still present in your data, we may have to see why it’s not properly taken into account.

Best,  
Thibault

---

<div class="post-metadata">

**Author:** ![Romulo\_Alfaro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/romulo_alfaro/32/77327_2.png) [@Romulo\_Alfaro](https://discourse.slicer.org/u/Romulo_Alfaro)\
**Post date:** [July 17, 2024, 3:10pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/10 "2024-07-17T15:10:19Z")

</div>

![Captura de pantalla 2024-07-17 a la(s) 10.08.06 a. m.](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/6/96d9123226f43e5169731aeac1255b8b4bde1e1b.jpeg)

---

<div class="post-metadata">

**Author:** ![Thibault\_Pelletier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thibault_pelletier/32/4767_2.png) [@Thibault\_Pelletier](https://discourse.slicer.org/u/Thibault_Pelletier)\
**Post date:** [July 17, 2024, 3:19pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/11 "2024-07-17T15:19:30Z")

</div>

Thanks for your test!

If you have not already done so, could you do the same test using the latest 3D Slicer 5.7 preview version?

If the problem is still present, could you share one of the data you experience this problem?

---

<div class="post-metadata">

**Author:** ![Romulo\_Alfaro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/romulo_alfaro/32/77327_2.png) [@Romulo\_Alfaro](https://discourse.slicer.org/u/Romulo_Alfaro)\
**Post date:** [July 17, 2024, 3:22pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/12 "2024-07-17T15:22:47Z")

</div>

I am using version 5.7 for Mac

 ![Captura de pantalla 2024-07-17 a la(s) 10.21.07 a. m.](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/5/15dbfe06ea23238b85e16b2f1cdc06264cee7534.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:** [July 17, 2024, 7:06pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/13 "2024-07-17T19:06:14Z")

</div>

> [@Romulo\_Alfaro](#):
>
> I am using version 5.7 for Mac

Which version exactly?

---

<div class="post-metadata">

**Author:** ![Romulo\_Alfaro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/romulo_alfaro/32/77327_2.png) [@Romulo\_Alfaro](https://discourse.slicer.org/u/Romulo_Alfaro)\
**Post date:** [July 17, 2024, 7:16pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/14 "2024-07-17T19:16:36Z")

</div>

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

I just used DentalSegmentator on other DICOM file (CT) and the orientation was correct. Apparently and so far, it only happens with CBCT files.

---

<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:** [July 17, 2024, 9:00pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/15 "2024-07-17T21:00:17Z")

</div>

Could you take a screenshot of the IJK to RAS direction matrix in Volumes module?

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

Is the volume under a transform? (In Data module, if you right-click on the transform column in the volume’s row then is the “None” option is selected or some transform?)

---

<div class="post-metadata">

**Author:** ![Romulo\_Alfaro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/romulo_alfaro/32/77327_2.png) [@Romulo\_Alfaro](https://discourse.slicer.org/u/Romulo_Alfaro)\
**Post date:** [July 18, 2024, 4:20am UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/16 "2024-07-18T04:20:15Z")

</div>

![Captura de pantalla 2024-07-17 a la(s) 11.17.23 p. m.](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/1/f16543bf09f3df2d38fc9e898f2b2f0857ba0d30.png)  
 ![Captura de pantalla 2024-07-17 a la(s) 11.19.45 p. m.](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/5/d5f548a72cf6538dd2ab7583a144d15d0c0452f2.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:** [July 18, 2024, 4:35am UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/17 "2024-07-18T04:35:10Z")

</div>

Why do you have two segmentations and images?

Where/how did you use NIFTI? (The .nii suffix suggests that it may have been used)

Can you share an anonymized scene file (saved as a single .mrb file) so that we can investigate further?

---

<div class="post-metadata">

**Author:** ![Romulo\_Alfaro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/romulo_alfaro/32/77327_2.png) [@Romulo\_Alfaro](https://discourse.slicer.org/u/Romulo_Alfaro)\
**Post date:** [July 18, 2024, 4:52am UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/18 "2024-07-18T04:52:57Z")

</div>

> **[Archivo.zip](https://wetransfer.com/downloads/c8f3b78021f3df4b437c7aa17ddec82f20240718045151/5b1000)**
>
> 1 file sent via WeTransfer, the simplest way to send your files around the world

---

<div class="post-metadata">

**Author:** ![mohammed\_alshakhas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mohammed_alshakhas/32/10025_2.png) [@mohammed\_alshakhas](https://discourse.slicer.org/u/mohammed_alshakhas)\
**Post date:** [July 18, 2024, 7:45am UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/19 "2024-07-18T07:45:28Z")

</div>

i had couple of volume having distortion / compression issues with same module . i tried mona and had a good outcome .

---

<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:** [July 18, 2024, 4:50pm UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/20 "2024-07-18T16:50:10Z")

</div>

Thanks for the example file, it helped a lot confirming what was happening. The `479068 AXIAL.nrrd` file uses left-handed coordinate system (`space directions: (0.39999999999999997,0,0) (0,0.39999999999999997,0) (0,0,-0.40000000000000191)`), which causes the segmentation to be turned inside out.

Have you used the DICOM browser to load the CBCT image (`DICOM import` in Data module)? Or you forced loading using the legacy image reader (`Volume` option in Data module)?

I’ve submitted a fix that should properly reorient the image when it is loaded using the DICOM browser. It will be probably integrated within a couple of days:

> <https://github.com/Slicer/Slicer/pull/7858>
>
> Automatically flip left handed volumes when loading into 3D Slicer from DICOM to… make them compatible with all algorithms. Fixes flipped normals in segmentation node for left handed volumes.
> 
> Renamed FlipIJKCoordinateSystemHandedness method to ReverseSliceOrder to make it explicit that flipping of handedness is achieved by reversing slice order. The method was introduced recently (no Slicer Stable Release has been created since then), therefore the old name was not deprecated but removed.
> 
> See related commit that applies this regularization when the image is read using volume storage node: https://github.com/Slicer/Slicer/commit/3802d812b1a5d855399d8a19cea0bd1705715d52
> 
> See discussion at https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/9

---

<div class="post-metadata">

**Author:** ![Romulo\_Alfaro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/romulo_alfaro/32/77327_2.png) [@Romulo\_Alfaro](https://discourse.slicer.org/u/Romulo_Alfaro)\
**Post date:** [July 19, 2024, 1:04am UTC](https://discourse.slicer.org/t/dentalsegmentator-result-mesh-is-inverted/37408/21 "2024-07-19T01:04:23Z")

</div>

Is true. I just opened it by force loading using the legacy image reader and this time the orientation was correct. Only that Segmentation had some flaws.

 ![Captura de pantalla 2024-07-18 a la(s) 8.05.33 p. m.](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/9/19f28b0bf63e1a48e0df90697b0469743cc71219.jpeg)
