Deep-MI / FastSurfer

PyTorch implementation of FastSurferCNN
Apache License 2.0
458 stars 119 forks source link

RuntimeError: affine matrix has wrong number of columns #27

Closed ZhyCong closed 4 years ago

ZhyCong commented 4 years ago

Hello, I successfully run FastSurfer, but the program has thrown this error, please check what the problem is caused by, thank you

Log file for fastsurfercnn eval.py
Thu 13 Aug 16:31:51 CST 2020

python3.6 eval.py --in_name /home/data_1/zhaoyang/toolbox/FastSurfer-fix-requirements/example/T1/01.nii --out_name /home/data_1/zhaoyang/toolbox/FastSurfer-fix-requirements/example/output/01/mri/aparc.DKTatlas+aseg.deep.mgz --order 1 --network_sagittal_path ../checkpoints/Sagittal_Weights_FastSurferCNN/ckpts/Epoch_30_training_state.pkl --network_axial_path ../checkpoints/Axial_Weights_FastSurferCNN/ckpts/Epoch_30_training_state.pkl --network_coronal_path ../checkpoints/Coronal_Weights_FastSurferCNN/ckpts/Epoch_30_training_state.pkl --batch_size 16 --simple_run
Reading volume /home/data_1/zhaoyang/toolbox/FastSurfer-fix-requirements/example/T1/01.nii
Conforming image to UCHAR, RAS orientation, and 1mm isotropic voxels
Input:    min: 0  max: 17004
rescale:  min: 0.0  max: 10321.428000000002  scale: 0.024705883720740965
Traceback (most recent call last):
  File "eval.py", line 483, in <module>
    fast_surfer_cnn(options.iname, options.oname, options)
  File "eval.py", line 167, in fast_surfer_cnn
    header_info, affine_info, orig_data = load_and_conform_image(img_filename, interpol=args.order)
  File "/home/data_1/zhaoyang/toolbox/FastSurfer-fix-requirements/FastSurferCNN/data_loader/load_neuroimaging_data.py", line 44, in load_and_conform_image
    orig = conform(orig, interpol)
  File "/home/data_1/zhaoyang/toolbox/FastSurfer-fix-requirements/FastSurferCNN/data_loader/conform.py", line 229, in conform
    mapped_data = map_image(img, h1.get_affine(), h1.get_data_shape(), order=order)
  File "/home/data_1/zhaoyang/toolbox/FastSurfer-fix-requirements/FastSurferCNN/data_loader/conform.py", line 85, in map_image
    new_data = affine_transform(img.get_data(), inv(vox2vox), output_shape=out_shape, order=order)
  File "/home/zhaoyang/anaconda3/envs/py36/lib/python3.6/site-packages/scipy/ndimage/interpolation.py", line 467, in affine_transform
    raise RuntimeError('affine matrix has wrong number of columns')
RuntimeError: affine matrix has wrong number of columns
m-reuter commented 4 years ago

Most likely you have a strange nifti file. You can convert it with mri_convert to mgz and back to nii to see if that helps.

ZhyCong commented 4 years ago

Thank you very much. I used nii files from ADNI before, but now I use nii files from other sources, and now I can run normally. @m-reuter