如何在mayavi p中渲染3D大脑图像

2024-04-19 22:24:16 发布

您现在位置:Python中文网/ 问答频道 /正文

一个大脑区域的网络图。我想得到类似于图1的东西。在

Figure 1

我能够在三维空间中放置点,并通过使用python和mayavi将它们与edge链接起来。代码在这里:

import mayavi    

# get data
xyz = getCoords(file_coords)
communities = getCommunities(file_communities)    

mlab.figure(1, bgcolor=(0, 0, 0))
mlab.clf()

# plot points
pts = mlab.points3d(xyz[:,0], xyz[:,1], xyz[:,2],
                    communities,
                    colormap= "Blues",
                    scale_factor=7,
                    resolution=50)

# plot edges            
pts.mlab_source.dataset.lines = np.array(list_of_edges)
tube = mlab.pipeline.tube(pts, tube_radius=0.1)
mlab.pipeline.surface(tube, color=(0.5, 0.5, 0.5))

mlab.show()

您可以在这里看到代码的输出,如图2所示:

(不要考虑顶部的箭头和曲线,因为它们只是试图创建某种方向) Figure 2

我如何创建一个3D大脑渲染,以获得类似于图1的东西:


Tags: 代码区域pipelineplotptsfile网络图mayavi