R: contour3d在3D显示中添加网格。

问题描述 投票:0回答:1

我正在尝试在示例中的大脑图像上使用brainR进行contour3D。https:/www.ncbi.nlm.nih.govpmcarticlesPMC4911196但我想在等高线3D中添加一个网格。

下面是一个可复制的例子。

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)

现在,我想在显示器周围画一个盒子,并为这个盒子画一个网格。我该怎么做呢?我试着添加一个框,但即使addbox=T似乎也没有任何作用?有什么建议吗?非常感谢

r rgl
1个回答
1
投票

我不确定你想要什么,但如果你想要一个完整的方框,在显示周围有刻度线和网格线,下面的代码应该可以做到。 我也改成了 alpha = 1 因为如果不这样做,Ifind的网格线会很混乱。

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+"))

这样在小范围旋转后就会产生这样的输出。

screenshot

根据评论编辑。

如果要显示没有刻度和数字的框架,请使用 box3d() 而不是 decorate3d().

为立方体添加背景色,可以通过使用 bbox3d() 函数。 默认情况下,它只画了立方体的3个面。 我觉得这样很丑陋 但你的口味可能会不同 I find this kind of ugly, but your taste may vary. 我更喜欢看到它的正面,可以是3个、4个或5个面。 这是代码。

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")

上面的代码是这样的:

screenshot

把最后两个参数 bbox3d 调用3面显示。 在这个方向上,它看起来是一样的,但当你旋转显示屏时,它将会有所不同。

© www.soinside.com 2019 - 2024. All rights reserved.