Reputation: 1258
I am trying out contour3D on a brain image in the example using brainR at https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4911196/but I wanted to add a grid to contour 3D.
Here is a reproducible example:
require(brainR)
# Template from MNI152 from McGill
template <- readNIfTI(system.file("MNI152_T1_2mm_brain.nii.gz",
package="brainR"), reorient=FALSE)
contour3d(template, level = 4500, alpha = 0.1, draw = TRUE)
Now, I would liketo draw a box around the display and a grid for that box. How do I do this? I tried to add a box, but even addbox=T does not seem to do anything? Any suggestions? Many thanks in advance!
Upvotes: 0
Views: 381
Reputation: 44957
I'm not sure what you want, but if you want a full box around the display with tick marks and grid lines at the ticks, the code below should do it. I've also changed to alpha = 1
because otherwise I
find the grid lines confusing.
require(brainR)
# Template from MNI152 from McGill
template <- readNIfTI(system.file("MNI152_T1_2mm_brain.nii.gz",
package="brainR"), reorient=FALSE)
contour3d(template, level = 4500, alpha = 1, draw = TRUE)
decorate3d()
grid3d(c("x-", "x+", "y-", "y+", "z-", "z+"))
This produces this output after a small rotation:
Edited in response to comments:
To display the frame without ticks and numbers, use box3d()
instead of decorate3d()
.
Adding a background colour to the cube can be done with the bbox3d()
function. By default it draws only 3 sides of the cube: I find this kind of ugly, but your taste may vary. I
prefer to see it with front-facing sides showing; that could be 3, 4, or 5 faces. Here's the code:
require(brainR)
# Template from MNI152 from McGill
template <- readNIfTI(system.file("MNI152_T1_2mm_brain.nii.gz",
package="brainR"), reorient=FALSE)
contour3d(template, level = 4500, alpha = 1, draw = TRUE)
box3d()
grid3d(c("x-", "x+", "y-", "y+", "z-", "z+"))
bbox3d(col="cyan", alpha = c(0.5, 0), shininess = 100,
draw_front = TRUE, front = "culled")
Here's what you get with the code above:
Leave off the last two arguments of the bbox3d
call for the
3-side display. It will look the same at this orientation, but will be different as you rotate the display.
Upvotes: 1