Setting/Changing Voxel Dimensions - Time

Hi All,

I have another seemingly simple questions. For an existing BRIK, how would I go about changing the voxel dimensions? Curious in general but most interested in how do I change the associated time stamp in a 3D+t data set. I’ve read through ‘3dTcat’ and saw it allows to change ‘TR’. Is that a way to set a timestamp between 3D datasets?

Thank you all!


Hi, Edwin-

For changing TR, in the sense of adjusting header information to alter the value of TR, you can use “3drefit”, which is AFNI’s program for changing (and hopefully correcting) header info. So, for your case:

3drefit -TR IN_DSET

Note that this does not create a new dset, but alters the IN_DSET that is input; so you might want to make a copy first (3dcopy …).
See 3drefit’s help on this option for more info:

-TR time        Changes the TR time to a new value (see 'to3d -help').
               ** You can also put the name of a dataset in for 'time', in
                  which case the TR for that dataset will be used.
               ** N.B.: If the dataset has slice time offsets, these will
                  be scaled by the factor newTR/oldTR. This scaling does not
                  apply if you use '-Tslices' in the same 3drefit run.

For changing voxel sizes, there are different ways to do this, depending on what you want the process to do. If you think the header has the wrong information and you want to correct it, again 3drefit is your tool of choice. There is some important subtlety to note in this, because the origin of the dset will likely change on you (the “location” of every voxel is really its centroid, so changing voxel dimensions changes the centroid location, including of the “origin” voxel); here is a bit of 3drefit’s help about these topics:

-xdel dimx      Makes the size of the voxel the given dimension,
  -ydel dimy      for the given axis (x,y,z); dimensions in mm.
  -zdel dimz   ** WARNING: if you change a voxel dimension, you will
                  probably have to change the origin as well.
  -keepcen        When changing a voxel dimension with -xdel (etc.),
                  also change the corresponding origin to keep the
                  center of the dataset at the same coordinate location.
  -xyzscale fac   Scale the size of the dataset voxels by the factor 'fac'.
                  This is equivalent to using -xdel, -ydel, -zdel together.
                  -keepcen is used on the first input dataset, and then
                  any others will be shifted the same amount, to maintain
                  their alignment with the first one.
               ** WARNING: -xyzscale can't be used with any of the other
                  options that change the dataset grid coordinates!
               ** N.B.: 'fac' must be positive, and using fac=1.0 is stupid.

If you want to change the voxel size in order to just resample the data to a new grid (i.e., you don’t think the current voxel size is incorrect, you just want it the dset to have a different grid for some reason), then you can use 3dresample; note that you choose the “resampling mode” for how interpolation happens-- see the help about the “-rmode …” option. Note that you can also specify a dset whose grid you want your input to be resampled to-- that is done with the “-master …” option.

Note that you can also use 3dAllineate to resample, by specifying “-1Dmatrix_apply IDENTITY” (where the string “IDENTITY” really is that set of characters-- it’s a keyword); this might be useful if you want to interpolate with the wsinc5 function, which preserves the greatest sharpness/edginess for floating point dsets-- you could do this with using this option in 3dAllineate: “-final wsinc5”.

Note that we also have a “classified” list of programs in AFNI-- i.e., we have grouped (=classified) programs by what they do-- this might be a useful reference for you:


Hi PT,

Thank you so much for the response. Works great!