R でマウスの脳の領域の3D図を作成
#R #Figure #macOS
Aim
マウスの脳全体を透過っぽく表示して,目的の領域を別の色で示すような図を作る
R の cocoframer が良さそう
基本は,Allen のデータ(ccf_2017) を利用している.2020 は未対応?
mouselightr っていうのもある
Matlab だと BrainMesh
python だと BrainRender
Install R, Rstudio
R(と RStudio )をインストール
Ubuntu の場合
Install packages
code:install cocoframer.R
#devtools なければ
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
#install the latest rbokeh
devtools::install_github("bokeh/rbokeh")
#rbokeh install できたら
devtools::install_github("AllenInstitute/cocoframer")
Run demos
インストールできたら,デモでやってみる.
code:Demo.R
library(cocoframer)
library(purrr)
library(rgl)
#脳全体: root
#上丘: SC
#上丘(感覚領域): SCs
#下丘: IC
#Auditory cortex: AUD
# Primary audotory cortex: AUDp
#Visual cortex: VIS
# Primary visual cortex: VISp
#領域の名称は BrainExploer で確認?
#https://github.com/cortex-lab/allenCCF/blob/master/FP_table_Chon_2020.csv
structures <- c("root","SCs", "VISp")
mesh_list <- map(structures, ccf_2017_mesh)
names(mesh_list) <- structures
plot_ccf_meshes(mesh_list,
fg_structure = c("SCs","VISp"), #複数の場合はリストc() で指定
fg_color = c("magenta", "cyan"), #指定領域の色(c())
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