Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

SCT Toolbox

Run this notebook

Author: Steffen Bollmann

Date: 17 Oct 2024

License:

MIT License

Note: If this notebook uses neuroimaging tools from Neurocontainers, those tools retain their original licenses. Please see Neurodesk citation guidelines for details.

Citation and Resources:

Tools included in this workflow

Spinal Cord Toolbox

  • Valošek, J., & Cohen-Adad, J. (2024). Reproducible spinal cord quantitative MRI analysis with the Spinal Cord Toolbox. Magnetic Resonance in Medical Sciences, 23(3), 307-315. Valošek & Cohen-Adad (2024)

Workflows this work is based on

Demonstrating the Spinal Cord Toolbox (SCT) use via Neurodesk

In Neurodesk we can use module to load specific versions of tools. Here we load the spinalcordtoolbox in a specific version:

['spinalcordtoolbox/5.8']

In this interactive notebook we will go through a series of processing steps specific to spinal cord MRI analysis. We first need to import the necessary tools and setup the filenames and folders in the notebook environment.

The rest of this notebook is copied from the neurolibre project with minor path modifications and code adjustments to work with the current version of SCT


--
Spinal Cord Toolbox (5.8)

sct_download_data -d sct_example_data -o ./sct_example_data
--

Removing existing destination folder 'sct_example_data'
Trying URL: https://github.com/spinalcordtoolbox/sct_example_data/releases/download/r20180525/20180525_sct_example_data.zip
Downloading: 20180525_sct_example_data.zip
Status: 100%|██████████████████████████████| 44.3M/44.3M [00:03<00:00, 12.9MB/s]
Creating temporary folder (/tmp/sct-20260409013851.300573-wkiwq92d)
Unzip data to: /tmp/sct-20260409013851.300573-wkiwq92d
Copying data to: sct_example_data
Removing temporary folders...
Done!

The first processing step consists in segmenting the spinal cord. This is done automatically using an algorithm called Optic that finds the spinal cord centerline, followed by a second algorithm called DeepSeg-SC that relies on deep learning for segmenting the cord.


--
Spinal Cord Toolbox (5.8)

sct_deepseg_sc -i t1w.nii.gz -c t1 -qc /home/jovyan/workspace/books/examples/structural_imaging/qc
--

Config deepseg_sc:
  Centerline algorithm: svm
  Brain in image: True
  Kernel dimension: 2d
  Contrast: t1
  Threshold: 0.15
Creating temporary folder (/tmp/sct-20260409013906.675189-0w39df9o)
Reorient the image to RPI, if necessary...
Finding the spinal cord centerline...
Creating temporary folder (/tmp/sct-20260409013907.678994-anu9bnln)
Remove temporary files...
rm -rf /tmp/sct-20260409013907.678994-anu9bnln
Cropping the image around the spinal cord...
Normalizing the intensity...
Segmenting the spinal cord using deep learning on 2D patches...
Reassembling the image...
Resampling the segmentation to the native image resolution using linear interpolation...
Binarizing the resampled segmentation...
Image header specifies datatype 'float32', but array is of type 'uint8'. Header metadata will be overwritten to use 'uint8'.
Compute shape analysis: 100%|#################| 17/17 [00:00<00:00, 29.87iter/s]
Remove temporary files...
rm -rf /tmp/sct-20260409013906.675189-0w39df9o

*** Generate Quality Control (QC) html report ***
Resample images to 0.6x0.6 mm
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
QcImage: layout with Axial slice
Compute center of mass at each slice
/opt/spinalcordtoolbox-5.8/python/envs/venv_sct/lib/python3.8/site-packages/scipy/ndimage/_measurements.py:1407: RuntimeWarning: invalid value encountered in double_scalars
  results = [sum(input * grids[dir].astype(float), labels, index) / normalizer
/home/jovyan/workspace/books/examples/structural_imaging/qc/structural_imaging/sct_example_data/mt/sct_deepseg_sc/2026_04_09_013914.187248/bkg_img.png
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/css/bootstrap-table.min.css /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/css
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/css/bootstrap.min.css /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/css
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/css/bootstrap-theme.min.css /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/css
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/css/style.css /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/css
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/css/select2.min.css /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/css
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/css/bootstrap.min.css.map /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/css
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/js/yaml.min.js /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/js
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/js/bootstrap-table.min.js /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/js
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/js/animation.js /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/js
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/js/bootstrap.min.js /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/js
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/js/select2.min.js /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/js
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/js/main.js /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/js
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/js/jquery-3.1.0.min.js /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/js
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/js/filesaver.min.js /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/js
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/imgs/axial.png /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/imgs
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/imgs/sct_logo.png /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/imgs
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/imgs/f-icon.png /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/imgs
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/imgs/keyright.png /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/imgs
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/imgs/keydown.png /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/imgs
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/imgs/keyup.png /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/imgs
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/imgs/sagittal.png /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/imgs
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/fonts/glyphicons-halflings-regular.woff2 /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/fonts
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/fonts/glyphicons-halflings-regular.eot /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/fonts
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/fonts/glyphicons-halflings-regular.svg /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/fonts
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/fonts/glyphicons-halflings-regular.woff /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/fonts
cp /opt/spinalcordtoolbox-5.8/spinalcordtoolbox/reports/assets/_assets/fonts/glyphicons-halflings-regular.ttf /home/jovyan/workspace/books/examples/structural_imaging/qc/_assets/fonts
Successfully generated the QC results in /home/jovyan/workspace/books/examples/structural_imaging/qc/_json/qc_2026_04_09_013914.187248.json

To see the results in a browser, type:
xdg-open /home/jovyan/workspace/books/examples/structural_imaging/qc/index.html

Results of the segmentation appear in Figure 1.

<Figure size 2000x200 with 1 Axes>

Figure 1. Quality control (QC) SCT module segmentation results. The segmentation (in red) is overlaid on the T1-weighted anatomical scan (in grayscale). Orientation is axial.

Using the generated segmentation, we create a mask around the spinal cord which will be used to crop the image for faster processing and more accurate registration results: the registration algorithm will concentrate on the spinal cord and not on the surrounding tissue (e.g., muscles, neck fat, etc.) which could move independently from the spinal cord and hence produce spurious motion correction results.


--
Spinal Cord Toolbox (5.8)

sct_create_mask -i t1w.nii.gz -p centerline,t1w_seg.nii.gz -size 35mm -o t1w_mask.nii.gz
--

  OK: t1w_seg.nii.gz
Creating temporary folder (/tmp/sct-20260409013927.001192-create_mask-3dryo0vz)

Orientation:
  LPI

Dimensions:
(192, 192, 22, 1, 0.8958333, 0.8958333, 5.000001, 1)

Create mask...
/opt/spinalcordtoolbox-5.8/spinalcordtoolbox/scripts/sct_create_mask.py:230: DeprecationWarning: get_header method is deprecated.
Please use the ``img.header`` property instead.

* deprecated from version: 2.1
* Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 4.0
  hdr = centerline.get_header()  # get header
/opt/spinalcordtoolbox-5.8/spinalcordtoolbox/scripts/sct_create_mask.py:233: DeprecationWarning: get_data() is deprecated in favor of get_fdata(), which has a more predictable return type. To obtain get_data() behavior going forward, use numpy.asanyarray(img.dataobj).

* deprecated from version: 3.0
* Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 5.0
  data_centerline = centerline.get_data()  # get centerline
/opt/spinalcordtoolbox-5.8/spinalcordtoolbox/scripts/sct_create_mask.py:245: DeprecationWarning: Please use `center_of_mass` from the `scipy.ndimage` namespace, the `scipy.ndimage.measurements` namespace is deprecated.
  cx[iz], cy[iz] = ndimage.measurements.center_of_mass(np.array(data_centerline[:, :, iz]))
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
Image header specifies datatype 'int16', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.

Remove temporary files...
rm -rf /tmp/sct-20260409013927.001192-create_mask-3dryo0vz

--
Spinal Cord Toolbox (5.8)

sct_crop_image -i t1w.nii.gz -m t1w_mask.nii.gz -o t1w_crop.nii.gz
--

Bounding box: x=[73, 118], y=[69, 112], z=[4, 21]
Cropping the image...

Then, we register the proton density weighted (PD) image to the T1w image, and the MT-weighted image to the T1w image, so we end up with the T1w, MTw and PDw images all aligned together, which is a necessary condition for then computing quantitative MR metrics (here: MTsat).

Fetching long content....

Next step consists in registering the PAM50 template to the T1w image. We first create a label, centered in the spinal cord at level C3-C4 intervertebral disc, then we apply a multi-step non-linear registration algorithm.


--
Spinal Cord Toolbox (5.8)

sct_label_utils -i t1w_seg.nii.gz -create-seg-mid 4 -o label_c3c4.nii.gz
--

Generating output files...

--
Spinal Cord Toolbox (5.8)

sct_register_to_template -i t1w_crop.nii.gz -s t1w_seg.nii.gz -ldisc label_c3c4.nii.gz -ref subject -c t1 -param step=1,type=seg,algo=slicereg,metric=MeanSquares,smooth=2:step=2,type=im,algo=bsplinesyn,metric=MeanSquares,iter=5,gradStep=0.5 -qc /home/jovyan/workspace/books/examples/structural_imaging/qc
--


Check template files...
  OK: /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_t1.nii.gz
  OK: /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_label_disc.nii.gz
  OK: /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_cord.nii.gz

Check parameters:
  Data:                 t1w_crop.nii.gz
  Landmarks:            label_c3c4.nii.gz
  Segmentation:         t1w_seg.nii.gz
  Path template:        /opt/spinalcordtoolbox-5.8/data/PAM50
  Remove temp files:    1

Check input labels...
Creating temporary folder (/tmp/sct-20260409014033.711766-register_to_template-crtq5j0a)

Copying input data to tmp folder and convert to nii...

Check if provided labels are available in the template
WARNING: Only one label is present. Forcing initial transformation to: Tx_Ty_Tz

Binarize segmentation

Change orientation of input images to RPI...

Remove unused label on template. Keep only label present in the input label image...
File template_label.nii.gz already exists. Will overwrite it.
File /tmp/sct-20260409014033.711766-register_to_template-crtq5j0a/label_projected_rpi.nii.gz already exists. Will overwrite it.
File /tmp/sct-20260409014033.711766-register_to_template-crtq5j0a/template_label.nii.gz already exists. Will overwrite it.
Creating temporary folder (/tmp/sct-20260409014039.126078-register-e32p9mfz)

Copying input data to tmp folder and convert to nii...

--
ESTIMATE TRANSFORMATION FOR STEP #0
Registration parameters:
  type ........... label
  algo ........... syn
  slicewise ...... 0
  metric ......... MeanSquares
  samplStrategy .. None
  samplPercent ... 0.2
  iter ........... 10
  smooth ......... 0
  laplacian ...... 0
  shrink ......... 1
  gradStep ....... 0.5
  deformation .... 1x1x0
  init ........... 
  poly ........... 5
  filter_size .... 5
  dof ............ Tx_Ty_Tz
  smoothWarpXY ... 2
  rot_method ..... pca
Parameter 'algo=syn' has no effect for 'type=label' registration.
Labels src: [[-0.0, 46.220001220703125, -126.34002685546875], [5.0, 46.220001220703125, -126.34002685546875]]
Labels dest: [[-2.6386161799539707, 12.005123619921505, 10.510888874530792], [2.7172001843343594, 12.074783655814826, 10.06255692243576]]
Degrees of freedom (dof): Tx_Ty_Tz
Optimization terminated successfully.
         Current function value: 0.166230
         Iterations: 2
         Function evaluations: 147
Matrix:
 [[ 1.  0.  0.]
 [ 0.  1.  0.]
 [-0.  0.  1.]]
Center:
 [ 0.039292   12.03995364 10.2867229 ]
Translation:
 [[   2.460708     34.18004758 -136.62674975]]

--
ESTIMATE TRANSFORMATION FOR STEP #1

Apply transformation from previous step
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i src_seg.nii -o src_seg_reg.nii -t warp_forward_0.txt -r dest_seg_RPI.nii -n NearestNeighbor # in /tmp/sct-20260409014039.126078-register-e32p9mfz
Registration parameters:
  type ........... seg
  algo ........... slicereg
  slicewise ...... 0
  metric ......... MeanSquares
  samplStrategy .. None
  samplPercent ... 0.2
  iter ........... 10
  smooth ......... 2
  laplacian ...... 0
  shrink ......... 1
  gradStep ....... 0.5
  deformation .... 1x1x0
  init ........... 
  poly ........... 5
  filter_size .... 5
  dof ............ Tx_Ty_Tz_Rx_Ry_Rz
  smoothWarpXY ... 2
  rot_method ..... pca
/opt/spinalcordtoolbox-5.8/bin/isct_antsSliceRegularizedRegistration -t 'Translation[0.5]' -m 'MeanSquares[dest_seg_RPI_crop.nii,src_seg_reg_crop.nii,1,4,None,0.2]' -p 5 -i 10 -f 1 -s 2 -v 1 -o '[step1,src_seg_reg_crop_regStep1.nii]' # in /tmp/sct-20260409014039.126078-register-e32p9mfz

--
ESTIMATE TRANSFORMATION FOR STEP #2

Apply transformation from previous step
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i src.nii -o src_reg.nii -t warp_forward_1.nii.gz warp_forward_0.txt -r dest_RPI.nii -n 'BSpline[3]' # in /tmp/sct-20260409014039.126078-register-e32p9mfz
Registration parameters:
  type ........... im
  algo ........... bsplinesyn
  slicewise ...... 0
  metric ......... MeanSquares
  samplStrategy .. None
  samplPercent ... 0.2
  iter ........... 5
  smooth ......... 0
  laplacian ...... 0
  shrink ......... 1
  gradStep ....... 0.5
  deformation .... 1x1x0
  init ........... 
  poly ........... 5
  filter_size .... 5
  dof ............ Tx_Ty_Tz_Rx_Ry_Rz
  smoothWarpXY ... 2
  rot_method ..... pca

Estimate transformation
/opt/spinalcordtoolbox-5.8/bin/isct_antsRegistration --dimensionality 3 --transform 'bsplinesyn[0.5,1,3]' --metric 'MeanSquares[dest_RPI_pad.nii,src_reg.nii,1,4]' --convergence 5 --shrink-factors 1 --smoothing-sigmas 0mm --restrict-deformation 1x1x0 --output '[step2,src_reg_regStep2.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20260409014039.126078-register-e32p9mfz

Concatenate transformations...
/opt/spinalcordtoolbox-5.8/bin/isct_ComposeMultiTransform 3 warp_src2dest.nii.gz -R dest.nii warp_forward_2.nii.gz warp_forward_1.nii.gz warp_forward_0.txt # in /tmp/sct-20260409014039.126078-register-e32p9mfz
/opt/spinalcordtoolbox-5.8/bin/isct_ComposeMultiTransform 3 warp_dest2src.nii.gz -R src.nii -i warp_forward_0.txt warp_inverse_1.nii.gz warp_inverse_2.nii.gz # in /tmp/sct-20260409014039.126078-register-e32p9mfz

Apply transfo source --> dest...
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i src.nii -o src_reg.nii -t warp_src2dest.nii.gz -r dest.nii -n Linear # in /tmp/sct-20260409014039.126078-register-e32p9mfz

Apply transfo dest --> source...
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i dest.nii -o dest_reg.nii -t warp_dest2src.nii.gz -r src.nii -n Linear # in /tmp/sct-20260409014039.126078-register-e32p9mfz

Generate output files...
mv /tmp/sct-20260409014039.126078-register-e32p9mfz/src_reg.nii template_reg.nii
File created: template_reg.nii
mv /tmp/sct-20260409014039.126078-register-e32p9mfz/warp_src2dest.nii.gz warp_template2data_rpi.nii.gz
File created: warp_template2data_rpi.nii.gz
mv /tmp/sct-20260409014039.126078-register-e32p9mfz/dest_reg.nii data_rpi_reg.nii
File created: data_rpi_reg.nii
mv /tmp/sct-20260409014039.126078-register-e32p9mfz/warp_dest2src.nii.gz warp_data_rpi2template.nii.gz
File created: warp_data_rpi2template.nii.gz

Remove temporary files...
rm -rf /tmp/sct-20260409014039.126078-register-e32p9mfz
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i template.nii -o template2anat.nii.gz -t warp_template2anat.nii.gz -r data.nii -n 'BSpline[3]' # in /tmp/sct-20260409014033.711766-register_to_template-crtq5j0a
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i data.nii -o anat2template.nii.gz -t warp_anat2template.nii.gz -r template.nii -n 'BSpline[3]' # in /tmp/sct-20260409014033.711766-register_to_template-crtq5j0a

Generate output files...
mv /tmp/sct-20260409014033.711766-register_to_template-crtq5j0a/warp_template2anat.nii.gz warp_template2anat.nii.gz
File created: warp_template2anat.nii.gz
mv /tmp/sct-20260409014033.711766-register_to_template-crtq5j0a/warp_anat2template.nii.gz warp_anat2template.nii.gz
File created: warp_anat2template.nii.gz
mv /tmp/sct-20260409014033.711766-register_to_template-crtq5j0a/template2anat.nii.gz template2anat.nii.gz
File created: template2anat.nii.gz
mv /tmp/sct-20260409014033.711766-register_to_template-crtq5j0a/anat2template.nii.gz anat2template.nii.gz
File created: anat2template.nii.gz

Delete temporary files...
rm -rf /tmp/sct-20260409014033.711766-register_to_template-crtq5j0a

Finished! Elapsed time: 81s

*** Generate Quality Control (QC) html report ***
Resample images to 0.6x0.6 mm
Image header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.
QcImage: layout with Axial slice
Compute center of mass at each slice
/home/jovyan/workspace/books/examples/structural_imaging/qc/structural_imaging/sct_example_data/mt/sct_register_to_template/2026_04_09_014154.922680/bkg_img.png
Successfully generated the QC results in /home/jovyan/workspace/books/examples/structural_imaging/qc/_json/qc_2026_04_09_014154.922680.json

To see the results in a browser, type:
xdg-open /home/jovyan/workspace/books/examples/structural_imaging/qc/index.html

Once the PAM50 is registered with the T1w image, we can warp all objects pertaining to the PAM50 into the T1w native space. These objects notably include a white matter atlas, which will be subsequently used to extract qMR metrics within specific white matter tracts.


--
Spinal Cord Toolbox (5.8)

sct_warp_template -d t1w_crop.nii.gz -w warp_template2anat.nii.gz -qc /home/jovyan/workspace/books/examples/structural_imaging/qc
--


Check parameters:
  Working directory ........ /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
  Destination image ........ t1w_crop.nii.gz
  Warping field ............ warp_template2anat.nii.gz
  Path template ............ /opt/spinalcordtoolbox-5.8/data/PAM50
  Output folder ............ label


WARP TEMPLATE:
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_t1.nii.gz -o label/template/PAM50_t1.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_t2.nii.gz -o label/template/PAM50_t2.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_t2s.nii.gz -o label/template/PAM50_t2s.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_cord.nii.gz -o label/template/PAM50_cord.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n NearestNeighbor # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_wm.nii.gz -o label/template/PAM50_wm.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_gm.nii.gz -o label/template/PAM50_gm.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_csf.nii.gz -o label/template/PAM50_csf.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n NearestNeighbor # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_levels.nii.gz -o label/template/PAM50_levels.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n NearestNeighbor # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_levels_continuous.nii.gz -o label/template/PAM50_levels_continuous.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_label_body.nii.gz -o label/template/PAM50_label_body.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_label_disc.nii.gz -o label/template/PAM50_label_disc.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_label_discPosterior.nii.gz -o label/template/PAM50_label_discPosterior.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_spine.nii.gz -o label/template/PAM50_spine.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_centerline.nii.gz -o label/template/PAM50_centerline.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/template/PAM50_label_spinal_levels.nii.gz -o label/template/PAM50_label_spinal_levels.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n NearestNeighbor # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
cp /opt/spinalcordtoolbox-5.8/data/PAM50/template/info_label.txt label/template

WARP ATLAS OF WHITE MATTER TRACTS:
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_00.nii.gz -o label/atlas/PAM50_atlas_00.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_01.nii.gz -o label/atlas/PAM50_atlas_01.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_02.nii.gz -o label/atlas/PAM50_atlas_02.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_03.nii.gz -o label/atlas/PAM50_atlas_03.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_04.nii.gz -o label/atlas/PAM50_atlas_04.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_05.nii.gz -o label/atlas/PAM50_atlas_05.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_06.nii.gz -o label/atlas/PAM50_atlas_06.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_07.nii.gz -o label/atlas/PAM50_atlas_07.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_08.nii.gz -o label/atlas/PAM50_atlas_08.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_09.nii.gz -o label/atlas/PAM50_atlas_09.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_10.nii.gz -o label/atlas/PAM50_atlas_10.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_11.nii.gz -o label/atlas/PAM50_atlas_11.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_12.nii.gz -o label/atlas/PAM50_atlas_12.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_13.nii.gz -o label/atlas/PAM50_atlas_13.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_14.nii.gz -o label/atlas/PAM50_atlas_14.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_15.nii.gz -o label/atlas/PAM50_atlas_15.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_16.nii.gz -o label/atlas/PAM50_atlas_16.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_17.nii.gz -o label/atlas/PAM50_atlas_17.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_18.nii.gz -o label/atlas/PAM50_atlas_18.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_19.nii.gz -o label/atlas/PAM50_atlas_19.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_20.nii.gz -o label/atlas/PAM50_atlas_20.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_21.nii.gz -o label/atlas/PAM50_atlas_21.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_22.nii.gz -o label/atlas/PAM50_atlas_22.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_23.nii.gz -o label/atlas/PAM50_atlas_23.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_24.nii.gz -o label/atlas/PAM50_atlas_24.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_25.nii.gz -o label/atlas/PAM50_atlas_25.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_26.nii.gz -o label/atlas/PAM50_atlas_26.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_27.nii.gz -o label/atlas/PAM50_atlas_27.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_28.nii.gz -o label/atlas/PAM50_atlas_28.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_29.nii.gz -o label/atlas/PAM50_atlas_29.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_30.nii.gz -o label/atlas/PAM50_atlas_30.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_31.nii.gz -o label/atlas/PAM50_atlas_31.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_32.nii.gz -o label/atlas/PAM50_atlas_32.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_33.nii.gz -o label/atlas/PAM50_atlas_33.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_34.nii.gz -o label/atlas/PAM50_atlas_34.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_35.nii.gz -o label/atlas/PAM50_atlas_35.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
/opt/spinalcordtoolbox-5.8/bin/isct_antsApplyTransforms -d 3 -i /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/PAM50_atlas_36.nii.gz -o label/atlas/PAM50_atlas_36.nii.gz -t warp_template2anat.nii.gz -r t1w_crop.nii.gz -n Linear # in /home/jovyan/workspace/books/examples/structural_imaging/sct_example_data/mt
cp /opt/spinalcordtoolbox-5.8/data/PAM50/atlas/info_label.txt label/atlas

*** Generate Quality Control (QC) html report ***
Resample images to 0.6x0.6 mm
QcImage: layout with Axial slice
Compute center of mass at each slice
/home/jovyan/workspace/books/examples/structural_imaging/qc/structural_imaging/sct_example_data/mt/sct_warp_template/2026_04_09_014306.425519/bkg_img.png
Successfully generated the QC results in /home/jovyan/workspace/books/examples/structural_imaging/qc/_json/qc_2026_04_09_014306.425519.json

To see the results in a browser, type:
xdg-open /home/jovyan/workspace/books/examples/structural_imaging/qc/index.html

Results of the registration/warming appear in Figure 2.

<Figure size 2000x200 with 1 Axes>

Figure 2. Quality control (QC) SCT module registration/warping results of the PAM50 template and atlas to the T1w native space. The white matter (in blue) is overlaid on the T1-weighted anatomical scan (in grayscale). Orientation is axial. Once co-registration between images and registration to the template is complete, we can venture into computing our favorite qMR metrics. Here, we compute the magnetization transfer ratio (MTR) and the magnetization transfer saturation (MTsat).

Once co-registration between images and registration to the template is complete, we can venture into computing our favorite qMR metrics. Here, we compute the magnetization transfer ratio (MTR) and the magnetization transfer saturation (MTsat).


--
Spinal Cord Toolbox (5.8)

sct_compute_mtr -mt1 mt1_reg.nii.gz -mt0 mt0_reg.nii.gz
--


Compute MTR...
Found 0 voxels with value=0. These will be replaced by nan.
Threshold to clip values: +/- 100

--
Spinal Cord Toolbox (5.8)

sct_compute_mtsat -mt mt1_reg.nii.gz -pd mt0_reg.nii.gz -t1 t1w_crop.nii.gz -trmt 0.057 -trpd 0.057 -trt1 0.015 -famt 9 -fapd 9 -fat1 15
--

Load data...
Compute T1 map...
R1 values were found to be lower than 0.01. They will be set to inf, producing T1=0 for these voxels.
Compute A...
Compute MTsat...
MTsat values were found to be larger than 1. They will be set to zero for these voxels.
Generate output files...

Now that our metrics are computed, we want to extract their values within specific tracts of the spinal cord. This is done with the function sct_extract_metric.


--
Spinal Cord Toolbox (5.8)

sct_extract_metric -i mtr.nii.gz -l 51 -vert 2:4 -perlevel 1 -o mtr_in_wm.csv
--


Load metric image...
Estimation for label: white matter

Done! To view results, type:
xdg-open mtr_in_wm.csv


--
Spinal Cord Toolbox (5.8)

sct_extract_metric -i mtsat.nii.gz -l 51 -vert 2:4 -perlevel 1 -o mtsat_in_wm.csv
--


Load metric image...
Estimation for label: white matter

Done! To view results, type:
xdg-open mtsat_in_wm.csv


--
Spinal Cord Toolbox (5.8)

sct_extract_metric -i t1map.nii.gz -l 51 -vert 2:4 -perlevel 1 -o t1_in_wm.csv
--


Load metric image...
Estimation for label: white matter

Done! To view results, type:
xdg-open t1_in_wm.csv

Results are output as csv files, which we can then open and display as bar graphs.

<Figure size 1500x400 with 3 Axes>

Figure 3. Quantitative MRI metrics in WM between C2 and C4 vertebral levels. The three calculated metrics from this dataset using SCT are the magnetization transfer ratio (MTR – [%]), magnetization transfer saturation (MTsat – [a.u.]), and longitudinal relaxation time (T1 – [s]).

Dependencies in Jupyter/Python

  • Using the package watermark to document system environment and software versions used in this notebook, alongside the Neurodesktop version extracted from the JUPYTER_IMAGE or NEURODESKTOP_VERSION environment variables.

Last updated: 2026-04-09T01:43:24.293006+00:00

Python implementation: CPython
Python version       : 3.13.9
IPython version      : 9.7.0

Compiler    : GCC 14.3.0
OS          : Linux
Release     : 5.15.0-171-generic
Machine     : x86_64
Processor   : x86_64
CPU cores   : 32
Architecture: 64bit

IPython   : 9.7.0
matplotlib: 3.10.8
numpy     : 2.3.5
pandas    : 2.3.3
sys       : 3.13.9 | packaged by conda-forge | (main, Oct 22 2025, 23:33:35) [GCC 14.3.0]

Neurodesktop version: 2025-12-20
References
  1. Valošek, J., & Cohen-Adad, J. (2024). Reproducible Spinal Cord Quantitative MRI Analysis with the Spinal Cord Toolbox. Magnetic Resonance in Medical Sciences, 23(3), 307–315. 10.2463/mrms.rev.2023-0159