Anat2template.nii.gz file created as an image rather than 5D warp field

Hi, I am using SCToolbox to register spinal cords of rodents. We have our template for this study and it seems to run fine until we try applying anat2template.nii.gz to other files.

The error I get is “anat2template.nii.gz is invalid: should be encoded in a 5D file with vector intent code (see https://nifti.nimh.nih.gov/pub/dist/src/niftilib/nifti1.h

Here is the return of fslhd on anat2template.nii.gz file.

filename anat2template.nii.gz

size of header 348

data_type FLOAT64

dim0 3

dim1 111

dim2 88

dim3 580

dim4 1

dim5 1

dim6 1

dim7 1

vox_units mm

time_units Unknown

datatype 64

nbyper 8

bitpix 64

pixdim0 -1.000000

pixdim1 0.050000

pixdim2 0.050000

pixdim3 0.150000

pixdim4 1.000000

pixdim5 1.000000

pixdim6 1.000000

pixdim7 1.000000

vox_offset 352

cal_max 0.000000

cal_min 0.000000

scl_slope 1.000000

scl_inter 0.000000

phase_dim 0

freq_dim 0

slice_dim 0

slice_name Unknown

slice_code 0

slice_start 0

slice_end 0

slice_duration 0.000000

toffset 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.050000 0.000000 -0.000000 5.500000

qto_xyz:2 0.000000 0.050000 -0.000000 -0.000000

qto_xyz:3 0.000000 0.000000 0.150000 0.000000

qto_xyz:4 0.000000 0.000000 0.000000 1.000000

qform_xorient Right-to-Left

qform_yorient Posterior-to-Anterior

qform_zorient Inferior-to-Superior

sform_name Scanner Anat

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 1.000000

sform_xorient Unknown

sform_yorient Unknown

sform_zorient Unknown

file_type NIFTI-1+

file_code 1

descrip

aux_file

I found a previous thread but didn’t find an answer there. Here is what I ran

#register to the template

sct_register_to_template \

-i $infile \

-s $label \

-param step=0,type=label,dof=Tx_Ty_Tz_Sz:step=1,type=im,algo=rigid,metric=MeanSquares,iter=3,smooth=0,gradStep=0.5,slicewise=0,smoothWarpXY=2:step=2,type=im,algo=bsplinesyn,metric=MeanSquares,iter=3,gradStep=0.5,slicewise=0 \

-t $ourtemplate \

-v 2 \

-lspinal $label \

-ofolder reg/

sct_register_multimodal \

-i $img1 \

-d $img2 \

-o reg.nii.gz \

-param step=1,type=im,algo=translation,slicewise=0,metric=MI,iter=10,gradStep=0.5:step=2,type=im,algo=bsplinesyn,slicewise=0,metric=MI,iter=20,gradStep=0.5,deformation=1x1x0 \

-v 2 \

-ofolder t2startTOt2 \

-owarp warp_t2startTOt2.nii.gz \

-r 0

sct_apply_transfo \

-i $file \

-d $ourtemplate \

-w warp1.nii.gz anat2template.nii.gz \

-o out.nii.gz

I am getting that error when running “sct_apply_transfo.”

Please help! Thanks!

Hi,
Sorry for the late response. anat2template.nii.gz is a 3D file (ie: it’s an image). A transformation should be 5D. You should instead use the file called warp_*.
Best
Julien

Hi Julien,

Thanks! That was my bad. It works now!
Best

1 Like