How to resample T1w image?

Hello,

I am trying to resample the T1w.nii.gz as func.nii.gz
Here are some specifications about T1w.nii.gz
dim1: 227 dim2: 272 dim3: 227 pixdim1: 0.8 mm pixdim2: 0.8 mm pixdim3: 0.8 mm SForm code: MNI152 QForm code: MNI152
Here are some specifications about func.nii.gz
dim1: 91 dim2: 109 dim3: 91 dim4: 478 pixdim1: 2 mm pixdim2: 2 mm pixdim3: 2 mm SForm code: MNI152 QForm code: MNI152
How can I make both the resolution and dimensions (x,y,z) T1w.nii.gz same as func.nii.gz?
I tried the following
1) fsl.utils.image.resample — fslpy 3.10.0 documentation (ox.ac.uk) this can be also done in fsleyes under Tools->Resample image and select image of reference from which resampling will be done
image

2) FSL FLIRT

3) FSL FNIRT

4) [AFNI Resample] did not work no errors or warnings but it just returned the same T1w.nii.gz (Neuroimaging in Python - Pipelines and Interfaces — nipy pipeline and interfaces package)

so, from the above options 1, 2, 3 worked but I am not sure which method produces the most accurate result from the above methods of resampling T1w.nii.gz? May i please get some guidance?
thank you

Interesting question! I think there are as many resampling functions as there are imaging tools out there :wink:

They should all produce more or less the same result but what makes the difference is the interpolation choice: nearest neighbour, trilinear, spline, …

The choice is yours depending on which one is easier to use for you I think!

1 Like

Hi-

What was your 3dresample command?

How about:

3dresample                            \
    -input T1w.nii.gz                 \
    -master func.nii.gz               \
    -prefix T1w_like_func.nii.gz

? You can check if the outputs have the same header properties as well with:

3dinfo -same_all_grid func.nii.gz T1w_like_func.nii.gz

As @jsein mentioned, a key additional point is deciding an appropriate interpolant kernel. The option to specify this in 3dresample is -rmode ... From the program help:

    -rmode RESAM     : use this resampling method
          e.g.  -rmode Linear
          default is NN (nearest neighbor)

          The resampling method string RESAM should come
          from the set {'NN', 'Li', 'Cu', 'Bk'}.  These
          are for 'Nearest Neighbor', 'Linear', 'Cubic'
          and 'Blocky' interpolation, respectively.

          For details, go to the 'Define Datamode' panel
          of the afni GUI, click BHelp and then the
          'ULay resam mode' menu.

For a T1w dset, I guess you might want to use -rmode Cu, for cubic interpolation (the default “NN” is most desirable for integer-valued dsets, like atlases and other ROI maps).

For an interpolant that preserves edges more sharply, you could use a sinc-based interpolant; in AFNI, there is what we call wsinc5, for deep, dark, secret reasons lost to the mists of time. This interpolant does not exist in 3dresample, but you could use an alternative 3dAllineate command as follows, invoking an identity-matrix “warp” (a special case of affine: the data doesn’t ‘move’, it essentially just triggers resampling with the chosen kernel):

3dAllineate                                \
    -input  T1w.nii.gz                     \
    -master func.nii.gz                    \
    -prefix T1w_in_func_wsinc5.nii.gz      \
    -1Dparam_apply IDENTITY                \
    -final         wsinc5

(Above, the all-caps “IDENTITY” is really the keyword to use, not a placeholder or something.)

–pt

1 Like