我想找到Schaefer 100 atlas脑图谱的脑区坐标,然后用nilearn的画图软件把指定的脑节点在图上标注出来。
下面是我的程序的概览,是使用nilearn库进行的画图
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 26 21:53:19 2023
@author: LB
"""
from nilearn import plotting
# import scipy.io as scio
import pylab as pl
import numpy as np
def main():
# data_path = "~\\node_distribution_TLE.mat" # 输入网络文件的地址
# data_org = scio.loadmat(data_path)
strength = [1, 2, 3, 4, 5] # 网络节点强度(n*1)
strength_list = [100 * i for i in strength] # 可以根据节点的值控制节点的大小
data_position = [[-30, -10, 20],
[10, 0, 45],
[-15, 25, -5],
[40, -5, 30],
[-5, -40, 15]] # 存放节点的MNI坐标(n*3
# data_mat = [[1,-2,3.5,1.1,-2],
# [-2,1,7,-3.5,0.8],
# [3.5,7,1,6.6,0.6],
# [1.1,-3.5,6.6,1,3.5],
# [-2,0.8,0.6,3.5,1]]
data_mat = np.zeros((len(data_position), len(data_position))) # 图个只想显示节点,可以产生了一个0矩阵
# colors = ['#B9A3AE', '#D2CCC5', '#C0BEC7', '#B0A4C2', '#D3C0BB', '#BFA58A', '#D9C6B0', '#E8DBC5', '#E6D4D1', '#E0BBE4']
node_color_list = ['#1967db', '#1c61e6', '#4c27ba', '#dd0922', '#e40a1e'] # 节点的颜色值(n*1 放置 )
# node_color_list = '#00CCCC'
figure1 = pl.figure(figsize=(12, 6))
plotting.plot_connectome(data_mat,
data_position,
node_color_list,
colorbar=False,
edge_cmap='rainbow', # 选择colormap用来显示边的强度
edge_threshold=0.0,
node_size=strength_list,
# edge_vmin=2,
# edge_vmax=3,
alpha=0.7,
figure=figure1
)
pl.savefig('.\\test2.png', dpi=600) # 输出文件的地址
plotting.show()
print('ending')
if __name__ == '__main__':
main()