sct_get_centerline

This function extracts the spinal cord centerline. Three methods are available: ‘optic’ (automatic), ‘viewer’ (manual), and ‘fitseg’ (applied on segmented image). These functions output (i) a NIFTI file with labels corresponding to the discrete centerline, and (ii) a csv file containing the float (more precise) coordinates of the centerline in the RPI orientation.

Reference: C Gros, B De Leener, et al. Automatic spinal cord localization, robust to MRI contrast using global curve optimization (2017). doi.org/10.1016/j.media.2017.12.001

usage: sct_get_centerline -i <file> [-method {optic,viewer,fitseg}]
                          [-c {t1,t2,t2s,dwi}]
                          [-centerline-algo {polyfit,bspline,linear,nurbs}]
                          [-centerline-smooth <int>] [-centerline-soft <int>]
                          [-space <str>] [-extrapolation <int>] [-o <file>]
                          [-gap <float>] [-qc <folder>] [-qc-dataset <str>]
                          [-qc-subject <str>] [-h] [-v <int>]
                          [-profile-time [<file>]] [-trace-memory [<folder>]]
                          [-r {0,1}]

MANDATORY ARGUMENTS

-i

Input image. Example: t1.nii.gz

OPTIONAL ARGUMENTS

-method

Possible choices: optic, viewer, fitseg

Method used for extracting the centerline.

  • optic: automatic spinal cord detection method

  • viewer: manual selection a few points followed by interpolation

  • fitseg: fit a regularized centerline on an already-existing cord segmentation. This method will interpolate if any slices are missing. Also, if -extrapolation 1 is specified, this method will extrapolate beyond the segmentation boundaries (i.e., every axial slice will exhibit a centerline pixel).

Default: “optic”

-c

Possible choices: t1, t2, t2s, dwi

Type of image contrast. Only relevant with -method optic.

-centerline-algo

Possible choices: polyfit, bspline, linear, nurbs

Algorithm for centerline fitting. Only relevant with -method fitseg.

Default: “bspline”

-centerline-smooth

Degree of smoothing for centerline fitting. Only relevant with -centerline-algo {bspline, linear}.

Default: 30

-centerline-soft

Possible choices: 0, 1

Binary or soft centerline. 0 = binarized, 1 = soft. Only relevant with -method fitseg.

Default: 0

-space

Possible choices: pix, phys

The coordinate space to use for units when outputting the centerline coordinates to a .csv file.’pix’=pixel dimensions, ‘phys’=physical dimensions.

Default: “pix”

-extrapolation

Possible choices: 0, 1

Extrapolate beyond the segmentation boundaries. 0 = no extrapolation, 1 = extrapolation. Only relevant with -method fitseg.Note: -extrapolation 1 works best with lower-order (linear, nurbs) centerline fitting algorithms

Default: 0

-o

File name for the centerline output file. If file extension is not provided, .nii.gz will be used by default. If -o is not provided, then the output file will be the input with suffix _centerline. Example: centerline_optic.nii.gz

-gap

Gap in mm between manually selected points. Only with method=viewer.

Default: 20.0

-qc

The path where the quality control generated content will be saved.

-qc-dataset

If provided, this string will be mentioned in the QC report as the dataset the process was run on.

-qc-subject

If provided, this string will be mentioned in the QC report as the subject the process was run on.

MISC ARGUMENTS

-v

Possible choices: 0, 1, 2

Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode.

Default: 1

-profile-time

Enables time-based profiling of the program, dumping the results to the specified file.

If no file is specified, human-readable results are placed into a ‘time_profiling_results.txt’ document in the current directory (’/home/docs/checkouts/readthedocs.org/user_builds/spinalcordtoolbox/checkouts/stable/documentation/source’). If the specified file is a .prof file, the file will instead be in binary format, ready for use with common post-profiler utilities (such as snakeviz).

-trace-memory

Enables memory tracing of the program.

When active, a measure of the peak memory (in KiB) will be output to the file peak_memory.txt. Optionally, developers can also modify the SCT code to add additional snapshot_memory() calls. These calls will ‘snapshot’ the memory usage at that moment, saving the memory trace at that point into a second file (memory_snapshots.txt).

By default, both outputs will be placed in the current directory (’/home/docs/checkouts/readthedocs.org/user_builds/spinalcordtoolbox/checkouts/stable/documentation/source’). Optionally, you may provide an alternative directory (-trace-memory <dir_name>), in which case all files will be placed in that directory instead. Note that this WILL incur an overhead to runtime, so it is generally advised that you do not run this in conjunction with the time profiler or in time-sensitive contexts.

-r

Possible choices: 0, 1

Remove temporary files.

Default: 1