R でマウスの脳の領域の3D図を作成
Aim
マウスの脳全体を透過っぽく表示して,目的の領域を別の色で示すような図を作る
基本は,Allen のデータ(ccf_2017) を利用している.2020 は未対応?
Install R, Rstudio
Ubuntu の場合
Install packages
code:install cocoframer.R
if (!require("devtools")) install.packages("devtools")
# install cocoframer
devtools::install_github("AllenInstitute/cocoframer")
# その他のパッケージ
install.packages("purrr")
install.packages("rgl")
package ‘rbokeh’ is not available for this version of R とエラーが出る場合は,github から開発中のものを入れてからやり直す
code: install_cocoframer.R
devtools::install_github("bokeh/rbokeh")
devtools::install_github("AllenInstitute/cocoframer")
Run demos
インストールできたら,デモでやってみる.
code:Demo.R
library(cocoframer)
library(purrr)
library(rgl)
# Primary audotory cortex: AUDp
# Primary visual cortex: VISp
structures <- c("root","SCs", "VISp")
mesh_list <- map(structures, ccf_2017_mesh)
names(mesh_list) <- structures
plot_ccf_meshes(mesh_list,
fg_alpha = c(0.4,0.4),
bg_structure = "root",
bg_alpha = 0.2)
rgl::bg3d(color = "transparent") # 背景を透明に設定
# View の向きはどう設定?
view3d(theta = 30, phi = 30) #デフォルト view3d(theta = 45, phi = 60, zoom=0.7) others
アニメーション gif を作る際に imagemagick が必要
mac の場合
brew install imagemagick
して Rで brew install したものを使う場合
単発で使用する場合は
code: R
Sys.setenv(PATH = paste(Sys.getenv("PATH"), "/opt/homebrew/bin", sep=":"))
起動時に常に path を当巣場合は,~/.Renviron に保存
code: ~/.Renviron
PATH=$PATH(/opt/homebrew/bin
Date :2025/3/27
Modified Date :
Author :lattice.icon