Learn R Programming

espadon (version 1.11.3)

get.plane: Extracting a plane from a volume

Description

The get.plane function extracts a plane from a "volume" class object.

Usage

get.plane(
  vol,
  origin = c(0, 0, 0),
  plane.orientation = c(1, 0, 0, 0, 1, 0),
  alias = "plane.n",
  xgrid = NULL,
  ygrid = NULL,
  interpolate = TRUE,
  method = c("NN", "Av")
)

Value

Returns a "volume" class object, containing only a single plane, at k = 0, in the same frame of reference as vol. This returned object has 2 new fields local.xgrid, and local.ygrid, representing the local grids of the abscissa (columns) and ordinate (rows) of the plane.

Returns NULL if plane doesn't exist.

Arguments

vol

"volume" class object.

origin

Vector of x, y, z coordinates, representing the origin of the plane to extract. If interpolate = FALSE, these coordinates are replaced by the coordinates of the voxel closest to origin.

plane.orientation

Vector orientation of the plane in the vol frame of reference, composed by the 2 vectors coordinates of the orthonormal basis of the plane. First vector is x-axis, and second one is y-axis.

alias

$object.alias of the created object.

xgrid

Vector, representing the grid of the plane abscissa. See note.

ygrid

Vector, representing the grid of the plane ordinates. See note. If ygrid = NULL, the ordinate is the line intercepting the volume and the step is set to the projection of vol$dxyz onto the ordinate orientation.

interpolate

Boolean, default to TRUE.

method

method of interpolation, defaulted to 'NN' ie 'Nearest Neighbor'. See Details.

Details

The interpolation method is chosen from:

  • 'NN': the value of a voxel is calculated from its nearest adajcent neighbors.

  • 'Av': the value of a voxel is the weighted average of the voxels contained in a box, whose sides are automatically calculated from the back.bol$dxyz steps.

Examples

Run this code
# loading of toy-patient objects (decrease dxyz for better result)
step <- 4
patient <- toy.load.patient (modality = "mr", dxyz = rep (step, 3))
MR <- patient$mr[[1]] 
    
# mid-volume point 
mid.point <- apply (get.extreme.pt (MR),1,mean)

plane <- get.plane (MR, origin = mid.point, interpolate = TRUE)
display.kplane (plane, interpolate = FALSE)

plane <- get.plane (MR, origin = mid.point, xgrid = seq (-50, 50, 1), 
                    ygrid = seq (-50, 50, 1), interpolate = TRUE)
display.kplane (plane, interpolate = FALSE)

# 3 points on the inclined plane
pts <- t ((MR$xyz.from.ijk %*% MR$cube.idx) [1:3 , c (1, 2, 7)])
orientation <- orientation.create (A = pts[1,], B = pts[2,], C = pts[3,])
origin <- apply (pts, 2, mean)
plane <- get.plane (MR, origin = origin, 
                    plane.orientation = orientation, interpolate = TRUE)
display.kplane (plane, interpolate = FALSE)

orientation <- orientation.create (A = c (0, 0, 0) , B = c (1, 1, 0), 
                                   C = c (-1, 1, 0))
plane <- get.plane (MR, origin = origin, 
                    plane.orientation = orientation, interpolate = TRUE) 
display.kplane (plane, interpolate = FALSE)

Run the code above in your browser using DataLab