# Proceed to surfstat

**URL:** <https://discourse.slicer.org/t/proceed-to-surfstat/1229>\
**Category:** SlicerSALT\
**Created:** [October 15, 2017, 11:18am UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229 "2017-10-15T11:18:49Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![iPsych](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@iPsych](https://discourse.slicer.org/u/iPsych)\
**Post date:** [October 15, 2017, 11:18am UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/1 "2017-10-15T11:18:49Z")

</div>

Deal all,  
I am trying to run more complex statistics using surfstat.  
However the result of SPHARM-PDM or SlicerSALT ( \*ellalign.meta and \*ellalign.coef) seems different from  
the structures of data used in existing tutorial.

[http://www.stat.wisc.edu/~mchung/research/amygdala/](http://www.stat.wisc.edu/~mchung/research/amygdala/)

Anybody has some experience on modify the data to be used in surfstat?

---

<div class="post-metadata">

**Author:** ![styner](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/styner/32/1024_2.png) [@styner](https://discourse.slicer.org/u/styner)\
**Post date:** [October 16, 2017, 12:57pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/2 "2017-10-16T12:57:10Z")

</div>

Hi June, Indeed the coefficients themselves are not ready for surfstat, but you can use the vtk files to do the local shape analysis in surfstat. If you look at Moo’s amygdala page, before running surfstat he calls his tool SPHARMrepresent2, which maps the coefficients to a sampled/triangulated surface/mesh. The vtk files from our tool is such a triangulated mesh that you can use in surfstat. You just need to first convert it into either obj or MGH-Freesurfer format.  
Martin

---

<div class="post-metadata">

**Author:** ![SHKim](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@SHKim](https://discourse.slicer.org/u/SHKim)\
**Post date:** [October 16, 2017, 1:30pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/3 "2017-10-16T13:30:08Z")

</div>

Hi, June.

If you have vtk surfaces, first of all, you have to convert the surface format from vtk to freesurfer surface format. you can use “mris\_convert”. And also, you can check your surfaces have same vertex number (after surface registration) which means all surfaces have correspondence point.

---

<div class="post-metadata">

**Author:** ![iPsych](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@iPsych](https://discourse.slicer.org/u/iPsych)\
**Post date:** [October 16, 2017, 2:18pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/4 "2017-10-16T14:18:48Z")

</div>

Thanks, Martin,  
I checked SPHARMrepresent2.  
However, it requires data format like below.  
A=  
x: [43x85 double]  
y: [43x85 double]  
z: [43x85 double]  
(SPHARMrepresent2(sphere,A,15,0.01)😉

Since vtk data is just x,y,z coordinate, I think more data transfer or additional step is needed.

---

<div class="post-metadata">

**Author:** ![iPsych](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@iPsych](https://discourse.slicer.org/u/iPsych)\
**Post date:** [October 16, 2017, 2:20pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/5 "2017-10-16T14:20:00Z")

</div>

> [@SHKim](#):
>
> mris\_convert

Thanks,  
Actually I transferred it to MNI obj format.  
freesurfer surface is better to process?

You mean using mris\_convert, convert vtk to mgz, right?  
Should I use ellaign.vtk or already aligned procalign.vtk?

---

<div class="post-metadata">

**Author:** ![styner](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/styner/32/1024_2.png) [@styner](https://discourse.slicer.org/u/styner)\
**Post date:** [October 16, 2017, 3:31pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/6 "2017-10-16T15:31:24Z")

</div>

Sorry, that I was not clear. The vtk surfaces created by SALT would be similar to the surfaces created by SPHARMrepresent2. I.e. instead of using SPHARMrepresent2, you would be loading our surfaces.

---

<div class="post-metadata">

**Author:** ![styner](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/styner/32/1024_2.png) [@styner](https://discourse.slicer.org/u/styner)\
**Post date:** [October 16, 2017, 3:33pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/7 "2017-10-16T15:33:14Z")

</div>

I think obj or freesurfer are equally good. I don’t think mris\_convert converts from vtk, but rather only to vtk (I tried it on my local install, which is not the newest, and it did not work).

So, I would use your conversion from vtk to obj and then load those obj files into surfstat. For that purpose use the procalign.vtk surfaces.

Martin

---

<div class="post-metadata">

**Author:** ![styner](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/styner/32/1024_2.png) [@styner](https://discourse.slicer.org/u/styner)\
**Post date:** [October 16, 2017, 3:34pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/8 "2017-10-16T15:34:30Z")

</div>

Let me know if your vtk to obj tool does not work, as I was told by SunHyung that he has such a tool that we can give to you.  
Martin

---

<div class="post-metadata">

**Author:** ![iPsych](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@iPsych](https://discourse.slicer.org/u/iPsych)\
**Post date:** [October 16, 2017, 4:07pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/9 "2017-10-16T16:07:12Z")

</div>

Thanks.  
I also created python code using VTK, and it successfully converted vtk to obj.

However, I am stucked in below step. Brain, Age, Group is covariate. avsurf is average one.

slm0 = SurfStatLinMod( disp, Brain + Age + Group, avsurf);

When I load the obj transformed from vtk file, it looks like below.  
A=SurrfStatReadSurf(‘test.obj’)  
A =  
tri: [2880x3 int32]  
coord: [3x1442 double]

Making average surface from As are possible, but  
How should I calculate disp from them?

When I use surfstat, should I ignore ellalign.coef or should I use it in somewhere above?

---

<div class="post-metadata">

**Author:** ![SHKim](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@SHKim](https://discourse.slicer.org/u/SHKim)\
**Post date:** [October 16, 2017, 5:00pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/10 "2017-10-16T17:00:58Z")

</div>

Hi, June

I am not sure what you are analyzing for your measurement. What is your dependent variable? “disp” , as you wrote, is a dependent variable that means you obtained any features from surface (e.g. surface area, cortical thickness, and any your interesting value). But the dimension of your disp has to same the number of vertex (e.g. 1442 in your case).  
Could you explain the “ellalign.coef”? Is it your interesting dependent variable? If so, is the dimension matching to the number of vertex?

---

<div class="post-metadata">

**Author:** ![iPsych](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@iPsych](https://discourse.slicer.org/u/iPsych)\
**Post date:** [October 16, 2017, 5:12pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/11 "2017-10-16T17:12:14Z")

</div>

I am conducting shape analysis using SPHARM-PDM.  
disp is just difference from average shape in Moo K.s tutorial. (and same as me).  
Since I used different SPHARM method from Moo K., (He used matlab scripts to run SPHARM, and I used SPHARM-PDM made by Beatriz Paniagua.)

ellalign.coef is the result of SPHARM-PDM, and possibly coeffient values from comparision to standard sphere (r=1).

---

<div class="post-metadata">

**Author:** ![SHKim](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@SHKim](https://discourse.slicer.org/u/SHKim)\
**Post date:** [October 16, 2017, 6:00pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/12 "2017-10-16T18:00:55Z")

</div>

Hi, June

If I understood correctly, you want to make “disp” from the average surface and each individual surfaces. And then you will put the “disp” as a dependent variable into glm. Did you obtain each surface that is generated by SPHARM-PDM? If so, I thought it is quite simple to get the “disp”. you can calculate the distance between two points ( e.g. between coord from individual and coord from average).

---

<div class="post-metadata">

**Author:** ![iPsych](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@iPsych](https://discourse.slicer.org/u/iPsych)\
**Post date:** [October 16, 2017, 6:03pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/13 "2017-10-16T18:03:17Z")

</div>

Yes, that’s correct. I generate all surface by SPHARM-PDM, and use disp as dependent variable into glm.

---

<div class="post-metadata">

**Author:** ![iPsych](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@iPsych](https://discourse.slicer.org/u/iPsych)\
**Post date:** [October 17, 2017, 5:05am UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/14 "2017-10-17T05:05:07Z")

</div>

![21 PM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/3/33c219a7423256f2314948768430709c035bac0b.png)

Thanks Sun Hyung and Martin.  
I am almost done.

I think something wrong in the last visualization part, and looking on it.

Bests,  
J.

---

<div class="post-metadata">

**Author:** ![SHKim](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@SHKim](https://discourse.slicer.org/u/SHKim)\
**Post date:** [October 17, 2017, 1:02pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/15 "2017-10-17T13:02:09Z")

</div>

Hi, June

Great works. But I guess you are missing the surface smoothing. or when you visualized your values, the figure seems to use the vector information.

Sun Hyung

---

<div class="post-metadata">

**Author:** ![Tspostma](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@Tspostma](https://discourse.slicer.org/u/Tspostma)\
**Post date:** [January 22, 2018, 3:44pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/16 "2018-01-22T15:44:00Z")

</div>

> [@iPsych](#):
>
> Sun Hyung and Martin

Dear all,

I’m trying to import procalign.vtk files generated by Slicer into Surfstat, but I’m struggling with the conversion from vtk to MNI obj. Is the tool that Martin mentioned earlier still available?

---

<div class="post-metadata">

**Author:** ![SHKim](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@SHKim](https://discourse.slicer.org/u/SHKim)\
**Post date:** [January 22, 2018, 4:41pm UTC](https://discourse.slicer.org/t/proceed-to-surfstat/1229/17 "2018-01-22T16:41:36Z")

</div>

you can use vtk library or here is simple c++ code: [https://github.com/shykim/SurfaceConvert](https://github.com/shykim/SurfaceConvert)

best,  
Sun Hyung
