# Normalisation or scaling with SPHARM

**URL:** <https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602>\
**Category:** Support\
**Tags:** spharm-pdm\
**Created:** [May 26, 2022, 11:19pm UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602 "2022-05-26T23:19:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khalid\_Saifullah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/khalid_saifullah/32/15324_2.png) [@Khalid\_Saifullah](https://discourse.slicer.org/u/Khalid_Saifullah)\
**Post date:** [May 26, 2022, 11:19pm UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602/1 "2022-05-26T23:19:28Z")

</div>

Hi,

I would like to normalise all of my SPHARM-PDM output subjects (subjectID\_pp\_surf\_SPHARM\_procalign.vtk) by a scale factor before running any sort of statistical analysis. I am going to use a separate tool for the statistical analysis, so I would just need the scaled SPHARM-PDM output for now. Could you let me know how I can do this, please?

Regards,  
Khalid

---

<div class="post-metadata">

**Author:** ![Khalid\_Saifullah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/khalid_saifullah/32/15324_2.png) [@Khalid\_Saifullah](https://discourse.slicer.org/u/Khalid_Saifullah)\
**Post date:** [May 31, 2022, 12:53am UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602/2 "2022-05-31T00:53:01Z")

</div>

@styner Do you have the answer to this? Or could you point me to the right person?

---

<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:** [May 31, 2022, 7:49pm UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602/3 "2022-05-31T19:49:56Z")

</div>

Hi Khalid  
I am not sure I fully understand what you are trying to do. Do you want to simply scale the size of the mesh by a given factor (which is simply multiplying all coordinates by the scale factor), or do you want to scale the mesh to have a particular size? In case of the former, you can use MeshMath with option scaleMesh  
Martin

---

<div class="post-metadata">

**Author:** ![Khalid\_Saifullah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/khalid_saifullah/32/15324_2.png) [@Khalid\_Saifullah](https://discourse.slicer.org/u/Khalid_Saifullah)\
**Post date:** [June 1, 2022, 3:31am UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602/4 "2022-06-01T03:31:13Z")

</div>

Hi Martin,

So, I need to normalize all of the subjects (subjectID\_pp\_surf\_SPHARM\_procalign.vtk) by their intra-cranial volume (scale factor). Then I would like to calculate the signed normal distance from the mean shape followed by statistical analysis (with a separate tool). Which one of the two would be appropriate for this?

Regards,  
Khalid

---

<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:** [June 1, 2022, 5:45pm UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602/5 "2022-06-01T17:45:33Z")

</div>

This is scaling with a known scaling factor (in your case 1 / ICV^(1./3) ) , so use MeshMath. As you can see from this formula, if you use a volume measure to scale meshes, you need to take the cubic root (as scaling affects coordinates in mm)

Martin

---

<div class="post-metadata">

**Author:** ![Khalid\_Saifullah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/khalid_saifullah/32/15324_2.png) [@Khalid\_Saifullah](https://discourse.slicer.org/u/Khalid_Saifullah)\
**Post date:** [June 9, 2022, 7:59pm UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602/6 "2022-06-09T19:59:37Z")

</div>

Hi Martin,

The scale factor in your SPHARM-PDM framework paper suggests this formula:  
Scale Factor = Mean(ICV) ∕ (ICV\_subject)^⅓

Is this what you are saying in the previous reply? Also, is there a recommendation for number of places after decimal?

PaperLink: [Framework for the Statistical Shape Analysis of Brain Structures using SPHARM-PDM - PMC](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3062073/)

Regards,  
Khalid

---

<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:** [June 10, 2022, 1:53pm UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602/7 "2022-06-10T13:53:26Z")

</div>

Slightly different:  
(Mean(ICV) ∕ ICV\_subject)^⅓

---

<div class="post-metadata">

**Author:** ![Khalid\_Saifullah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/khalid_saifullah/32/15324_2.png) [@Khalid\_Saifullah](https://discourse.slicer.org/u/Khalid_Saifullah)\
**Post date:** [June 11, 2022, 3:15am UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602/8 "2022-06-11T03:15:45Z")

</div>

Hi Martin,

Thank you for taking the time in answering all the questions!

I see that once scaled, the subjects are no longer spatially aligned as they were in the subject\_pp\_surf\_SPHARM\_procalign.vtk files. How can I realign them again for the accurate distance calculation?

Regards,  
Khalid

---

<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:** [June 13, 2022, 1:27pm UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602/9 "2022-06-13T13:27:01Z")

</div>

The change in alignment happens, as the data is rigid-procrustes aligned (procrustes without scale) in image space (i.e. in the average location in image space, here the average hippocampus location). As you scale the size, this also changes the location in space.

In order for this not to happen, you could use an alignment to origin of coordinate system when the center of gravity/0th moment is (0,0,0).

Of course, you can do the rescaling in the image space, you just need to redo the alignment. As always there are multiple ways to do so, but I usually use MeshMath.

MeshMath RefMesh.vtk -alignMesh mesh1.vtk mesh2.vtk mesh3.vtk …

This does rigid procrustes, unless you also specify -scalingOn and then it does full procrustes.  
As reference mesh, you can use the average Mesh from before you did the rescaling. If you do not have that, you can compute an average Mesh with MeshMath and -avgMesh option. Btw, if you run MeshMath without any command line options, then it will give you an usage/help outout.

Martin

---

<div class="post-metadata">

**Author:** ![Khalid\_Saifullah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/khalid_saifullah/32/15324_2.png) [@Khalid\_Saifullah](https://discourse.slicer.org/u/Khalid_Saifullah)\
**Post date:** [August 30, 2022, 7:05am UTC](https://discourse.slicer.org/t/normalisation-or-scaling-with-spharm/23602/10 "2022-08-30T07:05:26Z")

</div>

Hi @Styner,

I wanted to asked you about the following two commands. How is the second command’s output different from that of the first one in terms of alignment? I know that the first one gives procrustes alignment and the second one gives a realignment but not sure if they are the same.

Command 1:  
ParaToSPHARMMeshCLP --NoParaAlign --paraOut --spharmDegree 15 --subdivLevel 10 --regTemplate template\_pp\_surf\_SPHARM.vtk --regTemplateFileOn Step2\_GenParaMesh/subject1\_pp\_para.vtk Step2\_GenParaMesh/subject1\_pp\_surf.vtk Step3\_ParaToSPHARMMesh/subject1\_pp\_surf

Command 2:  
MeshMath RefMesh.vtk -alignMesh mesh1.vtk mesh2.vtk mesh3.vtk …

Regards,  
Khalid Saifullah
