R:contour3d将网格添加到3D显示

时间:2020-04-26 13:21:01

标签: r rgl

在示例中,我使用https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4911196/处的brainR在脑图像上尝试了contour3D,但是我想在轮廓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似乎也没有执行任何操作?有什么建议?提前非常感谢!

1 个答案:

答案 0 :(得分:1)

我不确定您想要什么,但是如果您想要在显示屏周围有一个完整的方框,在刻度线上有刻度线和网格线,那么下面的代码应该可以做到。我还更改为alpha = 1,因为否则 找到令人困惑的网格线。

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个面:我觉得这种丑陋,但您的口味可能有所不同。一世 宁愿看到正面显示的外观;可以是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面显示。在此方向上看起来将相同,但是在旋转显示器时会有所不同。

相关问题