open-discussion > ParaToSpharmMeshCLP - basic usage?
Showing 1-14 of 14 posts
Display:
Results per page:
Jun 3, 2015  10:06 PM | Lara Foland-Ross - Stanford University
ParaToSpharmMeshCLP - basic usage?
Hello SPHARM experts, 

I am new to SPHARM and have successfully run a single subject through both SegPostProcessCLP and GenParaMeshCLP (via command line). I've run into some difficulty running ParaToSPHARMMeshCLP, and am hopeful you can help clarify what's happening in this step.

The command I'm running is:

ParaToSPHARMMeshCLP --regTemplate input_data_postprocessed_surfSPHARM.vtk --regTemplateFileOn --flipTemplate inputdata_postprocessed_surfSPHARM.coef --flipTemplateOn --medialMesh --paraOut --phiIteration 100 --thetaIteration 100 --spharmDegree 12 --subdivLevel 20 inputdata_postprocessed_para.vtk inputdata_postprocessed_surf.vtk output_surf

And the error that is returned states: "Coef file couldn't be open"

What's additionally puzzling is that I thought ParaToSPHARMMeshCLP generates the .coef file. Is that correct?

Could you also please confirm that ParaToSPHARMMeshCLP generates input_data_postprocessed_surfSPHARM.vtk?

Many thanks in advance for the help!
Lara
Jun 4, 2015  01:06 PM | Martin Styner
RE: ParaToSpharmMeshCLP - basic usage?
Hi Lara
the templates provided to ParaToSPHARMMeshCLP are input data, they provide an alignment template (rotation/translating the mesh to match the "regTemplate") and a parameter flip template (flipping the spherical parametrization, e.g. switching the north vs south pole of the spherical parametrization). Both are not necessary, but can be provided to match meshes across different subjects or even different studies.

So, if you run it for the first time, you won't have any templates and thus you cannot provide these template (and yes, input_data_postprocessed_surfSPHARM.vtk is generated by ParaToSPHARMMeshCLP)

But, if you have multiple meshes, you can make sure that they are aligned by using the regTemplate and that they have the same spherical parametrization orientation by using a flipTemplate.

A good illustration is how the ShapeAnalysisModule processes its input data. If no prior regTemplate & flipTemplate is provided, then it processes the first input dataset without any regTemplate or flipTemplate,and then sets the output mesh of that first input data as the templates for all other datasets.
Just btw, if the option "--MTemplate" is used, ShapeAnalysisModule will compute the mean surface over all datasets and rerun the processing with that mean surface as the regTemplate.

Martin
Jun 4, 2015  09:06 PM | Lara Foland-Ross - Stanford University
RE: ParaToSpharmMeshCLP - basic usage?
Thank you Martin! I have a couple of follow-up questions for you:

1. So assuming I continue to process my subjects individually via command line (SegPostProcessCLP, then GenParaMeshCLP, followed by ParaToSPHARMMeshCLP), then would I omit all template flags from my ParaToSPHARMMeshCLP command? (making it read as follows:)

ParaToSPHARMMeshCLP --medialMesh --paraOut --phiIteration 100 --thetaIteration 100 --spharmDegree 12 --subdivLevel 20 inputdata_postprocessed_para.vtk inputdata_postprocessed_surf.vtk output_surf

2. My general thinking is - again assuming I continue to process my subjects individually via command line - I would create an average mesh of all subjects using MeshMath. Specifically, I was thinking I would use the outputs of GenParaMeshCLP as inputs to MeshMath (using the -avgMesh flag), then feed that average in as my template for ParaToSPHARMMeshCLP. Is this appropriate? It's not clear to me from other posts whether I would actually need to make the average template from the output meshes that are created by ParaToSPHARMMeshCLP instead (in which case I would simply run ParaToSPHARMMeshCLP twice - once before template creation that does not include template flags and once after that does).

Many thanks again!
Lara
Jun 5, 2015  06:06 PM | Martin Styner
RE: ParaToSpharmMeshCLP - basic usage?
Re 1) correct.

Re 2) You would need to use MeshMath to compute the average (that's what ShapeAnalysisModule does). And you can't do that on the GenParaMeshCLP meshes, as these do not yet have correspondence (these do not even have the same number of surface vertices, so I would not know how to go about computing an average). 


Martin
Jun 10, 2015  09:06 AM | Marco P
RE: ParaToSpharmMeshCLP - basic usage?
Dear Martin,

I have to follow up questions.

1) as you and Lara suggested, i build an average template_pp_surfSPHARM_ellalign.vtk using "MeshMath -avgMesh" by averaging all my subjs_ pp_surfSPHARM_ellalign.vtk. Now I want to use this template to perform procrustes analysis. How do I calculate template_pp_surfSPHARM.coef? In fact I need this coefficients to use "ParaToSPHARMMeshCLP --flipTemplate".

2) can you please give us more information about the procedure you use for procrustes analysis? what does this algorithm maximise/minimise?

Thanks a lot again for you support!

Marco
Jun 10, 2015  01:06 PM | Martin Styner
RE: ParaToSpharmMeshCLP - basic usage?
Hi Marco

Re 1) the fliptemplate is only used to determine the optimal "flips" of the spherical parametrization, i.e. whether the north pole of the parametrization is at the right place, or rather should be flipped/mirrored to be at the current south pole. Since the correspondence is based on the first order ellipsoid, the correspondence is ambiguous with respect to such flips. Thus, you do not need to create an average coefficient file (though one certainly could), but simply using any coefficient file associated with one of the meshes that was used for the average computation will suffice. E.g. just take the ellalign.coef file of the first (or any other) mesh that you used in your MeshMath call as the flipTemplate.

Re 2) Procrustes is the standard alignment computing a 7 parameter (rotation, translation and single scale) alignment minimizing the mean squared error. In the standard SPHARM pipeline, only 6 of these 7 are used for the alignment, i.e. no scaling and thus the alignment is called rigid Procrustes. I always found wikipedia a good source for a quick read: http://en.wikipedia.org/wiki/Procrustes_analysis

Martin
Jun 25, 2015  10:06 PM | Lara Foland-Ross - Stanford University
RE: ParaToSpharmMeshCLP - basic usage?
Hi Martin, 

I have some follow up questions regarding this thread:

1. Regarding your answer to question #1 (from Marco), I noticed elsewhere in this forum (albeit years ago now) that it was suggested that one use the *_surfSPHARM.coef file as the flip template (not the ellalign one). Can you confirm which is appropriate (*_surfSPHARM_ellaign.coef or *_surfSPHARM.coef)?

2.  Is it correct to say (in an analysis of the hippocampus analysis, for example) that the:
a. the first order ellipsoid alignment (performed in ParaToSpharmMeshCLP using the --flipTemplateOn and --flipTemplate flags) ensures that every participant's hippocampi are in the same general orientation, and
b. the procrustes alignment (performed in ParaToSpharmMeshCLP using the the --regTemplateFileOn and --regTemplate flags) ensures that the hippocampi across subjects are more tightly aligned using a 6dof registration (with no scaling), thus
c. providing a common space in which to compute, using StatNonParamTestPDM or ShapeAnalysisMANCOVA, group difference of the local surface point distributions?

3. Lastly, in computing a study specific average mesh for use as my template in the rigid Procrustes alignment, can you confirm that I should be averaging the *_surfSPHARM_ellalign.vtk files (and not the *_surfSPHARM.vtk files)?

Many thanks in advance!
Lara
...
Jun 26, 2015  02:06 PM | Martin Styner
RE: ParaToSpharmMeshCLP - basic usage?
Hi Lara

Re 1. it does not really matter, which one you use, as long as you do so consistently

Re 2. a-c) You have most (but not all) of it correct. The first order ellipsoid alignment is just based on a different assumption than the procrustes alignment. Procrustes is defined with respect to a template) the first order ellipsoid does not need one. So, both provide a 6dof registration/alignment and can be used for analysis. Since Procrustes is more generally accepted in the field that is what we suggest to use.

You also have to differentiate alignment and flips. Alignment is the computation of the optimal rotation & translation such that all the transformed meshes are spatially aligned as best as possible (on top of each other). The flips are used for the spherical parametrization, which establishes correspondence (and does not do any spatial alignment). It is noteworthy that with an incorrect flip (and thus the correspondence would be mirrored along one or more of the three coordinate axes), a spatially aligned surface would become mirrored/flipped as compared to the non-aligned surface. This can also be used to one's advantage, e.g. by flipping a left-hemispheric hippocampus onto a right hemispheric one for asymmetry analysis.

Re 3. usually we average the rigid procrustes aligned surfaces, if you have them. Otherwise it's perfectly fine to average the ellipse aligned surfaces. I would NOT average the original surfaces, unless they are already prealigned before using SPHARM-PDM

Martin
Jun 26, 2015  04:06 PM | Lara Foland-Ross - Stanford University
RE: ParaToSpharmMeshCLP - basic usage?
Thank you Martin. This is very helpful! I was confusing flips and registrations.

So then both registrations (ellalign and procalign) are performed separately, and one can pick and choose which set of registered surfaces they use in their statistical processing (*_surfSPHARM_ellalign.vtk or *_surfSPHARM_procalign.vtk)?

Thanks again,
Lara
Jun 26, 2015  04:06 PM | Martin Styner
RE: ParaToSpharmMeshCLP - basic usage?
correct.

Martin
Jul 22, 2015  05:07 PM | Lara Foland-Ross - Stanford University
RE: ParaToSpharmMeshCLP - basic usage?
Hi Martin and others, 

I have followed the steps in this thread using the general three steps:
1. run ParaToSPHARMMeshCLP separately for each subject without specifying flip or registration templates to get vtk files having correspondance (*_surfSPHARM.vtk)
2. use MeshMath -avgMesh to create study-specific average using the *_surfSPHARM.vtk files
3. rerun ParaToSPHARMMeshCLP while specifying both the flip and registration templates

I have successfully run steps 1 and 2 and have run into a wall with step 3. 

Here's what I ran for step 3 specifically:

ParaToSPHARMMeshCLP --regTemplate [template_directory]/average_SPHARM_template.vtk --regTemplateFileOn --flipTemplate [template_directory]/[randomsubj]_Lhipp_surfSPHARM.coef flipTemplateOn --medialMesh --paraOut --phiIteration 100 --thetaIteration 100 --spharmDegree 12 --subdivLevel 20 [subjid]_Lhipp_para.vtk [subjid]_Lhipp_surf.vtk [subjid]_Lhipp_surf_round2

The specific error message I'm getting is:

PARSE ERROR: Argument: [subjid]_Lhipp_surf_round2
Couldn't find match for argument

(note that where I typed [subjid] in this post, I insert actual subject id number)
Also, in the above command, [subjid]_Lhipp_para.vtk and [subjid]_Lhipp_surf.vtk = output vtk files from step 1; [template_directory]/average_SPHARM_template.vtk = the average study template I made with MeshMath; [randomsubj]_Lhipp_surfSPHARM.coef is a coefficient file that I pulled from a subject at random following step #1.

Any feedback on where I'm going wrong is greatly appreciated!
Lara
Jul 22, 2015  05:07 PM | Lara Foland-Ross - Stanford University
RE: ParaToSpharmMeshCLP - basic usage?
So sorry! I caught my error. I had a simple type (needed a "--" before flipTemplateOn). 

Nevertheless, I would appreciate your confirming that my .vtk inputs for this step 3 are correct. My hunch is that they are, but I am curious as to whether I should have used the SPHARM vtk files that had correspondence.

Thanks and apologies again for the previous post!
Lara
Jul 22, 2015  08:07 PM | Martin Styner
RE: ParaToSpharmMeshCLP - basic usage?
Yes, your input is correct, i.e. you need to input the original surf and para surfaces, not the SPHARM ones with correspondence (it should work with the SPHARM mesh and parametrization too, never tried it though).

Martin
Jul 22, 2015  08:07 PM | Lara Foland-Ross - Stanford University
RE: ParaToSpharmMeshCLP - basic usage?
Perfect. Thanks!

Lara