-
Notifications
You must be signed in to change notification settings - Fork 35
/
plot.antsImage.Rd
162 lines (131 loc) · 4.41 KB
/
plot.antsImage.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.antsImage.R
\name{plot.antsImage}
\alias{plot.antsImage}
\title{Plotting an image slice or multi-slice with optional color overlay.}
\usage{
\method{plot}{antsImage}(
x,
y = NULL,
color.img = "white",
color.overlay = c("jet", "red", "blue", "green", "yellow", "viridis", "magma",
"plasma", "inferno"),
axis = 2,
slices,
colorbar = FALSE,
title.colorbar,
title.img,
title.line = NA,
color.colorbar,
window.img,
window.overlay,
quality = 2,
outname = NA,
alpha = 1,
direction = 1,
begin = 0,
end = 1,
newwindow = FALSE,
nslices = 10,
domainImageMap = NULL,
ncolumns = 4,
useAbsoluteScale = FALSE,
doCropping = TRUE,
text,
...
)
}
\arguments{
\item{x}{the reference image on which to overlay.}
\item{y}{image or list of images to use as overlays.}
\item{color.img}{color for main image.}
\item{color.overlay}{the color for the overlay , e.g c('blue','red') length
of this list should match the image list.}
\item{axis}{the axis to slice (1 , 2 or 3)}
\item{slices}{vector of slices to plot (e.g., c(10, 15, 20))}
\item{colorbar}{make colorbar?}
\item{title.colorbar}{title for colorbar}
\item{title.img}{title for main image (not displayed when file is saved with outname)}
\item{title.line}{title vertical displacement (irrelevant when a file is saved with outname)}
\item{color.colorbar}{color scale to use for colorbar}
\item{window.img}{lower and upper thresholds for display of main image}
\item{window.overlay}{lower and upper thresholds for display of overlay.
if you set \code{window.overlay = c( 0, 100 )} and \code{useAbsoluteScale=T}
then the image overlay will map into that range. otherswise, the min and
max of the image will be used.}
\item{quality}{integer quality magnification factor 1 => large (e.g.
10)}
\item{outname}{name of output file if you want to write result to file, e.g.
\code{plot.jpg}.}
\item{alpha}{opacity}
\item{direction}{Sets the order of colors in the scale.
If 1, the default, colors are ordered from darkest to lightest.
If -1, the order of colors is reversed.}
\item{begin}{The (corrected) hue in [0,1] at which the viridis colormap
begins.}
\item{end}{The (corrected) hue in [0,1] at which the viridis colormap
ends}
\item{newwindow}{boolean controlling if we open a new device for this plot}
\item{nslices}{number of slices to view}
\item{domainImageMap}{this input antsImage or list contains a reference image
(\code{domainImage}) and optional reference mapping named \code{domainMap}.
these will be used to map the input image(s) to this antsImage space before
plotting. this is useful for non-standard image orientations.}
\item{ncolumns}{number of columns in plot}
\item{useAbsoluteScale}{boolean determines whether dynamic range is maximized
when visualizing overlays}
\item{doCropping}{apply cropping, defaults to \code{TRUE}}
\item{text}{vector containing x, y, label, cex and color values passed to
text command, e.g. \code{txt=list(x=0,y=0,label='my text',cex=2,col='red')}}
\item{...}{other parameters}
}
\value{
output is plot to standard R window
}
\description{
This is a plotting utility for antsImage types with a background and color
overlay option. Useful for displaying statistical results overlaid on a
background image.
}
\examples{
img <- makeImage(c(4, 4), rnorm(4 * 4))
mask <- makeImage(
c(4, 4),
as.matrix(c(
0, 0, 0, 0,
0, 1, 1, 0,
0, 1, 1, 0,
0, 0, 0, 0
), nrow = 4)
)
plot(img, list(mask))
txt <- list(x = 2.5, y = 1.5, label = "my text", cex = 4, col = "red")
plot(img, list(mask), text = txt)
testthat::expect_error(plot(multi_component_image))
\dontrun{
img <- antsImageRead(getANTsRData("r16"))
betaVals <- rnorm(prod(dim(img)), 0, 20)
betaImg <- makeImage(dim(img), betaVals) \%>\% smoothImage(3.5)
betaImg[abs(betaImg) < 1.5] <- 0
plot(img, betaImg, window.img = range(img), window.overlay = range(betaImg))
mnit <- getANTsRData("mni")
mnit <- antsImageRead(mnit)
mniafn <- getANTsRData("mnia")
mnia <- antsImageRead(mniafn)
mnia <- thresholdImage(mnia, 22, 25)
mnia <- smoothImage(mnia, 1.5)
mnia2 <- antsImageRead(mniafn)
mnia2 <- thresholdImage(mnia2, 1, 4)
mnia2 <- smoothImage(mnia2, 1.5)
ofn <- paste(tempfile(), ".png", sep = "")
# write directly to a file
plot(mnit, list(mnia, mnia2),
slices = seq(50, 140, by = 5),
window.overlay = c(0.25, 1), axis = 2,
color.overlay = c("red", "blue"), outname = ofn
)
}
}
\author{
Avants BB
}