neuropoly / idea-projects

Ideas for cool projects
1 stars 0 forks source link

Co-registration of longitudinal data #17

Open valosekj opened 1 year ago

valosekj commented 1 year ago

This post summarizes notes from our (@valosekj, @sandrinebedard, @jcohenadad) meeting with Roland Henry (UCSF) at ISMRM 2023.

Roland is interested in the intra-subject co-registration of longitudinal data in MS patients (i.e., data across different time points).

He has axial and sagittal images from 10-time points. Images should have similar parameters across time points.

Interesting points to explore:

The ideas could be tested on spine-generic/data-single-subject dataset (we have already computed C2-C3 CSA in the native space).

TODO:

sandrinebedard commented 1 year ago

I've tested the suggestion of @benjamindeleener to use sct_straighten_spinalcord with the option -dest

Using this dataset: https://openneuro.org/datasets/ds004507/versions/1.0.1, trying to align the head position headUp (right) to headNormal (left).

image

Here is the description of -dest

 -dest <file>     Spinal cord centerline (or segmentation) of a destination image (which could be straight or 
 curved). An algorithm scales the length of the input centerline to match that of the destination centerline. 
 If using -ldisc-input and -ldisc-dest with this parameter, instead of linear scaling, the source centerline will
  be non-linearly matched so that the inter-vertebral discs of the input image will match that of the 
  destination image. This feature is particularly useful for registering to a template while accounting for disc
   alignment
  1. Tried using -dest
    sct_straighten_spinalcord -i sub-003/ses-headUp/anat/sub-003_ses-headUp_T2w.nii.gz -s derivatives/labels/sub-003/ses-headUp/anat/sub-003_ses-headUp_T2w_seg-manual.nii.gz -dest derivatives/labels/sub-003/ses-headDown/anat/sub-003_ses-headDown_T2w_seg-manual.nii.gz -x linear -qc ./qc

    It failed:

Traceback (most recent call last):
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_straighten_spinalcord.py", line 278, in <module>
    main(sys.argv[1:])
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_straighten_spinalcord.py", line 261, in main
    fname_straight = sc_straight.straighten()
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/straightening.py", line 453, in straighten
    coord_straight2curved = centerline.get_inverse_plans_coordinates(coord_in_planes_straight, lookup)
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/types.py", line 330, in get_inverse_plans_coordinates
    return einsum('mnr,nr->mr', rollaxis(self.matrices[indexes], 0, 3), coordinates.transpose()).transpose() + self.points[indexes]
IndexError: index 243 is out of bounds for axis 0 with size 243
  1. Adding the discs labels of input and dest:
    sct_straighten_spinalcord -i sub-003/ses-headUp/anat/sub-003_ses-headUp_T2w.nii.gz -s derivatives/labels/sub-003/ses-headUp/anat/sub-003_ses-headUp_T2w_seg-manual.nii.gz -dest derivatives/labels/sub-003/ses-headNormal/anat/sub-003_ses-headNormal_T2w_seg-manual.nii.gz -x linear -qc ./qc -ldisc-input derivatives/labels/sub-003/ses-headUp/anat/sub-003_ses-headUp_T2w_labels-disc-manual.nii.gz -ldisc-dest derivatives/labels/sub-003/ses-headNormal/anat/sub-003_ses-headNormal_T2w_labels-disc-manual.nii.gz

    It worked! 🎉

gif_straighten (croped is headUp in the spinal cord curvature of head normal)

benjamindeleener commented 1 year ago

Awesome! Some details about the method: when providing the labels, the registration algorithm will map the two sets of labels. When the user does not provide any set of labels, the registration algorithm will map the two curves based on length, but it doesn't make sense if the two curves do not start at the same (upper) location. In addition, I usually experience some errors with this algorithm (when only providing the curves.

This algorithm is great for intra- and inter-subject registration while preserving the axial topology of the structures. It can be used for registration to a template, for intra-subject inter-modality registration as well as motion correction. The processing time depends on the image size and resolution, but it can be used on any 3D image.