Saved pial surface model reloads as invalid

Hello, I use FreeSurfer to generate cortical surface models from a brain MR volume (outside of Slicer). Slicer can load the resulting surface files (lh.pial and rh.pial) as models and they seem to function as normal models within Slicer, including a log message like

"Model" Reader has successfully read the file "C:/DockerTest/freesurfer_subjects/GGNonCon/surf/rh.pial" "[0.23s]". 

I can interact with the imported models in all the ways I want to, change color, transparency, apply transforms, etc. However, when I save them to file, they are given a .vtk extension (rh.vtk and lh.vtk), and when I next try to load them into Slicer, they come in as invalid models and do not display, with the following error message appearing in the log:

vtkFSSurfaceReader.cxx Execute: Wrong file type when loading C:/Users/mikeb/Documents/Neuro/Testing/PialSaveReload/rh.vtk
 magic number = 2302070. Supported ar 16777215, 16777213, and 16777214

This happens any time I try to save and reload these surface files. Re-importing from the original pial surface files generated by FreeSurfer works fine, but this error makes it impossible to regenerate the application state by saving and loading a MRML scene.

I’m running 4.11.0-2020-01-08 on Windows.

Expected behavior: Imported FreeSurfer surfaces should reload into Slicer after being saved as .vtk models.

Actual behavior: Saved .vtk models of FreeSurfer surfaces reload as !InvalidModel.

@Sunderlandkyl what would you recommend?

I’ve made a pull request for a workaround here: https://github.com/Slicer/Slicer/pull/1325

No write functions have been implemented for the FreeSurferModel storage node, so the storage node falls back on the parent implementation to save the node as a vtk.

1 Like

Thanks! How can I tell if/when this has been incorporated into a nightly build for Windows?

It is not integrated yet. Let’s discuss it in the pull request.

OK, I’ll switch over to there. Thanks

@mikebind The workaround has been merged, and should be available in tomorrow’s installer. Thanks @Sunderlandkyl !

2 Likes