ValueError when using register to template

Hey there,
I am new to the whole SCT topic & coding in general, so sorry if i make mistakes that are easy to fix, I am using this software for an academic paper.
I am using the following commands:
sct_propseg -i “T2 FILENAME” -c t2 -init-centerline viewer
sct_label_utils -i “T2 FILENAME” -create-viewer 2,5 -o labels_vert.nii.gz
sct_register_to_template -i “T2 FILENAME” -s “T2 SEG FILE” -l labels_vert.nii.gz -c t2
sct_warp_template -d anat2template.nii.gz -w warp_anat2template.nii.gz -a 0

the first two steps are never a problem. However sometimes (so not always and not following a strict pattern) the third step, the register_to_template doesn’t work, I get the error code “ValueError: zero-size array to reduction operation minimum which has no identity”. It is completely random whether it happens or not, i always do the same procedure.

My System information are as follows:
SCT info:

  • version: 5.5
  • path: /Users/nicolas/sct_5.5
    OS: osx (Darwin-21.4.0-x86_64-i386-64bit)
    CPU cores: Available: 4, Used by ITK functions: 4
    RAM: Total: 8192MB, Used: 4834MB, Available: 2795MB
    Check Python executable…[OK]
    Using bundled python 3.7.11 (default, Jul 27 2021, 07:03:16)
    [Clang 10.0.0 ] at /Users/nicolas/sct_5.5/python/envs/venv_sct/bin/python
    Check if data are installed…[OK]
    Check if colored is installed…[OK] (1.4.3)
    Check if dipy is installed…[OK] (1.4.1)
    Check if h5py is installed…[OK] (2.10.0)
    Check if Keras (2.3.1) is installed…[OK] (2.3.1)
    Check if ivadomed is installed…[OK] (2.9.2)
    Check if matplotlib is installed…[OK] (3.5.1)
    Check if nibabel is installed…[OK] (3.2.1)
    Check if numpy is installed…[OK] (1.18.5)
    Check if onnxruntime is installed…[OK] (1.7.0)
    Check if pandas is installed…[OK] (1.3.5)
    Check if psutil is installed…[OK] (5.9.0)
    Check if pyqt5 (5.11.3) is installed…[OK] (5.11.3)
    Check if pytest is installed…[OK] (6.2.5)
    Check if pytest-cov is installed…[OK] (3.0.0)
    Check if raven is installed…[OK]
    Check if requests is installed…[OK] (2.27.1)
    Check if requirements-parser is installed…[OK]
    Check if scipy is installed…[OK] (1.7.3)
    Check if scikit-image is installed…[OK] (0.19.1)
    Check if scikit-learn is installed…[OK] (1.0.2)
    Check if tensorflow is installed…[OK] (1.15.5)
    Check if torch (1.5.0) is installed…[OK] (1.5.0)
    Check if torchvision (0.6.0) is installed…[OK] (0.6.0)
    Check if xlwt is installed…[OK] (1.3.0)
    Check if tqdm is installed…[OK] (4.62.3)
    Check if transforms3d is installed…[OK] (0.3.1)
    Check if urllib3 is installed…[OK] (1.26.8)
    Check if pytest_console_scripts is installed…[OK]
    Check if wquantiles is installed…[OK] (0.4)
    Check if spinalcordtoolbox is installed…[OK]
    Check ANTs compatibility with OS …[OK]
    Check PropSeg compatibility with OS …[OK]
    Check if figure can be opened with matplotlib…[OK] (Using GUI backend: ‘MacOSX’)
    Check if figure can be opened with PyQt…[OK]
    Check FSLeyes version…Command not found. If you installed FSLeyes as part of FSL package, please check that FSL is included in $PATH variable. If you installed FSLeyes using conda environment, make sure that the environment is activated. If you do not have FSLeyes installed, consider its installation to easily visualize processing outputs and/or to use SCT within FSLeyes. More info at: FSLeyes Integration - Spinal Cord Toolbox documentation

I can give more information as needed and I would be really grateful if somebody finds an answer to my struggles!
Kindest Regards,
Nicolas

Hi @Nicolas_We00,

Thank you for raising this issue! I have 2 clarifying questions that will help us troubleshoot your issue:

  • Are there any image files that you can reliably reproduce this issue with?
  • Can you share an example of the full error traceback? (In other words, not just the error code, but the entire output of the failed run.)

Thank you kindly,
Joshua

Hi Joshua,
thank you for your quick answer.
Yes, in fact there are several files i can reproduce it with, one I used for the error:

I hope the screenshot is enough!
Thanks you in advance for your answer!
Kindest regards,
Nicolas

Thank you for the quick response!

Just to check, is it possible for you to share one of the sample images so that I can try to reproduce the issue on my computer?

Kind regards,
Joshua

Hi @Nicolas_We00,

Our development team has been troubleshooting the error (internal discussion thread here). Our hunch is that there is a problem with the input segmentation.

Could you please double-check the file you passed to “-s” (i.e. “005_Non_IRL_Spinal_T1_seg.nii.gz”) to make sure that the segmentation looks good?

Kind regards,
Joshua

Hi Joshua,
sorry for the long wait, had to check back with my supervisors. Unfortunately, I cannot give out data because of privacy reasons. However, on their devices, there is no problem with the commands, even with the same original files, which we don’t understand.

Thank you for the idea, I’ll check the segmentation file as soon as I can and will report my findings.
What’s the best way to check it? Run it through the MRI programm?
Sorry for the troubles!
Kindest regards,
Nicolas

Hi Joshua,
so one thing i noticed is that there is a difference in file size of the functioning and non-functioning segmentation files. Problem is, there is no way i can influence it.
With some files after trying 5 times again and again it is suddenly working. I don’t know how to influence the outcome. The number of segments/waypoints im setting with the “sct_propseg -i” doesn’t seem to change anything and I don’t know what else can influence it. Maybe you guys know a way out.

Kindest regards,
Nicolas

@Nicolas_We00 It would be best to have a 30min Zoom chat with you to clarify a few things. Could you please email me jcohen@polymtl.ca and we’ll organize something with you, Joshua and me.