Functional images registration

Dear SCT team,

We are trying to register the mean functional image to the PAM50 using 2 steps: func2T1w and T1w2PAM50. The second step looks good (see video t1w2pam50) but we have some issues with the first one (see video func2pam50):

  1. First when defining the destination file (sct_register_multimodal ):
  • If we use t2 we have the cord is enlarged.
  • If we use t2s, I notice that the first slices of the template (around C1 level) are missing and I have registration problem for the corresponding slices
  1. We also tested two different combinations of parameters and had trouble finding the best compromise:
  • params_func_to_T1w = ‘step=1,type=seg,algo=centermass,metric=MeanSquares:step=2,algo=bsplinesyn,type=seg,slicewise=1,iter=3’
  • params_func_to_T1w=‘step=1,type=seg,algo=slicereg,metric=MeanSquares:step=2,type=seg,algo=affine,metric=MeanSquares,gradStep=0.2:step=3,type=im,algo=syn,metric=CC,iter=5,shrink=2’

Do you have any recommendation to improve our registration ?

Thank you !
Caroline

Hi @Caroline_Landelle,

My deepest apologies for the late response. I am writing to let you know that @jcohenadad is currently out of office, and will return on August 28th.

I will check in with other members of the lab to see if they can provide insight into your question. But, otherwise, I thank you for patience until Julien returns. :blush:

Kind regards,
Joshua

Hi Caroline, thank you for reaching out. I agree the T1wtoPAM50 registration looks good, and hopefully robust across your population. As for the GRE-EPI registration, it’s a bit hard for me to advise without looking at the data. If you could share 2-3 representative subjects, organised in BIDS format, I’ll look for an optimal solution.

Hi Julien,

Here is the link with images from 2 participants:
https://mcgill-my.sharepoint.com/:f:/g/personal/caroline_landelle_mcgill_ca/EsWegBtFAPNFsaC9tOr4DoUBPJ6B4_pWq4cFEORcDEFhEg?e=j66Y0v

I hope that I put everything you need for your tests let me know if you need other images.

Thank you a lot for you help

Hi Caroline,

Sorry for the slow response. I am looking at your data now, but I don’t see any script that I can use to reproduce your results and perform further optimization. Could you please send me your script that I can use with sct_run_batch to process the two subjects you shared?

Thanks,
Julien

Hi Julien,

it’s my turn to reply late! I’ve added a .sh script that can be run from the terminal + a readme file.
I’m not familiar with the sct_run_batch script and it would take me some time to use it so I hope this format works with you!

https://mcgill-my.sharepoint.com/:f:/g/personal/caroline_landelle_mcgill_ca/EsWegBtFAPNFsaC9tOr4DoUBPJ6B4_pWq4cFEORcDEFhEg?e=gg0f48

Thanks,
Caroline

Hi Caroline,

Few comments:

  • The pipeline was not end-to-end but assumed some preprocessing were done before, e.g. segmentation of cord on T1w, registration between T1w and PAM50 template, etc. It is important to always provide a comprehensive pipeline script to make sure results are reproducible. I wrote the full pipeline (see below).
  • Your script required manual interventions (eg: “SUBJECT=“sub-A011” # can be change by sub-006”), which is prone to human error. I made it fully automatic to run across a directory of subjects using sct_run_batch (see instructions below).
  • Your script did not include QC report generation. I strongly recommend using QC report generation to facilitate, systematize and make shareable the QC procedure, which is essential in any image analysis pipeline. I’ve added QC report generation in the script below.
  • Your script registered func–>T1w and then T1w–>PAM50. I recommend doing func–>PAM50, using the T1w–>PAM50 intermediate warping field, to minimize the accumulation of registration errors. See new script.
  • The new script registers using C2 and C5 vertebral levels. Please change according to the regions you are most interested in (eg: C4-C7).
  • I used a mask (dilated spinal cord) to improve the performance of the PAM50->func registration
  • The data are not BIDS-compatible, making the analysis script ‘custom’ and not shareable. For example, the suffix “_sc” in an image file under anat/ is not authorized: sub-A006_T1w_sc.nii.gz. See BIDS specification and online BIDS validator.
  • I encourage you to watch the latest SCT course, especially the part on analysis pipeline.

Here is the script you can download: coreg_func_julien.sh (7.3 KB)

Open a Terminal, go where your folder ‘data/’ is located and run (change YYYYMMDD_HHMMSS with whatever date/time you are running the pipeline):

sct_run_batch -script coreg_func_julien.sh -j -1 -path-data data -path-output results_YYYYMMDD_HHMMSS
Terminal output
julien-macbook:~/Desktop/OneDrive_1_9-1-2023 $ sct_run_batch -script coreg_func_julien.sh -j -1 -path-data data -path-output results_20230913_121913

--
Spinal Cord Toolbox (git-master-76c27e16f13974de3ff8f81e25c92abe8f6d80ec)

sct_run_batch -script coreg_func_julien.sh -j -1 -path-data data -path-output results_20230913_121913
--

INFO SYSTEM
-----------
OS: osx (macOS-10.16-x86_64-i386-64bit)
CPU cores: Available: 12 | Threads used by ITK Programs: 1
RAM: Total 16384 MB | Available 7230 MB | Used 7912 MB

INPUT ARGUMENTS
---------------
batch_log: sct_run_batch_log.txt
config: null
continue_on_error: 1
email_from: null
email_host: smtp.gmail.com:587
email_to: null
exclude: null
exclude_list: null
ignore_ses: false
include: null
include_list: null
itk_threads: 1
jobs: -1
path_data: data
path_output: results_20230913_121913
path_segmanual: .
script: coreg_func_julien.sh
script_args: ''
subject_prefix: sub-
v: 1
zip: false

SCRIPT
------
git commit: ?!?
git origin: ?!?
Copying script to output folder...
/Users/julien/Desktop/OneDrive_1_9-1-2023/coreg_func_julien.sh -> /Users/julien/Desktop/OneDrive_1_9-1-2023/results_20230913_121913/coreg_func_julien.sh
Setting execute permissions for script file coreg_func_julien.sh ...

DATA
----
git commit: ?!?
git origin: ?!?

RUNNING
-------
Processing 2 subjects in parallel. (Worker processes used: 11).
Started at 12h19m14s: sub-A006. See log file /Users/julien/Desktop/OneDrive_1_9-1-2023/results_20230913_121913/log/coreg_func_julien_sub-A006.log
Started at 12h19m14s: sub-A011. See log file /Users/julien/Desktop/OneDrive_1_9-1-2023/results_20230913_121913/log/coreg_func_julien_sub-A011.log

Hooray! your batch completed successfully :-)

Started: 12h19m14s | Ended: 12h28m56s | Duration: 00h09m42s


To open the Quality Control (QC) report in a web-browser, type:
open /Users/julien/Desktop/OneDrive_1_9-1-2023/results_20230913_121913/qc/index.html

QC report (open index.html): qc.zip (2.2 MB)

Comments on the results:

  • Automatic vertebral labeling failed for sub-A006, so this should be corrected manually. See function label_if_does_not_exist in the script. You just need to create 2 points and place them under the derivatives/labels folder. Also see Analysis pipeline — spine-generic documentation for inspiration about how to QC, manually correct, store corrections, and then use the corrections for re-running the analysis pipeline.
  • Cord segmentation for both subjects on the EPI scans need to be manually corrected (see previous point). This will positively impact the quality of the registration.

Hope that helps,
Julien

Dear Julien,
Thank you very much for taking the time to provide me an exemple and for these feedbacks,

  • You’re right I didn’t follow the standards because my initial image covered both brain and spinal cord in this dataset and I have to play with different toolboxes (SPM, FSL, SCT) in a single preprocessing Python script. I’ll try to improve the coding of the script for my next studies!
  • For the QC, I systematically check all images (brain + sc) with fsleyes after moco, segmentation, Coreg, denoising and also the tSNR improvement etc… (again, to have the same tool to examine QC for both brain and SC)
  • I have done the labelling of all vertebrae (I’m interested in all cervical spinal levels)
  • A careful manual correction of the segmentation (T1w and func) was done before the coreg step.
  • Sorry, I had to change a little the BIDS format and include an additional level that I named “structure” to distinguish the brain or sc (spinal cord) after cropping my inital images in two. That is why I have the sub??_T1w_sc.nii.gz and the sub??_T1w_brain.nii.gz images for each individual. I hope to find a better standard in the future!
  • Thank you for pointing out the courses I’m going to improve my brain and spinal cord pipeline and trying to find a standard that matches as much as possible both the brain and spinal cord communities!
  • Finally, your recommendation func > PAM50 using func>T1w intermediate warping field was a great solution! It improves my coregistration. I have done some tests and the coregistration looks a little better when I’m using PAM50_t2s compared to PAM50_t2, except for the upper slices (z>960). In fact, these slices are missing in PAM50_t2s. Do you have a complete version of the PAm50_t2s image so I can test it on the entire cervical SC?

Thank you very much for your help !
Caroline

Unfortunately I don’t. The PAM50 was built with the T2w data and coverage available at that time. However the T2w is pretty close to the T2w in terms of contrast, so I recommend you use the T2w for registration if you need coverage above z=960

Dear Julien,
Thank you once more for your help.
I will then use the PAM50_t2 image

Caroline

1 Like