# Surface generation from label map volume

**URL:** <https://discourse.slicer.org/t/surface-generation-from-label-map-volume/10372>\
**Category:** Support\
**Created:** [February 20, 2020, 11:33pm UTC](https://discourse.slicer.org/t/surface-generation-from-label-map-volume/10372 "2020-02-20T23:33:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aep93](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aep93/32/5990_2.png) [@Aep93](https://discourse.slicer.org/u/Aep93)\
**Post date:** [February 20, 2020, 11:33pm UTC](https://discourse.slicer.org/t/surface-generation-from-label-map-volume/10372/1 "2020-02-20T23:33:45Z")

</div>

Hello all,  
I am trying a code for generating surface from a label map volume. When I enter the following command:

```auto
reconstructSurface.SetInputConnection(threshold.GetOutputPort())
reconstructSurface.SetProjectionPlaneMode(vtk.VTK_BEST_FITTING_PLANE)

```

I will get the following error:

```auto
File "<console>", line 1*
    reconstructSurface.SetInputConnection(threshold.GetOutputPort()) 
    reconstructSurface.SetProjectionPlaneMode(vtk.VTK_BEST_FITTING_PLANE)*
SyntaxError: invalid syntax*

```

Can anyone help me about it?  
Thanks

---

<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:** [February 21, 2020, 12:16am UTC](https://discourse.slicer.org/t/surface-generation-from-label-map-volume/10372/2 "2020-02-21T00:16:53Z")

</div>

Point cloud reconstruction filters are not suitable for creating surfaces from labelmaps. Instead, you can use marching cubes or flying edges filter, followed by surface smoothing. In Slicer, you can do all the steps with just two lines of code - see [here](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Create_a_segmentation_from_a_labelmap_volume_and_display_in_3D).

---

<div class="post-metadata">

**Author:** ![Aep93](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aep93/32/5990_2.png) [@Aep93](https://discourse.slicer.org/u/Aep93)\
**Post date:** [February 21, 2020, 3:25pm UTC](https://discourse.slicer.org/t/surface-generation-from-label-map-volume/10372/3 "2020-02-21T15:25:37Z")

</div>

Thank you very much for your comment. I used the code you mentioned but what I get is something like a volume. Actually, I want to segment a tissue with very small thickness (eardrum) and convert my model to a surface so that I can use it as shell element if FEM packages. Do you have any suggestion for that?  
Thanks and regards.

---

<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:** [February 21, 2020, 3:57pm UTC](https://discourse.slicer.org/t/surface-generation-from-label-map-volume/10372/4 "2020-02-21T15:57:32Z")

</div>

OK, if you want to reconstruct an open surface from points then surface reconstruction filters can make sense. You may use markups fiducials to define surface points instead of derive them from labelmaps.

You got the error message above because of a typo (you typed a “\*” character at the end of the line that caused the syntax error).

---

<div class="post-metadata">

**Author:** ![Aep93](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aep93/32/5990_2.png) [@Aep93](https://discourse.slicer.org/u/Aep93)\
**Post date:** [February 21, 2020, 4:32pm UTC](https://discourse.slicer.org/t/surface-generation-from-label-map-volume/10372/5 "2020-02-21T16:32:52Z")

</div>

Thank you very much for your response.
