This function displays one or more 2D or 3D images, with optional click-to-navigate interactivity.

view(..., point = NULL, radiological = getOption("radiologicalView",
  FALSE), interactive = base::interactive(), crosshairs = TRUE,
  labels = TRUE, infoPanel = defaultInfoPanel)

lyr(image, scale = "grey", min = NULL, max = NULL, mask = NULL)

Arguments

...

One or more images, or "viewLayer" objects, to display.

point

A numeric vector giving the location to initially centre the view on. If crosshairs are in use, they will be placed at this point. For 3D images, this parameter also determines the planes shown in each subview.

radiological

Logical value. If TRUE, images will be displayed in the radiological convention whereby the left of the image is shown on the right; otherwise left is on the left.

interactive

Logical value. If TRUE, the user can navigate around the image by repeatedly clicking on a new centre point; otherwise the view is fixed.

crosshairs

Logical value, indicating whether crosshairs should be shown or not.

labels

Logical value, indicating whether orientation labels should be shown or not. Ignored (defaulting to FALSE) if the image is 2D or orientation information is not available.

infoPanel

A function of three arguments, which must produce a plot for the information panel of the view. defaultInfoPanel is the default, which shows the labels and values of each image at the current point. A NULL value will suppress the panel.

image

The image being shown in this layer.

scale

A character vector of colour values for the scale, or a single string naming a predefined scale: "grey" or "gray" for greyscale, "heat" for a heatmap, "rainbow" for a rainbow scale, or any of the scales defined in the shades package (see ?shades::gradient, if that package is installed). A fixed colour can be used by wrapping a string in a call to I. Ignored for RGB images.

min, max

The window minimum and maximum for the layer, i.e., the black and white points. These are ignored for RGB images. Otherwise, if NULL, the default, they are taken from the cal_min or cal_max NIfTI header fields. If either is NA, the image has no window stored in its header, or the two values are equal, then the 1st and 99th percentiles of the data are used, with values close to zero rounded to that extreme. If these values are still equal, the untrimmed range of the image data is used.

mask

A optional mask array, which may be of lower dimensionality than the main image. If specified, this is converted to logical mode and pixels that evaluate FALSE will be set to NA for that layer, meaning they will not be plotted. This operation is performed last, and so will not affect auto-windowing.

Value

lyr returns a list of class "viewLayer", to be used in a view. view is called for its side-effect of showing a view.

Note

Because of the way R's main run-loop interacts with graphics, it will not be possible to issue further commands to the terminal while interactive mode is enabled. Instructions for leaving this mode are shown by the default info panel; see also locator, which is the underlying core function.

See also

Author

Jon Clayden <code@clayden.org>

Examples

im <- readNifti(system.file("extdata", "example.nii.gz", package="RNifti"))
view(im, interactive=FALSE)

view(lyr(im, max=800), interactive=FALSE)

view(lyr(im, mask=im<800), interactive=FALSE)