Obtaining N slice indices in native space, equidistant along centerline

I would like to be able to obtain a list of N slice indices that are equidistant along the centerline in an image of interest (e.g. t2.nii.gz), between lower and upper bounds of my choosing. The bounds would be delimited by the file labels.nii.gz, where a binary mask labels two points: one at the lower bound of interest (e.g. mid vertebra C2) and one at the upper bound of interest (e.g. mid vertebra C5). More specifically:


  • t2_centerline.nii.gz (obtained by running: sct_get_centerline -i t2.nii.gz -c t2)
  • labels.nii.gz (obtained by running: sct_deepseg_sc -i t2.nii.gz -c t2; sct_label_vertebrae -i t2.nii.gz -s t2_seg.nii.gz -c t2; sct_label_utils -i t2_seg_labeled.nii.gz -vert-body 2,5)
  • N (integer value corresponding to the number of slices of interest)


  • Integer list of length N (each entry corresponding to a slice index)

Is there an SCT tool that already does this or should I create a new script for this? Thank you!