Convert stl surface to .surf.gii

Hello,

I am attempting to convert a .stl file to a .surf.gii but I can’t find a tool that does this.

I tried using mris_convert from Free Surfer but that did not work.

This is the command.

mris_convert cb4mesh-dec250k_fixnMf6_Euler-448_scale001.stl cb4mesh-dec250k_fixnMf6_Euler-448_scale001.surf.gii

This is the error I get.

MRISreadSTLfile: error reading file cb4mesh-dec250k_fixnMf6_Euler-448_scale001.stl
No such file or directory
mris_convert: could not read surface file cb4mesh-dec250k_fixnMf6_Euler-448_scale001.stl
No such file or directory

I’m definitely in the right directory so I’m not sure why this error is occurring. Does anybody know of any other tools that can do this conversion?

Thank you,
Hanad

It’s possible mris_convert assumes that relative paths are relative to some FreeSurfer directory, so you can try:

mris_convert ./cb4mesh-dec250k_fixnMf6_Euler-448_scale001.stl ./cb4mesh-dec250k_fixnMf6_Euler-448_scale001.surf.gii

Thank you for your reply. I tried putting the full path and I got the same error unfortunately.

Hmm. I would check on the FreeSurfer mailing list, then. The FreeSurfer developers are much more active there.

But when you do get a response, it might be useful to post back here, so others can benefit.

1 Like

I will definitely do that. Thanks!

If you only have a few files, you can use the graphical interface of Surfice. Drag and drop your STL file and then choose Advanced/SaveMesh and choose the GIfTI format. If you do this a few times, you can go to Preferences and make GIfTI your default format for saving files.

As an aside, I would check if the software that was used to to create your STL files can export to any format other than STL. STL has a fatal flaw that it does not re-use vertices. This means that these files look ugly (faceted) in most tools, have lower framerates, and load slowly with tools like Surfice (that need to weld the vertices back together). This flaw also means the files are much larger than they need to be. The only reason to use STL is if it is required by tools in your pipeline, and in this case you should lobby the developers of those tools to support better formats.

I was able to get a .surf.gii version of the file. I will note your GUI and use it if needed. Thank you