Operands could not be broadcast together

Hi!

Uploading the verbose if a weird error i have just found. I hope that the fact that i am using an image with brain has nothing to do with it. That’s why i used the -brain 1

extop@:/aran/SCT/Nifti/06. 14453312$ sct_deepseg_sc -i 144533123D_T1_.nii -c t1 -brain 1 -centerline cnn

--
Spinal Cord Toolbox (4.2.1)

Config deepseg_sc:
  Centerline algorithm: cnn
  Brain in image: True
  Kernel dimension: 2d
  Contrast: t1
  Threshold: 0.15

Create temporary folder (/tmp/sct-20200206150534.236788-c7w2mm13)...
Reorient the image to RPI, if necessary...
Finding the spinal cord centerline...
WARNING: To avoid intensity overflow due to convertion to uint8, intensity will be rescaled to the maximum quantization scale.
Traceback (most recent call last):
  File "/home/extop/sct_4.2.1/scripts/sct_deepseg_sc.py", line 205, in <module>
    main()
  File "/home/extop/sct_4.2.1/scripts/sct_deepseg_sc.py", line 189, in main
    threshold_seg=threshold, remove_temp_files=remove_temp_files, verbose=verbose)
  File "/home/extop/sct_4.2.1/spinalcordtoolbox/deepseg_sc/core.py", line 477, in deep_segmentation_spinalcord
    centerline_fname=file_ctr)
  File "/home/extop/sct_4.2.1/spinalcordtoolbox/deepseg_sc/core.py", line 97, in find_centerline
    brain_bool=brain_bool)
  File "/home/extop/sct_4.2.1/spinalcordtoolbox/deepseg_sc/core.py", line 252, in heatmap
    data_im = np.pad(data_im, ((0, x_pad), (0, 0), (0, 0)), 'constant')
  File "<__array_function__ internals>", line 6, in pad
  File "/home/extop/sct_4.2.1/python/envs/venv_sct/lib/python3.6/site-packages/numpy/lib/arraypad.py", line 741, in pad
    pad_width = _as_pairs(pad_width, array.ndim, as_index=True)
  File "/home/extop/sct_4.2.1/python/envs/venv_sct/lib/python3.6/site-packages/numpy/lib/arraypad.py", line 516, in _as_pairs
    return np.broadcast_to(x, (ndim, 2)).tolist()
  File "<__array_function__ internals>", line 6, in broadcast_to
  File "/home/extop/sct_4.2.1/python/envs/venv_sct/lib/python3.6/site-packages/numpy/lib/stride_tricks.py", line 182, in broadcast_to
    return _broadcast_to(array, shape, subok=subok, readonly=True)
  File "/home/extop/sct_4.2.1/python/envs/venv_sct/lib/python3.6/site-packages/numpy/lib/stride_tricks.py", line 127, in _broadcast_to
    op_flags=['readonly'], itershape=shape, order='C')

ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (3,2) and requested shape (4,2)

thanks for the help!

Update, we tried something different, another error

extop@/aran/SCT/Nifti/14. 13210485$ sct_deepseg_sc -i 13210485_3D_T1_MS.nii -c t1

--
Spinal Cord Toolbox (4.2.1)

Config deepseg_sc:
  Centerline algorithm: svm
  Brain in image: True
  Kernel dimension: 2d
  Contrast: t1
  Threshold: 0.15

Create temporary folder (/tmp/sct-20200206151404.725227-be439y_g)...
Reorient the image to RPI, if necessary...
Finding the spinal cord centerline...
Remove temporary files...
rm -rf /tmp/sct-20200206151432.869749-suyedmcd
Cropping the image around the spinal cord...
Traceback (most recent call last):
  File "/home/extop/sct_4.2.1/scripts/sct_deepseg_sc.py", line 205, in <module>
    main()
  File "/home/extop/sct_4.2.1/scripts/sct_deepseg_sc.py", line 189, in main
    threshold_seg=threshold, remove_temp_files=remove_temp_files, verbose=verbose)
  File "/home/extop/sct_4.2.1/spinalcordtoolbox/deepseg_sc/core.py", line 488, in deep_segmentation_spinalcord
    crop_size=crop_size)
  File "/home/extop/sct_4.2.1/spinalcordtoolbox/deepseg_sc/core.py", line 175, in crop_image_around_centerline
    x_shape, y_shape = data_in[x_start:x_end, y_start:y_end, zz].shape
ValueError: too many values to unpack (expected 2)

Hi Aran,

Thank you for the feedback. So, I suspect these issues are related to either the native dimension of your image and/or some errors during the automatic centerline detection.

Would you be able to run the script with the flag -r 0 and send me a zipped version of the folder that is generated in the /temp path? The folder is indicated in your error message, e.g.: /tmp/sct-20200206151432.869749-suyedmcd

cheers,
Julien

Good morning

I have just shared with you the output that you asked for!

Wierdly i could not upload it to this forum? Maybe there is
a hidden reason behind it!

thanks for your help!
aran

Thank you Aran,

I’ve been able to reproduce your error and a ticket has been opened. We are working on a fix now.

Best,
Julien

Hi @Aran,

As you can see on the Github issue, we identified the source of the problem: for some reasons, your NIFTI file has inconsistent fields: dim0=4 while your dim4 is a singleton. You can either split your data across time as suggested here, or adjust your pre-processing pipeline to ensure the NIFTI header is consistent (recommended).

Best,
Julien

Hi @jcohenadad,

That is unexpected! We believe that this inconsistency was
produced by the JIM software.
Now that we are aware of it, we will have more caution with it!
(and the way to solve it is actually unexpectedly easy)

thank you very much,
aran

1 Like