YixingHuang / DeepMedicPlus

Deep learning for brain metastasis detection and segmentation in longitudinal MRI data
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Inference - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 3 dimensions. The detected shape was (10, 1, 45) + inhomogeneous part. #4

Closed damiankucharski closed 1 year ago

damiankucharski commented 1 year ago

Hello @YixingHuang, I am trying to run inference on one of my test subjects. I have prepared the files and config files such that:

When runnning the inference with the following command I am getting an error. Do you have an idea what may be wrong?

python deepMedicRun -model ./examples/configFiles/deepMedicPlus/model/modelConfig_wide1_deeper.cfg -test ./examples/configFiles/deepMedicPlus/test/testConfig.cfg -load ./examples/output/saved_models/pretrainedModels/deepMedicWide1.high_sensitivity.model.ckpt -dev cuda0

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~         Segmenting subject with index #0       ~~~~~~~~
 Loading subject with 1st channel at: /home/kucharsd/Documents/Git/DeepMedicPlus/DeepMedicPlus/examples/data_test/PATIENT1002_VISIT2_T1CE.nii.gz
 WARN: Loaded labels are dtype [float64]. Rounding and casting to [int16]!
 WARN: Loaded ROI-mask is dtype [float64]. Rounding and casting to [int16]!
Starting to (tile) extract Segments from the images of the subject for Segmentation...
Finished (tiling) extracting Segments from the images of the subject for Segmentation.
Ready to make predictions for all image segments (parts).
Total number of Segments to process:20
Processed 0/20 segments.

ERROR: Caught exception from main process: setting an array element with a sequence. The requested array has an inhomogeneous shape after 3 dimensions. The detected shape was (10, 1, 45) + inhomogeneous part.
Traceback (most recent call last):
  File "/home/kucharsd/Documents/Git/DeepMedicPlus/DeepMedicPlus/deepMedicRun", line 180, in <module>
    session.run_session(sess_device, model_params)
  File "/home/kucharsd/Documents/Git/DeepMedicPlus/DeepMedicPlus/deepmedic/frontEnd/testSession.py", line 129, in run_session
    res_code = inference_on_whole_volumes(*([sessionTf, cnn3d] +
  File "/home/kucharsd/Documents/Git/DeepMedicPlus/DeepMedicPlus/deepmedic/routines/testing.py", line 566, in inference_on_whole_volumes
    array_fms_to_save) = predict_whole_volume_by_tiling(log, sessionTf, cnn3d,
  File "/home/kucharsd/Documents/Git/DeepMedicPlus/DeepMedicPlus/deepmedic/routines/testing.py", line 272, in predict_whole_volume_by_tiling
    feeds_dict = prepare_feeds_dict(cnn3d.get_main_feeds('test'), channs_of_tiles_per_path)
  File "/home/kucharsd/Documents/Git/DeepMedicPlus/DeepMedicPlus/deepmedic/routines/testing.py", line 207, in prepare_feeds_dict
    feeds_dict.update({feeds['x_prior']: np.asarray(channs_of_tiles_per_path[1], dtype='float32')})
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 3 dimensions. The detected shape was (10, 1, 45) + inhomogeneous part.

Finished.
YixingHuang commented 1 year ago

I guess that it is your data size problem. Please try to use similar/same preprocessing pipeline as ours. For example, also make your volume size into 240 240 155 with an isotropic voxel size of 1 mm.

damiankucharski commented 1 year ago

Thank you, after the resampling it worked. The segmentation however identifies whole brain as tumor. I assume that it is due to preprocessing reasons, I will investigate that, thanks again for your help.

YixingHuang commented 1 year ago

Good to hear that. Please try to follow our preprocessing pipeline if you want to use our pretrained models. You can also use your own preprocessing pipeline, but you need to fine tune or completely retrain the models.