Labels for lumbar spinal level

Hello,
I have spinal cord lumbar images and I am trying to register to template (PAM50). I am aware of the subject variability for the vertebral correspondence. But I would like to generate the labels for this spinal level with sct_label_utils or sct_label_vertebrae. I was wondering which vertebral labels correspond exactly to the lumbar spinal level among the ones I can choose.
Otherwise, should I manually create them?

Thank you in advance!

Hello @iricchi,

Thank you for reaching out.

First of all, some clarifications about what each function does:

  • sct_label_vertebrae: Enables to automatically (or semi-automatically) obtain vertebral labeling. This function outputs a spinal cord segmentation, with values corresponding to the vertebral level.
  • sct_label_utils: This function is a tools for convenient manual labeling. For example, you can use it to create manually labels of intervertebral discs, as explained here.

So, none of these functions show you the actual spinal levels. To obtain the spinal levels, you have these two options:

  • Manually label them (using sct_label_utils) if your anatomical image shows you sufficient resolution and contrast to identify the spinal rootlets.

  • Use sct_warp_template -s 1, which warps the probabilistic spinal level location on your image. Please note however that the probabilistic model was built for the cervical cord (more details here), and we don’t guaranty the accuracy of this model in the lumbar cord.

1 Like

Thanks for your detailed answer but exactly for sct_label_utils I need to specify in the viewer option the numbers corresponding to the disks and I was wondering if they were existing for the corresponding lumbar disks and which ones they were.

The label values follow this convention. So for example if you are looking to create a label for the disc T12-L1, the value would be 20.

1 Like

Hello,
I am using the same post I opened some months ago, since the topic is the same!

I have generated discs labels (till the 21st) and I have cropped both t2 and the segmentation to focus on the levels of interest. I have tried to run the sct_register_template (with standard parameters) but I get a very weird artefacts. Please have a look at the figure enclosed. Do you have any idea why this is happening? Thank you in advance!

Hi @iricchi

In order to understand the cause for this issue, could you please send me:

  • the data you used (image + segmentation + label)
  • the exact commands you used

cheers
Julien

Sure!

Forgot to mention that I was using spine+CSF segmentation to try to help the registration (given the high variability of the lumbar levels).

Anyway, here you can find the data I used.

The command I was using is:

sct_register_to_template -i t2.nii.gz -s t2_seg_CSF.nii.gz -ldisc labels.nii.gz -c t2 -param step=0,type=label,dof=Tx_Ty_Tz_Sz:step=1,type=seg,algo=centermassrot,metric=MeanSquares,iter=10,smooth=2,gradStep=0.5,slicewise=0,smoothWarpXY=2,pca_eigenratio_th=1.6:step=2,type=seg,algo=bsplinesyn,metric=MeanSquares,iter=3,smooth=1,slicewise=0,gradStep=0.5,smoothWarpXY=2,pca_eigenratio_th=1.6:step=3,type=im,metric=CC

I also tried the standard parameters option simply:

sct_register_to_template -i t2.nii.gz -s t2_seg_CSF.nii.gz -ldisc labels.nii.gz -c t2

And as I wrote, I also tried to crop the image till the 21st disc but same output after the registration.

A few comments:

  • there is no need to manually crop the image because this step is already included in the sct_register_to_template function
  • you cannot use a CSF segmentation with the function sct_register_to_template unless you specify that the target segmentation used for registration is the CSF mask. This can be achieved with the special flag -s-template-id and selecting the value 6 (you can find this value with the command cat $SCT_DIR/data/PAM50/template/info_label.txt). Although in your case this won’t work because the CSF mask is only the CSF, whereas your CSF mask has the spinal cord and the CSF. So if you want to use this mask you would need to subtract your mask from the SC mask. But in any case, I don’t think this is the right approach for your data. Instead I recommend to stick with the SC segmentation.
  • The artifact you are seeing in Labels for lumbar spinal level - #5 by iricchi is due to the fact that you used more than 2 labels with sct_register_to_template. When using more than 2 labels, a non-linear registration is first performed (corresponds to the step=0), meaning that SCT will align all the labels, and ignore what’s above the top label and below the bottom label. This results in the strange-looking image that you reported in your post. If you are only interested in the regions between the top and bottom label, then you don’t need to worry about this reconstruction artifact. If however you are interested in the regions outside, then you need to use a maximum of 2 labels.

Here is a piece of code that gets the SC segmentation and only keeps the top and bottom labels from your original label image that you sent (it had 5 labels in total):

# Segment the spinal cord
sct_deepseg_sc -i t2.nii.gz -c t2 -qc qc
# Only keep two labels
sct_label_utils -i labels.nii.gz -keep 17,21 -o labels_17_21.nii.gz
# Register to template
sct_register_to_template -i t2.nii.gz -s t2_seg.nii.gz -ldisc labels_17_21.nii.gz -c t2 -qc qc -param step=1,type=seg,algo=centermassrot:step=2,type=seg,algo=bsplinesyn,metric=MeanSquares,iter=3,slicewise=0:step=3,type=im,algo=syn,metric=CC,iter=3,slicewise=0

It gives the following result, which is acceptable:
anim

However, as you can notice more clearly in the QC report, the cauda equinea is not perfectly registered with the PAM50 template, because this registration is using intervertebral discs instead of the cord fiducial markers. If you are particularly interested in matching the location of the cauda equinea between your participant data and the PAM50 template, then you can create a label a ‘cauda equinea’ label in the PAM50 template and use that for registration. Demo here:

# Add a label of arbitrary value 99 to the PAM50 template at the start of the cauda equinea
sct_label_utils -i $SCT_DIR/data/PAM50/template/PAM50_label_disc.nii.gz -create-add 70,69,46,99 -o $SCT_DIR/data/PAM50/template/PAM50_label_disc.nii.gz
# Add the same label on the participant data
sct_label_utils -i t2.nii.gz -create 33,239,314,99 -o label_caudaequinea.nii.gz
# Use these labels to register to the PAM50
sct_register_to_template -i t2.nii.gz -s t2_seg.nii.gz -ldisc label_caudaequinea.nii.gz -c t2 -qc qc -param step=1,type=seg,algo=centermassrot:step=2,type=seg,algo=bsplinesyn,metric=MeanSquares,iter=3,slicewise=0:step=3,type=im,algo=syn,metric=CC,iter=3,slicewise=0

This time, the registration of the lumbar cord is more accurate because now it is based on the cauda equinea (as opposed to the vertebral levels). Notably, the lumbar enlargement is now matching that from the PAM50 better than in the previous registration:
anim_caudaEquinea

:information_source: Notice some image processing artefacts below the cauda equinea, which are caused by the straightening algorithm (because the cord segmentation has “holes” below the cauda equinea). These can be mitigated with a few approaches (eg: extrapolate the cord segmentation, change regularization parameters, etc.), but this is out of the scope of this post. And as mentioned before, if you are only interested in the cord (ie: above the cauda equinea), then that shouldn’t be a problem.

Hi Julien! Thank you so much!

  • Regarding the segmentation, I was basically summing (through fslmaths) CSF and cord segmentation (for T2) and, since we are loooking at fMRI too, it made sense to use CSF additionally to the cord because creating fMRI masks and segmenting functional imaging was easier in this way. So you would suggest for the purpose of registration to PAM50 to stick with spinal cord only anyway?

  • On sct_register_to_template, I thought I could use more than 2 labels for discs in particular. But, being interested in the regions also outside, I will need to stick to 2.

Thank you so much again! :slight_smile:

There is a lot of unknown for me (ie: how many contrasts you have, what are your hypotheses, what image quality of EPI scans, etc.) so it is difficult for me to advise exactly what to do. But for example, if your end goal is to register to the EPI scans to the PAM50 and your plan is to bypass the vertebral labeling, then you don’t need to go through the T2w registration and you can directly register the PAM50 template to your EPI scans.

Just to clarify: you can use more than 2 labels with sct_register_to_template. The only thing to keep in mind is that the region of interest needs to be encompassed between the top and bottom labels.

1 Like

Dear Julien,
Following this conversation, I tried to run the normalisation steps you suggest (that was working pretty well for most of the subjects). But a couple of subjects has the cauda equina quite high (see here the t2 and here the label I added for cauda equina). This anatomical variation systematically generates this error:

Do you know if there could be another way to normalise these types of subjects?

Dear @iricchi,

Incorrect conclusion. Please refer to further discussion below

I downloaded the 2 images you linked, and tried running sct_register_to_template. If I use a fresh copy of the PAM50 template (by running sct_download_data -d PAM50), I was able to reproduce the error using the 2 images you gave:

To fix this issue, I ran the label-adding step given by @jcohenadad here:

Once I did this, I found that I did not get the error mentioned, and so the registration completed successfully (albeit not particularly well):

anat2template_overlaid_on_PAM50_T2

Can you double-check that you’ve run the sct_label_utils step on the PAM50 template beforehand?

(Or, perhaps share a different label/image that we can test with, to try to reproduce this error?)

Kind regards,
Joshua


Aside: Segmentation quality for this image

This has no bearing on the registration error, but during my investigation, I tried segmenting the image you provided (t2_LU_SM.nii.gz) with sct_deepseg_sc (as recommended earlier by @jcohenadad), but noticed that the segmentation was quite poor:

As a backup, I tried running sct_propseg (SCT’s older segmentation tool), and was able to get much better results for this specific image (though admittedly still not perfect):

Dear @joshuacwnewton,
thank you so much for your swift reply!

I already run that command before (cause I was doing this in all subjects), so I already edited the labels.
I still continue having the same issue with the same subject! I think I realised what the problem is: the segmentation. I do have the latest implementation of lumbar segmentation (trained with our manual segmentations) and I get this. I am afraid the propeseg is getting nerves much more than the cord – that stops around the cauda equina.

Here another subject: t2, t2_seg, cauda_equina.
I think also here there is the same issue of the segmentation!

Ok, I fixed the segmentations and now it’s working without the error.
The label wasn’t included in the voxels of the segmentation.
Thanks so much for your help! :slight_smile:

1 Like

@iricchi To improve the quality of the spinal cord segmentation on lumbar images, you might want to try our recent segmentation model that was trained on lumbar data.

To run it:

sct_deepseg -i IMAGE -task seg_lumbar_sc_t2w

Hi @jcohenadad,
Yes, I’m already using that command (I helped generating the ground truth manually segmented for that). :crazy_face:

Hi @iricchi,

I’m very glad to hear you were able to solve this issue!

I came to the exact same conclusion in my debugging. Here is a more in-depth analysis of the root cause, if you’re curious:

Debugging to confirm that the segmentation was the issue

I was able to reproduce the issue as you’ve described (even with the modified PAM50 template).

Tracing the source code, I found that the label in your label image disappears after the straightening step. For comparison:

Internally, in order to straighten the label image, we reuse the same warping field that was used to straighten the segmentation. As well, the segmentation image gets cropped to the extent of the segmentation (shown in grey below):

image

So, because the label was outside of this cropped region (as you surmised), the straightening step causes the label to be lost (because the warping field, shown below, isn’t defined for that region):

image

Kind regards,
Joshua

1 Like

Thank you so much! :star_struck:

I’ve opened an issue in our GitHub repository (#3873) so that in the future, we can display a better error message in cases like this. That way, it will be easier to figure out the problem in the future.

Thank you for reporting this issue, and helping to improve SCT! :smile:

Kind regards,
Joshua

1 Like

I helped generating the ground truth manually segmented for that

Ah it’s you! Thanks a lot for your help :blush: If you have more manual segmentations please send them so we can further improve the model

1 Like