Skip to content

ValueError: operands could not be broadcast together with shapes (55,136,102) (3,) #4

@KMarshallX

Description

@KMarshallX

Hi,

I ran the code with my own data, but it bumped into an error:

running postprocessing... 
exporting segmentation...
Traceback (most recent call last):
  File "/scratch/itee/uqmxu4/tor_env/bin/hd-bet", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/scratch/itee/uqmxu4/HD-BET/HD_BET/hd-bet", line 121, in <module>
    run_hd_bet(input_files, output_files, mode, config_file, device, pp, tta, save_mask, overwrite_existing)
  File "/scratch/itee/uqmxu4/HD-BET/HD_BET/run.py", line 110, in run_hd_bet
    save_segmentation_nifti(seg, data_dict, mask_fname)
  File "/scratch/itee/uqmxu4/HD-BET/HD_BET/data_loading.py", line 87, in save_segmentation_nifti
    if np.any(np.array(seg_old_size) != np.array(dct['size'])[[2, 1, 0]]):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: operands could not be broadcast together with shapes (55,136,102) (3,) 

The problem seems to be with line 87, data_loading.py, where you compare a data matrix with a row matrix (the shape). I changed the line to if np.any(np.array(seg_old_size).shape != np.array(dct['size'])[[2, 1, 0]]): and it ran without errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions