Error with sct_deepseg spinalcord - sct 7.2

Hi,
I have this error when running sct_deepseg spinalcord (sct 7.2) - Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-163-generic x86_64)


--
Spinal Cord Toolbox (7.2)

sct_deepseg spinalcord -i /cerebro/cerebro1/dataset/spine_7t/spine_7t_fmri_data/derivatives/processing/preprocessing/sub-094/anat/sub-094_T2star.nii.gz -c t2 -thr 0.01 -o /cerebro/cerebro1/dataset/spine_7t/spine_7t_fmri_data/derivatives/processing/preprocessing/sub-094/anat/sct_deepseg/sub-094_T2star_seg.nii.gz -qc /cerebro/cerebro1/dataset/spine_7t/spine_7t_fmri_data/derivatives/processing/preprocessing/QC/ -qc-subject sub-094 -v 0
--

Traceback (most recent call last):
  File "/cerebro/cerebro1/dataset/spine_7t/spine_7t_fmri_analysis/toolboxes/sct_7.2/spinalcordtoolbox/scripts/sct_deepseg.py", line 623, in <module>
    main(sys.argv[1:])
  File "/cerebro/cerebro1/dataset/spine_7t/spine_7t_fmri_analysis/toolboxes/sct_7.2/spinalcordtoolbox/scripts/sct_deepseg.py", line 489, in main
    im_lst, target_lst = inference.segment_non_ivadomed(
  File "/cerebro/cerebro1/dataset/spine_7t/spine_7t_fmri_analysis/toolboxes/sct_7.2/spinalcordtoolbox/deepseg/inference.py", line 131, in segment_non_ivadomed
    net = create_net(path_model, device, **extra_network_kwargs)
TypeError: segment_non_ivadomed.<locals>.create_net() got an unexpected keyword argument 'test_time_aug'

I have also updated to Spinal Cord Toolbox (7.3.dev0) and had the same issue

However, I was not able to reproduce the error on macOS 14.1 & sct 7.2

Do you have any idea where the error is coming from? Could it be related to any dependency that it is not install in my environnement ?

Cheers,
Caroline

Hi @Caroline_Landelle,

Thanks so much for your question! We would be happy to help debug.

sct_deepseg spinalcord -i /cerebro/cerebro1/dataset/spine_7t/spine_7t_fmri_data/derivatives/processing/preprocessing/sub-094/anat/sub-094_T2star.nii.gz 
                       -c t2 
                       -thr 0.01 
                       -o /cerebro/cerebro1/dataset/spine_7t/spine_7t_fmri_data/derivatives/processing/preprocessing/sub-094/anat/sct_deepseg/sub-094_T2star_seg.nii.gz 
                       -qc /cerebro/cerebro1/dataset/spine_7t/spine_7t_fmri_data/derivatives/processing/preprocessing/QC/ 
                       -qc-subject sub-094 
                       -v 0

The good news is that I don’t see anything wrong with the command you used!

Here are some technical notes (just for posterity) to try and explain the cause of the error:

Some questions to confirm my suspicions:

  • Do you have an older version of the spinalcord model installed?
  • Have you used the -custom-url argument when installing the spinalcord model?

If either of these are true, then updating to the newest version of the spinalcord model using sct_deepseg spinalcord -install should fix the issue.

If you still need the older version of spinalcord model, please let me know and I can figure out an alternate solution for you. :slight_smile:

Kind regards,
Joshua

1 Like

Thank you Joshua,
Yes I probably have older spinal cord model installed as I am working on different projects using different sct version. However for each project I set up the path toward the right sct version like SCT_DIR=$PATH_CODE/toolboxes/sct_7.2

I don’t think I have used -custom-url argument.

Unfortunatly sct_deepseg spinalcord -install did not fixed the issue

Thank you for your help !

Thank you so much for trying this step. On further reflection, I see that my initial investigation was wrong, and you don’t have an old model version.

The real problem is actually due to a bug in SCT’s code. We will fix this shortly. For now, you can run the following command to update your SCT installation and remove this bug:

# fix the buggy line in SCT's code
 sed -i 's/if "spine" in path_model:/if os.path.basename(path_model) == "spine":/' "$SCT_DIR/spinalcordtoolbox/deepseg/inference.py"

Please let me know if this fixes the issue for you and then I will go ahead and apply this change to SCT’s codebase. Thank you for your patience and understanding.

Kindly,
Joshua

Excellent !
Thank you Joshua, the command fixed the bug on my side

Best,
Caroline