Sct can't read provided image

Every time I try to use an sct command on an .nii or .nii.gz image, I get the following error:


--
Spinal Cord Toolbox (4.3)

Error: make sure /home/Philipp/001_HWS.nii is an image.
Traceback (most recent call last):
  File "/home/philipp/sct_4.3/scripts/sct_label_utils.py", line 875, in <module>
    main()
  File "/home/philipp/sct_4.3/scripts/sct_label_utils.py", line 864, in main
    verbose=verbose, vertebral_levels=vertebral_levels, value=value, msg=msg, fname_previous=input_fname_previous)
  File "/home/philipp/sct_4.3/scripts/sct_label_utils.py", line 60, in __init__
    self.image_input = Image(fname_label, verbose=verbose)
  File "/home/philipp/sct_4.3/spinalcordtoolbox/image.py", line 243, in __init__
    self.loadFromPath(param, verbose)
  File "/home/philipp/sct_4.3/spinalcordtoolbox/image.py", line 347, in loadFromPath
    self.data = self.im_file.get_data()
AttributeError: 'NoneType' object has no attribute 'get_data'

I’m running this command through an ssh connection on an ubuntu server. The file definitely exists and is a NIFTI image. Does anyone know what’s happening here?

Hi Philipp,

if you have FSL, what is the output of:

fslhd /home/Philipp/001_HWS.nii

Does it work if you copy this file locally?

Hi jcohenadad,
thanks for your help!
this is the output of fslhd:

filename       ./001_HWS.nii.gz

sizeof_hdr     348
data_type      INT16
dim0           3
dim1           384
dim2           384
dim3           13
dim4           1
dim5           1
dim6           1
dim7           1
vox_units      mm
time_units     s
datatype       4
nbyper         2
bitpix         16
pixdim0        0.000000
pixdim1        0.911458
pixdim2        0.911458
pixdim3        3.299664
pixdim4        0.000000
pixdim5        0.000000
pixdim6        0.000000
pixdim7        0.000000
vox_offset     352
cal_max        0.0000
cal_min        0.0000
scl_slope      1.000000
scl_inter      0.000000
phase_dim      1
freq_dim       2
slice_dim      3
slice_name     alternating_increasing
slice_code     3
slice_start    0
slice_end      12
slice_duration 0.000000
time_offset    0.000000
intent         Unknown
intent_code    0
intent_name    
intent_p1      0.000000
intent_p2      0.000000
intent_p3      0.000000
qform_name     Scanner Anat
qform_code     1
qto_xyz:1      0.000000  0.012762  3.299340  -22.727304
qto_xyz:2      -0.911458  0.000000  0.000000  160.406860
qto_xyz:3      0.000000  0.911369  -0.046200  -362.059967
qto_xyz:4      0.000000  0.000000  0.000000  1.000000
qform_xorient  Anterior-to-Posterior
qform_yorient  Inferior-to-Superior
qform_zorient  Left-to-Right
sform_name     Unknown
sform_code     0
sto_xyz:1      0.000000  0.000000  0.000000  0.000000
sto_xyz:2      0.000000  0.000000  0.000000  0.000000
sto_xyz:3      0.000000  0.000000  0.000000  0.000000
sto_xyz:4      0.000000  0.000000  0.000000  0.000000
sform_xorient  Unknown
sform_yorient  Unknown
sform_zorient  Unknown
file_type      NIFTI-1+
file_code      1
descrip        t2_tse_sag_384 HWS
aux_file       

So far I haven’t been able to install sct locally.

And I’m getting the same error locally. Is there something wrong with my file?

I figured it out. It was this issue:

1 Like

sorry for the late reply-- i’m glad you figured this out