Surface generation from label map volume

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

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

I will get the following error:

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

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.

1 Like

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.

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).

Thank you very much for your response.