Mrtranform error

Hi MRtrix Development Team,

I hope this message finds you well.

I am currently working on straightening spinal cord FOD data using a warp image derived from another contrast e.g b0 that was not generated with MRtrix. However, I encountered an issue with the following error message: “The input warp image must have 3 volumes (x, y, z) in the 4th dimension.”

s4333238@cai-wks5:/90days/s4333238/mrtransform_test$ mrtransform 3392_fod_00_RPI_flip_y.nii.gz -template straight_ref.nii.gz fod_reg.mif -reorient_fod yes -warp_full warp_straight2curve.nii.gz -force
mrtransform: [WARNING] existing output files will be overwritten
mrtransform: [WARNING] warp_full image is not in original .mif/.mih file format or in NIfTI file format with associated JSON.  Converting to other file formats may remove linear transformations stored in the image header.
mrtransform: [100%] uncompressing image "warp_straight2curve.nii.gz"
mrtransform: [100%] preloading data for "warp_straight2curve.nii.gz"
mrtransform: [ERROR] the input warp image must have 3 volumes (x,y,z) in the 4th dimension.
s4333238@cai-wks5:/90days/s4333238/mrtransform_test$ 

Could you please confirm whether my approach using the mrtransform command is correct? Additionally, I would greatly appreciate any suggestions or recommendations to address this issue.
I have included all relevant header information for my input files with the mrtransform command below for your reference.

input fod header

Image name:          "3392_fod_00_RPI_flip_y.nii.gz"
Dimensions:        256 x 256 x 1024
  Voxel size:        0.078125 x 0.078125 x 0.078125
  Data strides:      [ -1 2 3 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0        -9.8
                               -0           1           0      -16.92
                               -0           0           1      -39.92
  comments:          2203.12-dirty 2024-02-01T16:17:47+00:00

template/reference header info

Image name:          "straight_ref.nii.gz"
************************************************
  Dimensions:        127 x 127 x 517
  Voxel size:        0.15625 x 0.15625 x 0.15625
  Data strides:      [ -1 2 3 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         64 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0      -9.644
                               -0           1           0      -16.84
                               -0           0           1      -40.47

warp header info

Image name:          "warp_straight2curve.nii.gz"
************************************************
  Dimensions:        256 x 256 x 1040 x 1 x 3
  Voxel size:        0.078125 x 0.078125 x 0.078125 x 1 x 1
  Data strides:      [ -1 2 3 5 4 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0        -9.8
                               -0           1           0      -16.92
                               -0           0           1      -40.55

Thank you so much for your invaluable feedback, continued support, and guidance. I look forward to hearing your thoughts.

Cheers,

Ibrahim

Hi Ibrahim,
I am not an expert, but as far as I know, your mrtransform implementation is correct; however, your warp_full is not. If you read the mrregister documentation under the non-linear registration options: " -nl_warp_full image output all warps used during registration. This saves four different warps that map each image to a midway space and their inverses in a single 5D image file. The 4th image dimension indexes the x,y,z component of the deformation vector and the 5th dimension indexes the field in this order: image1->midway, midway->image1, image2->midway, midway->image2."

I generated a warp_full between two images using mrregister to provide an example of the header.

************************************************
Image name:          "full_warp.mif"
************************************************
  Dimensions:        157 x 216 x 118 x 3 x 4
  Voxel size:        2.19293 x 1.72913 x 2.59049 x ? x ?
  Data strides:      [ 1 2 3 4 5 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:               0.9955     0.09221     0.02385      -193.6
                          -0.0887      0.9887     -0.1207      -163.7
                         -0.03471       0.118      0.9924        -160
  command_history:   mrregister bzero.nii.gz T1w_acpc_dc_brain.nii.gz -nl_warp_full full_warp.mif  (version=3.0.4)
  fod_reorientation: 0
  linear1:           0.7213731426468355  0.50998857531957775 -0.41561243659807734   7.7662337451897194
                     -0.42939443914946307  0.92832470037821968  0.50778213421605434  -6.5330207505586078
                     0.54234371995936814 0.024882082899081448  0.98360660926065424  -8.4106971478621588
  linear2:           0.73863111298290851 -0.41995387806167539  0.52889981440800027  -4.0315331140031958
                     0.57234243851786704  0.76691452316883424 -0.15407873073258405 -0.73058620717364287
                     -0.421746878873211  0.21215485513480972  0.72893807358427198   10.792274290024412
  mrtrix_version:    3.0.4
  nl_disp_smooth:    1
  nl_gradient_step:  0.5
  nl_niter:          [ 50 50 50 ]
  nl_scale:          [ 0.25 0.5 1 ]
  nl_update_smooth:  2

You may want to try recalculating your warp_full.

1 Like

Hi @Sebastian_Navarrete,
Thank you very much for your valuable information, and Merry Christmas to everyone!

I wanted to refer to this note:
“I am currently working on straightening spinal cord FOD data using a warp image derived from another contrast (e.g., b0) that was not generated with MRtrix or mrregister.”

While I understand that using mrregister would likely yield the same results with minimal effort, my question is how to optimize this process for compatibility with other applications. Specifically, I’m looking for a method to ensure that the warped b0 or T1 data preserves its 3 volumes in the 4-dimensional space. This requires careful inspection of all header outputs above from the Spinal Cord Toolbox software. I am seeking a way to address this issue using mrtrix.

Please note that I can straighten the FOD map using the same application; however, I am unable to reorient the FOD except through mrtransform.

I’d greatly appreciate any further insights from you or other experts, such as @rsmith, @bjeurissen, @jdtournier, or @ThijsDhollander, might have to help address this issue.

Thank you again for your valuable input, and I look forward to hearing your thoughts!

Cheers,
Ibrahim