open-discussion > Can I export the rendered surface as a .stl file?
Showing 1-13 of 13 posts
Display:
Results per page:
May 13, 2021  04:05 PM | Pengfei Yan
Can I export the rendered surface as a .stl file?
I am using the software MRIcroGL to render the scalp.
It works well in doing this.

Now I want to export the rendered scalp as a .stl file, so that I can further process it in other softwares like Blender.

I haven't found such functions in MRIcroGL.
Could you please give me any suggestions on this?

You are appreciated!
May 14, 2021  03:05 PM | Chris Rorden
RE: Can I export the rendered surface as a .stl file?
Surface meshes are the domain of Surfice
  https://www.nitrc.org/plugins/mwiki/index.php/surfice:MainPage
Specifically, the Advanced men's  "Convert voxelwise volume to mesh" menu item.

You can use the Preferences window to set your preferred output mesh format: OBJ, GIfTI, MZ3 or PLY. You can find links to tools to convert OBJ or PLY to STL (I like MeshLab for this)
  https://www.nitrc.org/plugins/mwiki/index.php/surfice:MainPage#Supported_Formats
I believe Blender already supports OBJ and PLY formats, and I provide a plugin for MZ3:
 https://github.com/neurolabusc/surf-ice/tree/master/mz3

You should only use STL as a format of last resort if your tools do not support other formats. STL is inherently inferior to other formats like OBJ and PLY. Specifically, it does not reuses vertices. This results in large file sizes. Further, STL meshes will either appear faceted or require a slow vertex unification stage with an arbitrary tolerance. 
  https://discourse.slicer.org/t/beware-of-the-stl-file-format/7642
May 14, 2021  03:05 PM | Chris Rorden
RE: Can I export the rendered surface as a .stl file?
By the way, the MRIcroGL "File" menu's "Save Volume" menu item does allow you to export data to Blender's bvox format. This format is limited to 8-bit precision (whereas medical images are typically 16-bit precision, so your selected contrast/brightness are "burnt in" to the output). You can look online to see how Blender can volume render voxelwise data. However recent versions of Blender have changed a lot, so old tutorials may be of limited help. Perhaps a question on a Blender forum would provide advice.
May 14, 2021  04:05 PM | Pengfei Yan
RE: Can I export the rendered surface as a .stl file?
Thank you for the detailed explanation.
I think exporting as in the OBJ format is also an option for me.
I looked in the MRIcroGL software, and found the Preferences menu. But in this window, I cannot find an option that let me choose the preferred output format.
Could you help me on this?
You are appreciated!
Attachment: 002.png
May 14, 2021  04:05 PM | Pengfei Yan
RE: Can I export the rendered surface as a .stl file?
I have uploaded the Screenshot
Attachment: 001.png
May 14, 2021  04:05 PM | Pengfei Yan
RE: Can I export the rendered surface as a .stl file?
Besides, I cannot find the menu "Convert voxelwise volume to mesh" in MRIcroGL either ;-(

The version I am using is "MRIcroGL 1.2.20210317"
May 14, 2021  05:05 PM | Chris Rorden
RE: Can I export the rendered surface as a .stl file?
Your screenshots show the voxel-based MRIcroGL. For surface meshes you need to use surface-based Surfice.
   https://github.com/neurolabusc/surf-ice
   https://www.nitrc.org/plugins/mwiki/index.php/surfice:MainPage
May 19, 2021  02:05 PM | Pengfei Yan
RE: Can I export the rendered surface as a .stl file?
Thank you for the information, and I've tried the software Surf Ice.

I tried to load a head CT dataset, but the software failed to reconstruct the scalp (skin of the head) from this dataset.
Instead, the software showed a weird 3D surface reconstruction (as attached).

I am wondering if the software is intended to perform such tasks as reconstructing the scalp?
If yes, is it possible you could provide further guidance on how I could achieve this?

You are really appreciated!
Attachment: A.png
May 19, 2021  03:05 PM | Chris Rorden
RE: Can I export the rendered surface as a .stl file?
This forum is for MRIcroGL. Please post questions about Surfice in the Surfice forum. 

Assuming your voxelwise volume is in NIfTI format, you launch Surfice and choose the Advanced/ConvertVoxelwiseVolumeToMesh. You will then select your NIfTI volume, select threshold levels, and save the result as a mesh which you can view with Surfice or other mesh-based tools.
Jun 29, 2021  08:06 AM | rtransform - Medical University of Vienna
RE: Can I export the rendered surface as a .stl file?
I found 3D Slicer (https://www.slicer.org/) really helpful for surface creation and exporting NIfTIs to .stl, it also has some simple segmentation features.
Jun 29, 2021  12:06 PM | Chris Rorden
RE: Can I export the rendered surface as a .stl file?
Slicer3D is an excellent tool with a huge number of features. Here are a couple of other options:

1.) If you want to segment the brain from the head, you may want to try out my Matlab script:
  https://github.com/rordenlab/spmScripts/blob/master/nii_nii2stl.m
this uses SPM for the segmentation. It creates both a traditional STL file, as well as a "hollow" STL file, which is much less expensive to 3D print with companies like ShapeWays where you pay by the volume of material used. The attached image shows the segmented volume as NIfTI format (left, MRIcroGL), and as a STL format mesh (right, Surfice).

2.) The Surfice Advanced/ConvertVoxelwiseDataToMesh can be helpful. It can also be used in combination with my Matlab script, where you can adjust the iso-surface threshold (e.g. to show either white matter or pial surface).

As ever, I urge users to only create surface meshes in STL format as a format of last resort. If the other tools you are using can use ANY other surface format (OBJ, GIfTI, PLY, etc), you should choose the non-STL format. Since STL does not re-use vertices, STL files inherently use a lot of disk space. For the same reason, the files either are slow to load (e.g. Surfice) or have a jagged/faceted appearance (e.g. Slicer3D) when viewed.
Attachment: segment.png
Nov 10, 2021  04:11 PM | Pengfei Yan
RE: Can I export the rendered surface as a .stl file?
Hi Chris,

I have tried again, and still faced some difficulties.

I have tried the software Surfice again, but it seems the software could not render the scalp as I wanted (while MRIcroGL can do this well). The attached image is the screenshot of MRIcroGL, the data is a real-world patient MRI data, the scalp is rendered perfectly I think. Besides, in this image, I have segmented the lesion (brain tumor) as shown red. I am wondering if I could output/export the scalp AND the lesion together as an OBJ or PLY file, so that I can use it for further surgery planning. 

As for surgery, I want to measure things like: (1) the size of the lesion (2) the physical relationship between the lesion and several anatomical landmarks such as the eyes and the ears. To achieve this, I need the previous OBJ or PLY file, and then I can import the file to other softwares to do the measurement and planning.

Looking forward to your further advice :-)
Attachment: 001.png
Nov 10, 2021  04:11 PM | Pengfei Yan
RE: Can I export the rendered surface as a .stl file?
I will explain again, so that my question can be easier to get. 

I have uploaded the screenshot of the rendering, which can be acceseed/viewed at:
https://ibb.co/0nmLB0R

I want to export this model (scalp+ the segmented lesion) as a surface file(OBJ, GIfTI, PLY, etc), so that I can use this file in other softwares for further measurement and surgery planning.

Thank you in advance!