# SPHARM PDM Correspondence improvement

**URL:** <https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897>\
**Category:** SlicerSALT\
**Created:** [June 16, 2022, 4:09am UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897 "2022-06-16T04:09:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lili-yu22](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@lili-yu22](https://discourse.slicer.org/u/lili-yu22)\
**Post date:** [June 16, 2022, 4:09am UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/1 "2022-06-16T04:09:33Z")

</div>

Slicer salt3.0，windows10  
when I use“ spharm-pdm correspondence improvement ”the python show "OSError：Invalid argument：“C：//users//…//2022—06—16T11:51:18.762701.csv”.  
the input models directory: i use the\*SPHARM.vtk.  
the input fiducial files directory :i use the makeup model to define the landmark on the "SPHARM.vtk"model  
Common unit sphere directory：i use only one “para.vtk”file  
can anyone tell me what’s wrong，thank you

---

<div class="post-metadata">

**Author:** ![SAO](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sao/32/16036_2.png) [@SAO](https://discourse.slicer.org/u/SAO)\
**Post date:** [July 20, 2022, 12:19pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/2 "2022-07-20T12:19:43Z")

</div>

Hello everyone.

**I am facing the same issue - unfortunately.**  
Currently, I am using SlicerSALT software version 3.0.0-2022 - GUI. Operating system: Windows 10

I have already generated the correspondence for all shapes; however, further improvement to the correspondence is needed before running “Covariant significant testing” and “Population Analysis” modules.

After uploading the required material into the _SPHARM PDM Correspondence improvement module_ [I got no response - and no error message].

**The material uploaded into the "_SPHARM PDM Correspondence improvement" module_ include:**

```
*Input models directory*: all models with *SPHARM.vtk extension.
*Input fiducial files directory*: I used the markeup module along with ALPACA module to automate the process of generating of landmarks for "SPHARM.vtk" models in my sample. The landmark files was saved as (.FCSV file).
*Common unit sphere directory*：I used one of the “para.vtk” file generated after running the SPHARM-PDM generator module.

```

It will be helpful if someone can share with us his knowledge regarding this pipeline, and how to correct it.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![bpaniagua](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bpaniagua/32/20_2.png) [@bpaniagua](https://discourse.slicer.org/u/bpaniagua)\
**Post date:** [July 20, 2022, 12:25pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/3 "2022-07-20T12:25:24Z")

</div>

@Connor-Bowley could you please take a look into this problem? Thank you!

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [July 20, 2022, 12:43pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/4 "2022-07-20T12:43:59Z")

</div>

I will look into this, but I may not have something until next week.

---

<div class="post-metadata">

**Author:** ![SAO](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sao/32/16036_2.png) [@SAO](https://discourse.slicer.org/u/SAO)\
**Post date:** [July 20, 2022, 12:48pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/5 "2022-07-20T12:48:27Z")

</div>

Thanks for your prompt response @bpaniagua and @Connor-Bowley.

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [July 26, 2022, 9:00pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/6 "2022-07-26T21:00:18Z")

</div>

Still looking into this, but I noticed the tutorial wasn’t linked properly. There is a tutorial [here](https://bit.ly/2WsFiun) that may be of some use.

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [July 27, 2022, 8:42pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/7 "2022-07-27T20:42:37Z")

</div>

I have found and fixed a couple problems with this module on Windows and am working to get the fixes into the mainline SlicerSALT build.

Next steps (for me):

1. Pull request into RigidAlignment: [Run on windows by Connor-Bowley · Pull Request #8 · NIRALUser/RigidAlignment · GitHub](https://github.com/NIRALUser/RigidAlignment/pull/8)
2. Open a pull request into [GROUPS](https://github.com/NIRALUser/GROUPS) with the branch [GitHub - Connor-Bowley/GROUPS at run-on-windows](https://github.com/Connor-Bowley/GROUPS/tree/run-on-windows), updated to to include the RigidAlignment change
3. Open a pull request into [SlicerSALT](https://github.com/Kitware/SlicerSALT) with the updates from above.

---

<div class="post-metadata">

**Author:** ![SAO](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sao/32/16036_2.png) [@SAO](https://discourse.slicer.org/u/SAO)\
**Post date:** [August 1, 2022, 2:33pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/8 "2022-08-01T14:33:58Z")

</div>

Thanks for your informative feedback @Connor-Bowley.

Additionally, I also noticed that “Correspondance Improvment” section in the _SHARM-PDM Generator_ module is not working properly even after uploading the required material !

 ![Screenshot (668)](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/1/d16fab4bd0f498ef5421561ab1576afd40d4579b.jpeg)

We will be able to proceed with our data processing - using SlicerSALT modules - in Windows - once these issues is fixed. Hopefully soon.

Thanks again for your hard work.

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [September 16, 2022, 1:01pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/9 "2022-09-16T13:01:19Z")

</div>

I opened the following pull request into the SlicerSALT repo that should fix this problem.

> <https://github.com/Kitware/SlicerSALT/pull/278>

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [September 20, 2022, 3:32pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/10 "2022-09-20T15:32:14Z")

</div>

This issue should be fixed in `SlicerSALT-3.0.0-2022-09-16` which can be downloaded by going to [Download • SlicerSALT](http://salt.slicer.org/download/), clicking `Visit Girder -> Nightly -> SlicerSALT-3.0.0-2022-09-16-win-amd64.exe`. Please try it out and let me know if you are still having problems.

---

<div class="post-metadata">

**Author:** ![SAO](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sao/32/16036_2.png) [@SAO](https://discourse.slicer.org/u/SAO)\
**Post date:** [November 1, 2022, 5:50am UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/11 "2022-11-01T05:50:50Z")

</div>

Thanks alot for your hard work @Connor-Bowley  
I will use SlicerSALT (latest version), and let you know if there is a problem.

---

<div class="post-metadata">

**Author:** ![Hoai-Nam\_Bui](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hoai-nam_bui/32/15877_2.png) [@Hoai-Nam\_Bui](https://discourse.slicer.org/u/Hoai-Nam_Bui)\
**Post date:** [January 16, 2023, 9:37pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/12 "2023-01-16T21:37:22Z")

</div>

Hello!

@SAO I was wondering if you were able to get your Correspondence improvement module to work with the latest version of SlicerSalt? It seems I am running into a problem similar to yours.

I have about 50 shapes but was forerunning with two to figure out the workflow.

I pathed:

Input Models Directory: a folder with the 2 models with the vtk extension  
Fiducial files directory: a folder with 2 separate fcsv’s (should I be merging them?)  
Common unit sphere: a folder with one of the para.vtk files

Upon running, I also get no response nor an error message. I’m wondering if I need to format/name the fcsv’s with the same name as my models? Or change something within the file itself?

I’ve also been using the tutorial that @Connor-Bowley had linked above. Thank you!

---

<div class="post-metadata">

**Author:** ![SAO](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sao/32/16036_2.png) [@SAO](https://discourse.slicer.org/u/SAO)\
**Post date:** [January 18, 2023, 8:12am UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/13 "2023-01-18T08:12:34Z")

</div>

Dear @Connor-Bowley, @Hoai-Nam_Bui, and @bpaniagua,  
I hope you all doing well.

Actually, I am still facing the same issue - even with the latest version of [SlicerSALT 4.0.1](https://discourse.slicer.org/t/slicersalt-4-0-1-summary-highlights-and-changelog/26197).

**After uploading the required material [I got no response - and no error message].**

I agree with you that there is a need for detailed-tutorial, with a case, that outline the pipeline for the “correspondence improvement module”.

All the best.

Regards,  
Sultan

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [January 18, 2023, 4:44pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/14 "2023-01-18T16:44:48Z")

</div>

So I am looking into this again and have found a problem which I am looking into resolving. The problem did not occur on my original data I was using to test the module because that data was generated with an old version of SALT.

Hopefully I will have a resolution in the next couple of days.

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [January 23, 2023, 10:29pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/15 "2023-01-23T22:29:37Z")

</div>

I have a fix and have the started the work to integrate it into SlicerSALT. In short, there was a bug when reading the newer file format verison for `.vtk` files. My data I used to test during the original fix was an old enough version of the `.vtk` format that it didn’t cause the problem.

> <https://github.com/NIRALUser/GROUPS/pull/41>
>
> Updates MeshLib to version that fixes a bug where newer .vtk files would be read… incorrectly, causing a segfault in RigidAlignment.
> 
> Pointing this to the new slicersalt fork of MeshLib so we can get this fix into SALT while https://github.com/ilwoolyu/MeshLib/issues/12 is being sorted out.
> 
> cc @vicory

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [January 25, 2023, 1:32pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/16 "2023-01-25T13:32:38Z")

</div>

Found another small bug that is working its way through reviews. Will let you know when everything is through and SALT gets updated.

To answer some questions @Hoai-Nam_Bui asked about naming:

When using the SPHARM-PDM Correspondence Improvement module:

- The models **must** be named `<some-name>_pp_surf_SPHARM.vtk`
- The corresponding fiducials **must** be named `<some-name>_fid.fcsv`
- The spheres folder only needs 1 sphere and it **must** be named `<something>_surf_para.vtk`

The `<some-name>` for a model and its corresponding fiducial should match exactly.  
(e.g. `subject1_pp_surf_SPHARM.vtk` and `subject1_fid.fcsv`)

The `<something>` for the sphere is not required to match any of the `<some-name>`s.

When using SPHARM-PDM / Shape Analysis Module with the `Correspondence Improvement -> Enable Correspondence Improvement` checkbox checked, SPHARM will make sure the models and sphere are named correctly, you just need to worry about the fiducials.

The tutorial is definitely not clear about this. I had to go look at the [source code](https://github.com/NIRALUser/GROUPS/blob/71daa95a831e35b3995db64a82a2c7f8646c9148/Modules/Scripted/RigidAlignmentModule/RigidAlignmentModule.py#L101-L103) to understand the naming requirements. I think the assumption is because SPHARM outputs the files in this way and this is SPHARM correspondence improvement the files should just be named appropriately. I have added [this issue](https://github.com/NIRALUser/GROUPS/issues/43) to track this problem.

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [January 27, 2023, 2:10pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/17 "2023-01-27T14:10:12Z")

</div>

The bugs were fixed and those fixes are incorporated in the latest nightly build of SlicerSALT, SlicerSALT-4.0.1-2023-01-25, which can be found on Girder [here](https://data.kitware.com/#collection/586fbb7b8d777f05f44a5c7b/folder/5bd85a568d777f06b9402dad).

@Hoai-Nam_Bui @SAO Please try downloading this updated version of SALT and see if it works for your data (keeping the naming requirements detailed above in mind). If it does not work, please go to the “SPHARM-PDM Generator” module, click `Tutorials -> Correspondence Improvement (this will download sample data) -> Run ShapeAnalysisModule` let run (it may take ~45 minutes) and see if produces any errors.

For reference, here is the pull request bringing the fixes into SALT:

> <https://github.com/Kitware/SlicerSALT/pull/292>
>
> GROUPS changes: git shortlog --no-merges 1263afc12..387bc83ad
> 
> Connor Bowley (…2):
> BUG: Fix running with new vtk files
> BUG: Update RigidAlignment

---

<div class="post-metadata">

**Author:** ![SAO](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sao/32/16036_2.png) [@SAO](https://discourse.slicer.org/u/SAO)\
**Post date:** [January 29, 2023, 4:31am UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/18 "2023-01-29T04:31:43Z")

</div>

Thanks for your hard work @Connor-Bowley.Your informative response is highly appreciated.  
I will download the updated version of SALT(SlicerSALT-4.0.1-2023-01-25), and see if it works for my data, soon.

All the best to everyone.

Regards,  
Sultan

---

<div class="post-metadata">

**Author:** ![Hoai-Nam\_Bui](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hoai-nam_bui/32/15877_2.png) [@Hoai-Nam\_Bui](https://discourse.slicer.org/u/Hoai-Nam_Bui)\
**Post date:** [February 5, 2023, 6:17pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/19 "2023-02-05T18:17:26Z")

</div>

Hi @Connor-Bowley, thanks so much for your hard work. I believe your fixes are running successfully!

I have a relatively large sample to align, but here are the results of two shapes with 9 landmarks.  
I was hoping that 9 landmarks would be sufficient but I am assuming that due to their non-aligned alignment that I most likely need more? Your thoughts would be greatly appreciated!

Thanks again for everything.

 ![Screenshot 2023-02-05 at 1.14.05 PM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/1/21f3df22c9b1b57df433dd63fe8abba354b4f75a.jpeg)

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [February 13, 2023, 4:31pm UTC](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897/20 "2023-02-13T16:31:04Z")

</div>

Hi @Hoai-Nam_Bui,

`SPHARM-PDM Correspondence improvement` is a module that improves point-wise correspondence between meshes. It takes a unit sphere from the `SPHARM-PDM/Shape Analysis Module` work and rigidly aligns the sphere-mapped landmarks from each mesh onto the input sphere, and remeshes the models based on that. This has the effect of changing the point numbering and cell numbering of the different meshes to be in correspondence _without_ changing the actual geometries or any of the actual point locations.

For doing the physical alignment after the correspondence improvement, you could take the output of the `SPHARM-PDM Correspondence improvement` and run it through something like the `Procrustes Registration` module (under `Shape Analysis`). Note that for the `Procrustes Registration` module to work, the meshes must be in point correspondence (which they will be coming out of the `SPHARM-PDM Correspondence improvement` module).

I hope this helps.

[Next page](https://discourse.slicer.org/t/spharm-pdm-correspondence-improvement/23897.md?page=2)
