open-discussion > New analysis tool release and other questions
Showing 1-5 of 5 posts
Display:
Results per page:
May 4, 2016  01:05 PM | Lucas Fenger - Universität Würzburg
New analysis tool release and other questions
Dear SPHARM-experts!

I am currently trying to use SPHARM-PDM and ShapeAnalysisMancova for my study. I installed ITK-SNAP (version 3.4.0), the newest stable version of 3D Slicer (version 4.5.0-1) and its SPHARM extension on a Windows 7 machine. I also
installed a virtual Linux (Ubuntu 15.10) on it to be able to use the Mancova analysis per console. Thanks to your documentaion, your publications and the forum entrys, I am able to create and export labels with ITK-SNAP and to run them through SPHARM. But some questions came up, and I would be happy if you could answer them:

1) Are you planning to release a new analysis tool any time soon? Because I think it would be wiser for me to wait for it instead of using the Mancova analysis then.

2) If I use the procrustes alignment (6dof) in the SPHARM application, I get all the labels (right and left) flipped to one side, and most of them seem to overlap quite well, but there are some labels which seem to be too much rotated around one axis by like 45, 90 or even 180 degrees. Is there a way to fix that? Perhaps approximating the labes by a rough registration first and then doing a somewhat restrictet 6dof procrustes analysis? The flipping option is only for getting the right orientation for the poles of the parametrization, isn't it?

3) Is there a way to define exactly a sufficient accuracy threshold for the SubdivLevel value and for the SPHARM Degree value? Or is there a way to make safe assumptions for them?

4) What does it mean if I increase the number of theta/phi iterations? Are they for computing of the mean latitude axis only?

5) What is the difference betwen "ParaOut (template)" and "Use Mean as the Template"? Does "ParaOut (template)" mean that simply the first label gets used as template?

6) What do the four parameters (startRegularization, endRegularization, optimizationIteration, RelativeWeighting) under the option "UseProcalign" mean?

7) What is the option "overwrite" in every part of the SPHARM application in 3D Slicer for? To not use that particular part in that particular run?

Many thanks in advance,

Lucas
May 5, 2016  01:05 PM | Beatriz Paniagua
RE: New analysis tool release and other questions
Hi Lucas,


I am glad to hear that the documentation, the forum and the papers have helped you process your data.
1) Are you planning to release a new analysis tool any time soon? Because I think it would be wiser for me to wait for it instead of using the Mancova analysis then.

This project does not have dedicated funding for new tool releases. We are maintaining it and solving bugs with small funds from other projects that only allow us to keep the current version of spharm in good working order but not adding new functionality. We have been making a lot of efforts to gather new funding and we hope to be able to obtain the resources we need soon to develop and release a new tool that can replace mancova, but for now older versions of mancova is what is available for analysis.
2) If I use the procrustes alignment (6dof) in the SPHARM application, I get all the labels (right and left) flipped to one side, and most of them seem to overlap quite well, but there are some labels which seem to be too much rotated around one axis by like 45, 90 or even 180 degrees. Is there a way to fix that? Perhaps approximating the labes by a rough registration first and then doing a somewhat restrictet 6dof procrustes analysis? The flipping option is only for getting the right orientation for the poles of the parametrization, isn't it?

Yes, there is a fix for that but you will have to run the last spharm step manually. When you run ParaToSPHARMMesh you can enforce a certain flip (8 possible flips in each 3D axis and all the combinations), and choose the flip that makes your data match well.
3) Is there a way to define exactly a sufficient accuracy threshold for the SubdivLevel value and for the SPHARM Degree value? Or is there a way to make safe assumptions for them?
There are several ways to do it. You could use some comparison metric between the input binary map and the output PDM, and use the spharm degree and subdivision that give you an acceptable error level (they wont be the absolute same). In Slicer, for example you can look at volume values from a label map as well as a 3D surface, and you could use that value to compare both representations.
4) What does it mean if I increase the number of theta/phi iterations? Are they for computing of the mean latitude axis only?
Yes, that is correct, those are parameters only affecting the computation of the mean latitude axis. The number of theta iterations define how many points you will have along the axis, and the number of phi iterations define how many points along the surface you will use to compute the mean point for a latitude.
5) What is the difference betwen "ParaOut (template)" and "Use Mean as the Template"? Does "ParaOut (template)" mean that simply the first label gets used as template?
Para out is to write out the parameterization values as scalar maps that can be loaded into the pdm or the unit sphere, it does not have anything to do with the alignment template. If you do not select "use mean as template" the first case in the list will be the template for the paramterization pose correction and the other additional alignment options (ellalign and procalign), if you use mean as template it will do one round of computation of spharm representations for all cases to them compute a mean. In a second round of computation, the mean will be used as template and new files will be writen out for all cases (mtemplate).
6) What do the four parameters (startRegularization, endRegularization, optimizationIteration, RelativeWeighting) under the option "UseProcalign" mean?
It has to do with the procrustes registration. As any other registration problems involves an optimization, and those are parameters relating to the optimization process. Procrustes alignment tries to optimize the positions of one or more surface meshes points to have the least error between them as possible.
7) What is the option "overwrite" in every part of the SPHARM application in 3D Slicer for? To not use that particular part in that particular run?
This only is important if you use an output folder with files computed inside it. SPHARM by default will not compute again files that already exist in a certain output folder, unless the overwrite option is specified.



I hope that helps!
Best regards,


Beatriz
May 6, 2016  02:05 PM | Lucas Fenger - Universität Würzburg
RE: New analysis tool release and other questions
Dear Beatriz,

thank you very much for your detailed answers. SPHARM seems to be a great method to use in medicine, and I hope that the project will get the funding soon.
2) If I use the procrustes alignment (6dof) in the SPHARM application, I get all the labels (right and left) flipped to one side, and most of them seem to overlap quite well, but there are some labels which seem to be too much rotated around one axis by like 45, 90 or even 180 degrees. Is there a way to fix that? Perhaps approximating the labes by a rough registration first and then doing a somewhat restrictet 6dof procrustes analysis? The flipping option is only for getting the right orientation for the poles of the parametrization, isn't it?

Yes, there is a fix for that but you will have to run the last spharm step manually. When you run ParaToSPHARMMesh you can enforce a certain flip (8 possible flips in each 3D axis and all the combinations), and choose the flip that makes your data match well.

I am not sure whether you refer to the spatial alignment or the parametrization, my choice of words was a little misleading I think. To clarify:  I would like to change the spatial alignment of some of the meshes, not the orientation of the parametrization. Albeit on a second thought, changing the orientation of the parametrization could probably get the meshes which are misaligned of about 180 degrees in the right spatial position, could'nt it?

So how about the following approach:
1) Computing a complete set of files with the 3D Slicer application by using the mean template and procrustes options; identifying bad aligned meshes in the viewer.
2) Using the generated *para.vtk and *surf.vtk files for computing a *surfSPHARM.vtk file while changing the spatial alignment of the bad aligned meshes with ParaToSPHARMMesh.
3) Computing a mean template with MeshMath
4) Running the outcomes of 2) with 3) through ParaToSPHARMMesh

Does that make sense? What flag do I have to use with ParaToSPHARMMesh to change the spatial alignment of specific labels?


Thanks again,

Lucas
May 10, 2016  01:05 PM | Beatriz Paniagua
RE: New analysis tool release and other questions
Hi Lucas,


Happy my previous response was helpful.

Albeit on a second thought, changing the orientation of the parametrization could probably get the meshes which are misaligned of about 180 degrees in the right spatial position, could'nt it?

Yes, it could. If you change the orientation of the parameterization that will result in different spatial orientation of the meshes, since the 3D points will be sampled from a parameterization with different orientation.
1) Computing a complete set of files with the 3D Slicer application by using the mean template and procrustes options; identifying bad aligned meshes in the viewer.
Yes, perfect.

2) Using the generated *para.vtk and *surf.vtk files for computing a *surfSPHARM.vtk file while changing the spatial alignment of the bad aligned meshes with ParaToSPHARMMesh.


Yes, this is a good idea. You will have to QC the different orientations to see which one fits the current template. In your first run of spharm I am assuming this will be the first mesh. A script like this can be run in a unix terminal to generate all possible flips for each missaligned case. If you dont want things to go crazy and have a lot of files generated, I suggest creating a directory and generating links or copying the surf.vtk and para.vtk files of the flipped cases there before running the script.
#!/bin/tcsh -f
foreach i (/pathtoGenParaMeshRESULTS/subjectID_pp_surf.vtk)
set j = $i:s/_surf.vtk/_para.vtk/
set out00 = $i:s/pp_surf.vtk/pp0_surf/
set out01 = $i:s/pp_surf.vtk/pp1_surf/
set out02 = $i:s/pp_surf.vtk/pp2_surf/
set out03 = $i:s/pp_surf.vtk/pp3_surf/
set out04 = $i:s/pp_surf.vtk/pp4_surf/
set out05 = $i:s/pp_surf.vtk/pp5_surf/
set out06 = $i:s/pp_surf.vtk/pp6_surf/
set out07 = $i:s/pp_surf.vtk/pp7_surf/
ParaToSPHARMMeshCLP $j $i $out00 --regTemplateFileOn --regTemplate /pathtotemplate/templateID_pp_surfSPHARM.vtk --flipTemplateOn --flipTemplate /pathtotemplate/templateID_pp_surfSPHARM.coef --subdivLevel 20 --spharmDegree 16 --FinalFlip 0 --paraOut --medialMesh
ParaToSPHARMMeshCLP $j $i $out01 --regTemplateFileOn --regTemplate /pathtotemplate/templateID_pp_surfSPHARM.vtk --flipTemplateOn --flipTemplate /pathtotemplate/templateID_pp_surfSPHARM.coef --subdivLevel 20 --spharmDegree 16 --FinalFlip 1 --paraOut --medialMesh
ParaToSPHARMMeshCLP $j $i $out02 --regTemplateFileOn --regTemplate /pathtotemplate/templateID_pp_surfSPHARM.vtk --flipTemplateOn --flipTemplate /pathtotemplate/templateID_pp_surfSPHARM.coef --subdivLevel 20 --spharmDegree 16 --FinalFlip 2 --paraOut --medialMesh
ParaToSPHARMMeshCLP $j $i $out03 --regTemplateFileOn --regTemplate /pathtotemplate/templateID_pp_surfSPHARM.vtk --flipTemplateOn --flipTemplate /pathtotemplate/templateID_pp_surfSPHARM.coef --subdivLevel 20 --spharmDegree 16 --FinalFlip 3 --paraOut --medialMesh
ParaToSPHARMMeshCLP $j $i $out04 --regTemplateFileOn --regTemplate /pathtotemplate/templateID_pp_surfSPHARM.vtk --flipTemplateOn --flipTemplate /pathtotemplate/templateID_pp_surfSPHARM.coef --subdivLevel 20 --spharmDegree 16 --FinalFlip 4 --paraOut --medialMesh
ParaToSPHARMMeshCLP $j $i $out05 --regTemplateFileOn --regTemplate /pathtotemplate/templateID_pp_surfSPHARM.vtk --flipTemplateOn --flipTemplate /pathtotemplate/templateID_pp_surfSPHARM.coef --subdivLevel 20 --spharmDegree 16 --FinalFlip 5 --paraOut --medialMesh
ParaToSPHARMMeshCLP $j $i $out06 --regTemplateFileOn --regTemplate /pathtotemplate/templateID_pp_surfSPHARM.vtk --flipTemplateOn --flipTemplate /pathtotemplate/templateID_pp_surfSPHARM.coef --subdivLevel 20 --spharmDegree 16 --FinalFlip 6 --paraOut --medialMesh
ParaToSPHARMMeshCLP $j $i $out07 --regTemplateFileOn --regTemplate /pathtotemplate/templateID_pp_surfSPHARM.vtk --flipTemplateOn --flipTemplate /pathtotemplate/templateID_pp_surfSPHARM.coef --subdivLevel 20 --spharmDegree 16 --FinalFlip 7 --paraOut --medialMesh
end

A script like this will generate different versions of each missaligned cases you will have to tease out. The flag that enforces a certain alignment in the parameterization is FinalFlip.

Then, you will have to load the surfSPHARM mesh and the Phi.txt and Theta.txt files. You can do that with MeshMath, using the KWMtoPolyData flag. 


MeshMath input.vtk outputwithScalars.vtk -KWMtoPolyData Phicolor.txt name_of_scalar_field_your_choice

3) Computing a mean template with MeshMath
Once you have all your meshes aligned well, I dont see why you should do this. You can do it and it might result into something more fine tuned, but you might have to go through the whole flipScript process again. You see, the flips happen because there is sometimes pathology that affects the shape and modifies what the program thinks its the first automatic alignment. I give you an example, we had a lateral ventricle analysis study in which some of the LVs were very very thin due to pathology in the front, and the program detected the long axis ok, but thought the pathologic fronts were tails, and hence aligned the shapes incorrectly. That is why we have the option to do the 3 axis flips (8 flips total) and select what is best.
 
4) Running the outcomes of 2) with 3) through ParaToSPHARMMesh

Again, this will not be necessary when you have gone through 1) and 2) as suggested.


I hope that helps.


Best,
Beatriz
May 12, 2016  09:05 AM | Lucas Fenger - Universität Würzburg
RE: New analysis tool release and other questions
Dear Beatriz,

this is VERY helpful. Thank you very much! I will try it out and see how it goes.


Best regards,

Lucas