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,
alpha = 1,
label = NULL,
dict = NULL
)
lyr returns a list of class "viewLayer", to be used
in a view. view is called for its side-effect of showing a view.
One or more images, or "viewLayer" objects, to display.
These will be plotted in the order specified, so that the first image
forms the lowest layer.
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.
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.
Logical value. If TRUE, the user can navigate
around the image by repeatedly clicking on a new centre point; otherwise
the view is fixed.
Logical value, indicating whether crosshairs should be shown or not.
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.
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.
The image being shown in this layer.
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. If a named
character vector is given instead, it is taken to be a lookup table
assigning specific colours to specific numerical values (named by the
value, as for dict), for categorical images such as atlases or
parcellations; any value without a matching name will not be shown.
Ignored for RGB images.
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.
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.
A single opacity value, between 0 (fully transparent) and 1
(fully opaque, the default), to apply to the layer's colour scale.
Setting this requires the shades package.
An optional character string overriding the default label for
the layer, which is otherwise obtained by deparsing the image
argument.
An optional named vector or list giving a dictionary of labels for particular numerical values in the image, for layers whose values are categorical rather than continuous (e.g., an atlas image with regions of interest indicated by integer codes). Names should be the numeric codes, coerced to strings, and values the corresponding labels. If given, these labels will be shown instead of raw numbers in the default information panel.
Jon Clayden <code@clayden.org>
defaultInfoPanel, orientation,
locator
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)
Run the code above in your browser using DataLab