Registration of template to DWI

Hi Julien,

I have some DWI data and need to do all related quantifications using SCT. I exactly run all the commands related to DWI, but it seems that in the registration part, it cannot register the template to DWI (maybe because of cropping, although I tried it without cropping, the registration result did not change). I tried to change the -param flag’s settings as well, changed the algorithms, iterations, slicewise, no slicewise, and everything that I thought might change the result. but it just cannot get properly registered. It shows me the result, but it is not correct. I would really appreciate it if you can guide me and suggest anything that can make it work. I tried whatever I could, but did not reach the proper result for DWI data.
P.S. I attached the figure that I see in the registration stage.

Thank you very much.

1 Like

Hi @Maryam,

Thank you for reaching out. Easiest would be for you to share the relevant data, as well as your processing script that led you to these results, and the SCT version you are running.

If you prefer to not publicly share the data you can email me a private download link.

Cheers,
Julien

Thank you very much Julien. I shared a link with you. I would really appreciate if you can add any point to solve this issue.

Regards,
Maryam

Hi Maryam,

I had a look at what you sent-- a few comments:

  • the script should be a shell file (not txt), and by running this script i should be able to reproduce exactly what you did. This is currently not possible because the syntax inside the script does not match your folder/file naming structure;
  • along with the previous point: please organize your data under the BIDS convention. See example here;
  • please let me know which sct version you are running
  • please add your SCT QC report in the package you want me to look at (use -qc flag with your SCT commands)

Best,
Julien

Hi Julien,

I updated the link and sent it. All your points are considered now. Just by running the shell file, the results will be produced. To make it easier to check, I just included the name of the first dwi image in the shell file. But it can be edited for other images too. Thank you so much for taking your time.

Regards,
Maryam

Hi Maryam,

  • The QC folder you sent me was empty,
  • Please let me know which version of SCT you are running,
  • line 19 of your script:
sct_register_multimodal -i $SCT_DIR/data/PAM50/template/PAM50_t1.nii.gz -iseg $SCT_DIR/data/PAM50/template/PAM50_cord.nii.gz -d dmri_crop_moco_dwi_mean.nii.gz -dseg dmri_crop_moco_dwi_mean_seg.nii.gz -param step=1,type=seg,algo=centermass:step=2,type=seg,algo=bsplinesyn,slicewise=1,iter=3 -initwarp $SCT_DIR/sct_example_data/t2s/warp_template2t2s.nii.gz -initwarpinv $SCT_DIR/sct_example_data/t2s/warp_t2s2template.nii.gz -qc ./qc

This will not work because you are inputing a warping field which comes from another dataset (sct_example_data). You need to estimate a warping field between the PAM50 template and your subject (via an anatomical scan of your subject), and then input it here. I recommend you look at the processing script for the spine-generic project, which explains all this.

Also: the script you sent me cannot properly be run across multiple subjects because subject’s folder is hard-coded in the script. I strongly recommend you make your script subject-agnostic (which is the purpose of the BIDS convention). That way you will be able to run processing across 500 subjects with only one script (vs. 500 scripts, which is more difficult to maintain).

To help you, I’ve made a script that does the first part of the DWI processing. The rest of the processing (registration to template) will need to be figured out based on the other data you have (anatomical). Here it is: scripts_20200420152855.zip (2.4 KB)
After unzipping, move those scripts in the directory that encloses your folder dataset, then run:

sct_run_batch parameters.sh process_dwi.sh

Note that the script fails for subject sub-c2, which does not follow the convention (i.e., the dwi data should be called “sub-c2_dwi.nii.gz”, not “sub-c2_run-XX_dwi.nii.gz”).

Cheers,
Julien

2 Likes

Hi Julien,

Thank you very much for your guidance. As you pointed out, I estimated the warping field between the PAM50 template and my subject through an anatomical scan of my subject, and the registration now seems good.
Yes, I will make my script subject-agnostic to be able to run multiple processing with it.
Also, I am using SCT version 4.2.1.

Regards,
Maryam

2 Likes

I am currently trying to analyse DMRI data using spinalcordtoolbox commands as suggested by the tutorial online. Everything has gone smoothly until we have gotten to the warping to PAM50 template command:

sct_warp_template -d dmri_moco_dwi_mean.nii -w warp_template2dmri.nii.gz -qc …/qc

Basically, the warping templates are either incomplete or not accurately aligned with the cord. I wonder whether the sct_register_multimodal has worked properly either.

It is worth noting that the dmri data was acquired using ZOOMit as suggested by the generic acquisition protocol, and the FOV/slice acquisition of the T2 and DWI images are different.

I used mcverter to convert the dicom files to nifti before preprocessing with sct toolbox using command: mcverter -o . -f fsl -n -d SubjDir/

Also, in regards to the sform and qform, whilst labelling th vertebrae in t2 Ubuntu would not let me label the vertebrae without running the sform command: sct_image -i (t2.nii or t2_seg.nii) -set-sform-to-qform

we have corrected some labelling that was incorrect and this also has not fixed the issue with warping. i assume the incorrect warping is preventing us from extracting our data and when running the command:

sct_extract_metric -i dti_FA.nii.gz -f label/atlas
-l 51 -method map
-vert 2:9 -vertfile label/template/PAM50_levels.nii.gz -perlevel 1
-o fa_in_wm29.csv
chunks of the spinal cord data are missing from the output files

I am unsure of how to resolve this issue if anyone has any solutions it would be much appreciated.
i have also attached a zip of one of the qc reports where the warping is especially bad.
qczip.zip (1.9 MB)

qczip.zip (1.5 MB)

thanks!
Alex

Hi Alex, I suspect your way of converting the DICOM to NIfTI files causes a problem in the q/sform of your data, as already mentioned here Trouble warping to template - #29 by jcohenadad.

Can you try converting your data using dcm2niix and see if it solves the issue?

Also, in the future, can you please post as a new thread (instead of continuing on an existing thread), because the underlying source of the issue is different in your case vs. in the case of the original post. Thank you for your understanding.