Translates a voxel index into the continuous coordinate space defined by the NIfTI qform and sform information.

translateCoordinate(i, nim, verbose = FALSE)

Arguments

i

An index vector in nim.

nim

An object of class nifti.

verbose

Provide detailed output to the user.

Value

A nifti-class object with translated coordinates.

Details

This function takes as input a nifti object and an index vector in the voxel space of the object and translates that voxel index into the continuous coordinate space defined by the object's qform and sform.

Please note:

  1. By default the index i varies most rapidly, etc.

  2. The ANALYZE 7.5 coordinate system is

    +x=Left
    +y=Anterior
    +z=Superior

    (A left-handed co-ordinate system).

  3. The three methods below give the locations of the voxel centres in the x,y,z system. In many cases programs will want to display the data on other grids. In which case the program will be required to convert the desired (x,y,z) values in to voxel values using the inverse transformation.

  4. Method 2 uses a factor qfac which is either -1 or 1. qfac is stored in pixdim[0]. If pixdim[0] != 1 or -1, which should not occur, we assume 1.

  5. The units of the xyzt are set in xyzt_units field.

Author

Andrew Thornton zeripath@users.sourceforge.net

Examples


ffd <- readNIfTI(file.path(system.file("nifti", package="oro.nifti"),
                           "filtered_func_data"))
xyz <- c(1,1,1)
translateCoordinate(xyz, ffd, verbose=TRUE)
#> Input voxel coordinate:
#>      [,1]
#> [1,]    1
#> [2,]    1
#> [3,]    1
#> QForm_code and SForm_code unset: Orientation by Method 1.
#>      [,1]
#> [1,]    0
#> [2,]    0
#> [3,]    0
xyz <- trunc(dim(ffd)[1:3]/2)
translateCoordinate(xyz, ffd, verbose=TRUE)
#> Input voxel coordinate:
#>      [,1]
#> [1,]   32
#> [2,]   32
#> [3,]   10
#> QForm_code and SForm_code unset: Orientation by Method 1.
#>      [,1]
#> [1,]   31
#> [2,]   31
#> [3,]    9