spinalcordtoolbox / template-dog

Repository to create spinal cord template of dogs. Data from VirginiaTech.
0 stars 0 forks source link

Demonstrate that the dog template can be used for template-based registration #14

Open jcohenadad opened 7 months ago

jcohenadad commented 7 months ago

Context: https://forum.spinalcordmri.org/t/integrating-dog-template/1179/2

rohanbanerjee commented 7 months ago

Updating here, currently facing a few issues but I suspect it is due to the template cord labeling and template disc labeling (I'll explain below)

Using SCT latest version: git-master-29476b99e05d59a2b42ed7d20d4f40a58a53c497

The command I am using for this task is:

sct_register_to_template -i /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/bids_data/sub-HarshmanDobby/anat/sub-HarshmanDobby_T1.nii.gz -s /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/bids_data_updated/derivatives/labels/sub-HarshmanDobby/anat/sub-HarshmanDobby_T1_label-SC_seg.nii.gz -l /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/bids_data_updated/derivatives/labels/sub-HarshmanDobby/anat/sub-HarshmanDobby_T1_labels-disc_updated.nii.gz -t /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/template-dog/templatedog-r20240112/ -c t1 -s-template-id 2 -ofolder /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/register_op

I am using the template files from the latest release: https://github.com/spinalcordtoolbox/template-dog/releases/tag/v2.1

I am getting the following error: Exception: Error: number of source and destination landmarks are not the same, so landmarks cannot be paired.

When I investigated the temporary files created during the straightening during the registration, I found that template disc labeled values started from 2.0 and the cord labeling also started from the same place. The below image shows what I mean. It is missing the labels for the first disc.

Screenshot 2024-01-17 at 1 16 13 AM

I'm currently rectifying the above issue. Will keep updating here.

jcohenadad commented 7 months ago

-l /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/bids_data_updated/derivatives/labels/sub-HarshmanDobby/anat/sub-HarshmanDobby_T1_labels-disc_updated.nii.gz

"-l" refers to vertebral levels, whereas you are using disc labels ("-ldisc")

jcohenadad commented 7 months ago

if you have difficulties, maybe @joshuacwnewton can provide assistance.

rohanbanerjee commented 7 months ago

As mentioned above, I made changes to the template cord file, template disc level file and template vertebrae file. Along with this, I also used -ldisc instead of -l. This solved the above issue that I was facing.

The updated command I used for the registration is as follows:

sct_register_to_template -i /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/bids_data/sub-HarshmanDobby/anat/sub-HarshmanDobby_T2.nii.gz -s /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/bids_data_updated/derivatives/labels/sub-HarshmanDobby/anat/sub-HarshmanDobby_T2_label-SC_seg.nii.gz -ldisc /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/bids_data_updated/derivatives/labels/sub-HarshmanDobby/anat/sub-HarshmanDobby_T2_labels-disc_updated.nii.gz -t /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/template-dog/templatedog-r20240112/ -c t2 -s-template-id 2 -ofolder /Users/rohanbanerjee/Documents/research/neuropoly/dog_template_updated/register_op

The output of the registrations are as follows:

For t2,

template2anat
https://github.com/spinalcordtoolbox/template-dog/assets/25586344/91dbc7cb-ba7a-4993-a43f-18412995fd87
anat2template (Template is the copper overlay)
https://github.com/spinalcordtoolbox/template-dog/assets/25586344/6f7911f1-30a8-4e94-97da-c6bf2748424e

For t1,

template2anat
https://github.com/spinalcordtoolbox/template-dog/assets/25586344/6436492b-0f25-43fe-97c6-01efa352c4ee
anat2template
https://github.com/spinalcordtoolbox/template-dog/assets/25586344/4a8a1887-5ca5-476f-94a7-0fc8425aa2de

For t1, the anat2template registration (registration done with default parameters) does not produce great results.

Attaching all the above mentioned files: All template related files: https://drive.google.com/file/d/1UT2tqePQulXSopJwxAkpjdlytkewHT5e/view?usp=sharing

All registration related files: https://drive.google.com/file/d/1TNtpVcZZ45nWyxamPTMhTXJ-Vu5WJua5/view?usp=sharing

jcohenadad commented 7 months ago

clarification about disc labels:

Therefore, we CANNOT use the 26 labels disc file to register to the template.

that's fine, we will just do 2 labels.

my syntax to reproduce:


# only keep 2 disc labels
sct_label_utils -i ~/data.neuro/template_dog_virginiatech/derivatives/labels/sub-HarshmanDobby/anat/sub-HarshmanDobby_T2_labels-disc.nii.gz -keep 4,10 -o labels_4-10.nii.gz
# run registration (params not optimized)
sct_register_to_template -i ~/data.neuro/template_dog_virginiatech/sub-HarshmanDobby/anat/sub-HarshmanDobby_T2.nii.gz -s ~/data.neuro/template_dog_virginiatech/derivatives/labels/sub-HarshmanDobby/anat/sub-HarshmanDobby_T2_label-centerline.nii.gz -ldisc labels_4-10.nii.gz -t . -c t2 -s-template-id 2 -ofolder test_discs4-10 -param step=1,type=seg,algo=centermass:step=2,type=im,algo=syn,metric=CC,iter=3 -qc qc~~~

SCT version used: Spinal Cord Toolbox (git-jca/4298-flow-d396ad3a9090900cc62d4b6eb4ccbc6d63d4a6eb)