# Saved pial surface model reloads as invalid

**URL:** <https://discourse.slicer.org/t/saved-pial-surface-model-reloads-as-invalid/10268>\
**Category:** Support\
**Tags:** freesurfer\
**Created:** [February 14, 2020, 9:59pm UTC](https://discourse.slicer.org/t/saved-pial-surface-model-reloads-as-invalid/10268 "2020-02-14T21:59:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [February 14, 2020, 9:59pm UTC](https://discourse.slicer.org/t/saved-pial-surface-model-reloads-as-invalid/10268/1 "2020-02-14T21:59:32Z")

</div>

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.

---

<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 14, 2020, 10:21pm UTC](https://discourse.slicer.org/t/saved-pial-surface-model-reloads-as-invalid/10268/2 "2020-02-14T22:21:08Z")

</div>

@Sunderlandkyl what would you recommend?

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [February 15, 2020, 1:55am UTC](https://discourse.slicer.org/t/saved-pial-surface-model-reloads-as-invalid/10268/3 "2020-02-15T01:55:57Z")

</div>

I’ve made a pull request for a workaround here: [https://github.com/Slicer/Slicer/pull/1325](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.

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [February 17, 2020, 3:57pm UTC](https://discourse.slicer.org/t/saved-pial-surface-model-reloads-as-invalid/10268/4 "2020-02-17T15:57:06Z")

</div>

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

---

<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 17, 2020, 4:02pm UTC](https://discourse.slicer.org/t/saved-pial-surface-model-reloads-as-invalid/10268/5 "2020-02-17T16:02:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [February 17, 2020, 4:03pm UTC](https://discourse.slicer.org/t/saved-pial-surface-model-reloads-as-invalid/10268/6 "2020-02-17T16:03:46Z")

</div>

OK, I’ll switch over to there. Thanks

---

<div class="post-metadata">

**Author:** ![Sam\_Horvath](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sam_horvath/32/3092_2.png) [@Sam\_Horvath](https://discourse.slicer.org/u/Sam_Horvath)\
**Post date:** [February 17, 2020, 6:33pm UTC](https://discourse.slicer.org/t/saved-pial-surface-model-reloads-as-invalid/10268/7 "2020-02-17T18:33:00Z")

</div>

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