Automatic segmentation of the proximal spinal nerve roots

Hello SCT team,
I was wondering if there is a tool for the automatic segmentation of the proximal spinal nerve roots. I’m mainly interested in proximal lumbosacral nerves.
Many thanks in advance for your help
Mohamed

1 Like

Hi @mtach,

Thank you for reaching out. No there is no tool (yet) for automatic segmentation of spinal nerve rootlets. However, this is highly desirable feature, so if you are interested in developing it, we would love to help you having that feature integrated into SCT :blush:

Cheers,
Julien

1 Like

Hi @mtach,

I’m just providing a quick update to let you know that SCT v6.2 has been released. This version of SCT provides a new segmentation model for automatic segmentation of spinal nerve rootlets.

You can use this feature by running sct_deepseg -i image.nii.gz -task seg_spinal_rootlets_t2w. Please let us know if you have any further questions or concerns. :slight_smile:

Kind regards,
Joshua

Hi @joshuacwnewton
Thank you very much for letting me know.
I’m keen to run it and let you know how it goes.
Best regards
Mohamed

1 Like

Hi @joshuacwnewton ,

This does work nicely for the dorsal roots but is there also a way to mask both dorsal and ventral roots?

Edit: and if possible segment the roots even further away from the spinal cord

Thanks in advance!

Hi @b.kalkhoven!

Thanks for testing the dorsal rootlets model and for your positive feedback! :pray:

The model segmenting both ventral and dorsal rootlets is still under development. We currently have a beta version of this model available. You can follow the instructions in this README to get the model! We will be glad for your feedback! The model currently segments rootlets within the spinal canal.

If you find the model useful and will use it in your research, please cite our recent preprint.

Cheers,
Jan

Thank you @valosekj ,

I will work on it coming week!

@valosekj

I tried running the model but I get the following error, could you help me identify the issue?

Predicting :
perform_everything_on_gpu: False
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 8/8 [10:09<00:00, 76.14s/it]
Prediction done, transferring to CPU if needed
sending off prediction to background worker for resampling and export
done with
[W ParallelNative.cpp:230] Warning: Cannot set number of intraop threads after parallel work has started or after set_num_threads call when using native parallel backend (function set_num_threads)
Inference done.
Total inference time: 10 minute(s) 27 seconds

Traceback (most recent call last):
File β€œ/Users/bkalkhov/Tractography/Spinal_cord/Spinal_cord_testing/Rootlets/model-spinal-rootlets/packaging_ventral_rootlets/run_inference_single_subject.py”, line 224, in
main()
File β€œ/Users/bkalkhov/Tractography/Spinal_cord/Spinal_cord_testing/Rootlets/model-spinal-rootlets/packaging_ventral_rootlets/run_inference_single_subject.py”, line 198, in main
pred_file = glob.glob(os.path.join(tmpdir_nnunet, β€˜*.nii.gz’))[0]
IndexError: list index out of range

The T2 image is copied to the temporary folder, which also contains the folder β€œnnUNet_prediction” but there is no other .nii.gz file that contains the prediction which causes the error… But the loading bar and total inference time feedback imply that it encountered no errors during the process…

Thanks for testing the model, @b.kalkhoven!

I tried the model on a sample image on my end, and it worked without errors.

Would you mind sharing the image with me? The debugging will be easier. You can upload the image to some cloud service and send me a link to jan.valosek@polymtl.ca. Thanks!

Thanks for sharing the image @b.kalkhoven!

I was able to reproduce the error. I will dig deeper into it today/tomorrow and let you know.

Hi @b.kalkhoven!

I believe I fixed the issue (details here).
Can you please run the following commands to download the fixed code and run the model again?

cd <YOUR_PATH>/model-spinal-rootlets
git pull

Thank you!

Hi @valosekj ,

It works without errors now! But the results still only contain dorsal rootlets. Is that possibly a contrast problem in my image?

Cheers

Hi @b.kalkhoven!

I have just run the model-spinal-rootlets_ventral_D106_r20240523 model on your t2.nii image, and I can see that the model segments both ventral and dorsal rootlets:

image

Did you follow the instructions in this README? Note that you need to download the ventral model model-spinal-rootlets_ventral_D106_r20240523.zip, as described in Step 3. Then, you need to provide the path to this model to the run_inference_single_subject.py script:

python packaging_ventral_rootlets/run_inference_single_subject.py -i t2.nii -o t2_rootlets.nii ~/Downloads/model-spinal-rootlets_ventral_D106_r20240523 -fold all

@joshuacwnewton . Can I use this model to segment nerve roots for whole spine ? Based on readme, it seems it works only for cervical area. Thoughts ?

Hi @ranabhat!

Correct, the current models work for cervical rootlets only. However, we are also developing a model for lumbar rootlets! If you have already segmented some lumbar images manually, I would be happy to include them in our training set to make our current model more robust.

Cheers,
Jan

@valosekj : Sorry we have created any ground-truth segmentation for lumbar spine yet. It’s a huge manual work . In addition, we don’t have enough CT and MR images of lumbar spine to create those. Not sure do you have these data which I can use to generate segmentations? We are planning to do this work by the end of summer. Thanks !!!

Thanks for the details, @ranabhat! When we have the first version of the lumbar model ready (hopefully by the end of summer), I’ll share it with you so you can try it out on your data! :slight_smile: