Cervical images(brain data) normalization

Hi there again!

We were wondering which would be the “best” way to normalize a cervical MRI.
Something similar to this

At the same time, does a template including brain+spinal cord exist?
Because the PAM template includes only SC and there is a plenty of templates including only
the brain.

thanks,

aran

We were wondering which would be the “best” way to normalize a cervical MRI.
Something similar to this

What do you mean by “normalize”? Are you referring to the normalization of the computed CSA (e.g. accounting for independent variables such as heigh, neck size, etc.), or to the spatial normalization to a 3D template?

At the same time, does a template including brain+spinal cord exist? Because the PAM template includes only SC and there is a plenty of templates including only the brain.

Yes, as described in this paper (see Figure 4), the PAM50 template shares the same physical coordinate system as the MNI brain template (ICBM152). An example of brain-cspine analysis is demonstrated in this post.

Best,
Julien

Good morning,

By normalize we meant the spatial normalization to the 3D template.
Now we will try to fuse/join the MNI brain template with the PAM50.
I had not found it before…

And the code showed in this post is a little bit outdated :grimacing:
Specifically, the sct_crop_image lines, the

-dim -start XX -end YY

should be renamed to (I believe)

-xmin XX -end YY

And there is also an inconsistency between the numbers of the sct_crop_image orders. We end up either with this error

 extop@~/Desktop/uniden$ sct_maths -i MNI152_T1_0.5mm_pad_crop.nii.gz -add PAM50_t1_reg_norm_crop.nii.gz -o MNI152_PAM50_T1_0.5mm.nii.gz


Spinal Cord Toolbox (4.2.1)

Traceback (most recent call last):
  File "/home/extop/sct_4.2.1/scripts/sct_maths.py", line 774, in <module>
    main()
  File "/home/extop/sct_4.2.1/scripts/sct_maths.py", line 277, in main
    data_concat = concatenate_along_4th_dimension(data, data2)
  File "/home/extop/sct_4.2.1/scripts/sct_maths.py", line 554, in concatenate_along_4th_dimension
    return np.concatenate((data1, data2), axis=3)
  File "<__array_function__ internals>", line 6, in concatenate
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 2, the array at index 0 has size 334 and the array at index 1 has size 311

Or with one template over/above the other one :slightly_frowning_face:

Hi @Aran,

I’m sorry about the late response.

Yes, as you rightly pointed out, some of the commands in this post are outdated. The sct_crop_image command however takes the following input arguments (no more -end):

  -xmin <int>  Lower bound for cropping along X.
  -xmax <int>  Higher bound for cropping along X. Setting '-1' will crop to the maximum dimension
               (i.e. no change), '-2' will crop to the maximum dimension minus 1 slice, etc.
  -ymin <int>  Lower bound for cropping along Y.
  -ymax <int>  Higher bound for cropping along Y. Follows the same rules as xmax.
  -zmin <int>  Lower bound for cropping along Z.
  -zmax <int>  Higher bound for cropping along Z. Follows the same rules as xmax.

There was indeed a bug in sct_crop_image, but it has just been fixed today. More info here. The fix will be part of SCT v4.2.2 but you can already get the working version from Github’s master branch.

Please try again with the fixed version and let us know if you still experience the error.

Best,
Julien

Hello @jcohenadad,

Do not worry, all you do is help!

I believe there might be another problem with the -b option this time.
It looks like the sct_crop_image does not recognize the option?
Meaning, it crops the image to the introduced limits, but it does not maintain the original dimensions
nor sets the voxels outside the bounding box to the specified value.

Can you confirm it?

Nonetheless, we were able to obtain the image correctly adjusted.
Now,

 sct_register_to_template -i T1.nii.gz -s T1_seg.nii.gz -c t1 -ldisc labels.nii.gz -t DirectoryToNewAtlas

--
Spinal Cord Toolbox (dev)

Traceback (most recent call last):
  File "/home/extop/sct_dev/scripts/sct_register_to_template.py", line 807, in <module>
    main()
  File "/home/extop/sct_dev/scripts/sct_register_to_template.py", line 263, in main
    file_template_labeling = get_file_label(os.path.join(path_template, 'template'), id_label=7)  # label = spinal cord mask with discrete vertebral levels
  File "/home/extop/sct_dev/spinalcordtoolbox/metadata.py", line 203, in get_file_label
    il.load(fname_label)
  File "/home/extop/sct_dev/spinalcordtoolbox/metadata.py", line 53, in load
    file = io.open(file, "rb")
FileNotFoundError: [Errno 2] No such file or directory: DirectoryToNewAtlas/template/info_label.txt'

And if we copy the info_label.txt from the SCT_DIR, another bunch of errors appear… :weary:

Thanks,
aran

Hi Aran,

You are right, there is a bug. I’ve opened a ticket here. We will fix it very soon. Thank you very much for reporting it!

Julien

Regarding your other error (related to sct_register_to_template), this is because you are pointing to a template structure that is missing the file info_label.txt. All other templates should follow the same structure as PAM50 (i.e. have a subfolder template and atlas, with the appropriate files in it).

Now, the key question is: how would you like to use the merged MNI-PAM50 template for? You cannot simply run sct_register_to_template if you would like to consider the brain as well, because brain data should not be processed using spinal cord-specific algorithms (e.g., the concept of “straightening” does not make sense for brain data).

Previous users who wanted to use this merged brain/spine template did it after processing spinal cord images: brain/spine data were split at the brainstem level, brain data were processed using brain pipelines (FSL, SPM, etc.) while spinal cord data were processed using SCT. Once separate processing was done (e.g., first-level analysis of fMRI, diffusion tensor, etc.), each separate warping field was applied to each separate structure, and the single target image (i.e. the flag -d in sct_apply_transfo) for both the brain and spinal cord data was the merged MNI-PAM50 template.