View source: R/plotBasicNetwork.R
plotBasicNetwork | R Documentation |
takes an object output from renderSurfaceFunction and a list of centroids and plots the centroid network over the rendering object
plotBasicNetwork(
centroids,
brain,
weights = NA,
edgecolors = -1,
backgroundColor = "white",
nodecolors = "blue",
nodetype = "s",
edgeContrast = c(0, 1),
quantileTransformWeights = FALSE,
lwd = 2,
minRadius = 0,
maxRadius = 3,
radius = NA,
showOnlyConnectedNodes = TRUE
)
centroids |
input matrix of size N 3D points ( in rows ) by 3 ( in columns ), for N nodes. |
brain |
input rendering object which is output of renderSurfaceFunction. or a function derived from renderSurfaceFunction. |
weights |
edge weights, a symmetric matrix of size N. Weights should be non-negative. |
edgecolors |
a color(map) for edges. If a color map function, weights will be transformed
to the range [0,1], which is compatible with functions returned by |
backgroundColor |
background color. |
nodecolors |
a color or color vector for nodes. |
nodetype |
sphere or other node type supported by RGL. |
edgeContrast |
a vector of length 2, specifying the contrast range for edge colors.
Weights are normalized to the range [0,1].
The normalized weights can be rescaled with this parameter, eg |
quantileTransformWeights |
quantile transform the weights. |
lwd |
line width for drawing edges. |
minRadius |
minimum node radius. Ignored if the radius is specified explicitly with |
maxRadius |
maximum node radius. The node radius between |
radius |
a constant radius or vector of length nrow(centroids). If not specified, node radius is determined by the sum of edge weights connected to the node. |
showOnlyConnectedNodes |
boolean, if |
If edgecolors
is not specified, a heat-like color palette is used. Weights
can be quantile transformed or clipped at a given quantile in order to improve
contrast.
If weights are not specified, only the nodes are plotted.
None
Avants BB, Duda JT, Cook PA
## Not run:
# more complete example
mnit <- getANTsRData("mni")
mnit <- antsImageRead(mnit)
mnia <- getANTsRData("mnia")
mnia <- antsImageRead(mnia)
mnit <- thresholdImage(mnit, 1, max(mnit))
mnit <- iMath(mnit, "FillHoles")
mnit <- thresholdImage(mnit, 1, 2)
cnt <- getCentroids(mnia, clustparam = 0)
aalcnt <- cnt[1:90, 1:3]
brain <- renderSurfaceFunction(
surfimg = list(mnit),
alphasurf = 0.1, smoothsval = 1.5
)
testweights <- matrix(rep(0, 90 * 90), nrow = 90)
testweights[31, 37] <- 1 # ant cingulate to hipp
testweights[31, 36] <- 2 # ant cingulate to post cingulate
testweights[11, 65] <- 3 # broca to angular
plotBasicNetwork(centroids = aalcnt, brain, weights = testweights, edgecolors = "red")
id <- rgl::par3d("userMatrix")
rid <- rotate3d(id, -pi / 2, 1, 0, 0)
rid2 <- rotate3d(id, pi / 2, 0, 0, 1)
rid3 <- rotate3d(id, -pi / 2, 0, 0, 1)
rgl::par3d(userMatrix = id)
dd <- make3ViewPNG(rid, id, rid2, paste("network1", sep = ""))
rgl::par3d(userMatrix = id)
# another example
mni <- getANTsRData("mni")
mni <- antsImageRead(mni)
mnit <- thresholdImage(mni, 1, max(mni))
mnit <- iMath(mnit, "FillHoles")
mniseg <- kmeansSegmentation(mni, 3)$segmentation
wmbkgd <- thresholdImage(mniseg, 3, 3) %>%
iMath("GetLargestComponent") %>%
iMath("FillHoles")
wmbkgd <- smoothImage(iMath(wmbkgd, "MD", 1), 2.0)
brain <- renderSurfaceFunction(
surfimg = list(wmbkgd),
alphasurf = 0.8, smoothsval = 1.0
)
data(powers_areal_mni_itk)
coords <- powers_areal_mni_itk[, 1:3]
id <- rgl::par3d("userMatrix")
rid <- rotate3d(id, -pi / 2, 1, 0, 0)
rid2 <- rotate3d(id, pi / 2, 0, 0, 1)
rid3 <- rotate3d(id, -pi / 2, 0, 0, 1)
rgl::par3d(userMatrix = id)
handMat2 <- t(matrix(c(
-0.9998656511, 0.01626961, 0.00198165,
0, -0.0163816363, -0.99584705, -0.08955579, 0, 0.0005163439,
-0.08957647, 0.99597979, 0, 0.0000000000, 0.00000000,
0.00000000, 1
), ncol = 4))
loccolor <- as.character(powers_areal_mni_itk$Color)
loccolor[loccolor == "Peach"] <- "sienna1"
loccolor[loccolor == "Cyan"] <- "cyan"
loccolor[loccolor == "Orange"] <- "orange"
loccolor[loccolor == "Purple"] <- "darkorchid1"
loccolor[loccolor == "Pink"] <- "deeppink"
loccolor[loccolor == "Red"] <- "red"
loccolor[loccolor == "Gray"] <- "gray74"
loccolor[loccolor == "Teal"] <- "turquoise4"
loccolor[loccolor == "Blue"] <- "blue"
loccolor[loccolor == "Yellow"] <- "yellow"
loccolor[loccolor == "Black"] <- "black"
loccolor[loccolor == "Brown"] <- "brown"
loccolor[loccolor == "Pale blue"] <- "steelblue1"
loccolor[loccolor == "Green"] <- "green"
tt <- plotBasicNetwork(
centroids = coords, brain,
nodecolors = loccolor, radius = 3
)
dd <- make3ViewPNG(handMat2, id, rid2, tempfile(fileext = ".png"))
rgl::par3d(userMatrix = id)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.