Python,将1d数据投影和内插到3d网格(头部表面EEG功率)

时间:2019-07-01 12:49:26

标签: python arrays numpy matplotlib spatial-interpolation

我有一个用于26个EEG通道的1d数组(EEG电压),我也具有EEG通道的3d坐标。

x = np.array([  84.06,   83.74,   41.69,   51.87,   57.01,   51.84,    
    41.16, 21.02,   24.63,   21.16,  -16.52,  -13.25,  -11.28,    
   -12.8 , -16.65,  -48.48,  -48.77,  -48.35,  -75.17,  -80.11,     
   -82.23, -80.13,  -75.17, -114.52, -117.79, -114.68])                                                                                                                           

y = np.array([-26.81,  29.41, -66.99, -48.05,   0.9 ,  50.38,      
    68.71, -58.83, 0.57,  60.29, -83.36, -65.57,   0.23,  66.5 ,   
   -65.51, -0.42,  65.03, -71.46, -55.07,  -0.87,  53.51,  71.1 , 
   -28.98, -1.41,  26.89])

z = np.array([-10.56, -10.04, -15.96,  39.87,  66.36,  41.33, -15.31, 
    54.82, 87.63,  55.58, -12.65,  64.98,  99.81,  65.11, -11.79,     
    68.57, 98.37,  68.57,  -3.7 ,  59.44,  82.43,  59.4 ,  -3.69,      
    9.67, 15.84, 9.45])

data = [  884007.64101968,   997175.31684776,   853520.29922077,
    1146032.72839618,  1280654.00515894,  1136783.42927035,
     781802.02852187,  1165581.44354253,  1474539.74412991,
    1074018.46853295,   578909.21492644,  1067652.55432892,
    1508963.49572301,  1012764.69535714,   533385.60827991,
    1058268.82537597,  1392128.01175867,  1043996.55697014,
     675548.3896822 ,  1022400.8910867 ,  1360502.28709052,
    1108773.44991746,   780841.92929488,   986799.48807626,
     947189.96382125,   994734.32179115])

现在,我想根据通道位置(x,y和z)将1d数组(数据)投影到3d插值曲面上。

我的问题是我不知道如何将1d向量整形为既反映点的位置又反映点的值的3d数组,然后对其进行插值以绘制更易解释的图。另外,我还可以在绘制它时使用一些帮助。

我正在使用> python 3,为了进行绘图,我主要使用matplotlib。

使用scipy.interpolate.griddata进行2d插值(最终使2d弹出)。

N=300
xy_center = [np.min(x)+((np.max(x)-np.min(x))/2),np.min(y)+((np.max(y)-    
np.min(y))/2)]   # center of the plot
radius = ((np.max(x)-np.min(x))/2)        # radius

z = data

xi = numpy.linspace(np.min(x), np.max(x), N)
yi = numpy.linspace(np.min(y), np.max(y), N)
zi = scipy.interpolate.griddata((x, y), z, (xi[None,:], yi[:,None]),     
method='cubic')

尝试对data.shape和坐标不进行类似的3d插值。

d = data

xi = numpy.linspace(np.min(x), np.max(x), N)
yi = numpy.linspace(np.min(y), np.max(y), N)
zi = numpy.linspace(np.min(z), np.max(z), N)

int = scipy.interpolate.griddata((x, y, z), z, (xi[None,:],     
      yi[:,None],zi[:, None]), method='cubic')

我知道在此处选择轴上的最小/最大值也不是正确的做法,但是我不确定还有什么要做。

我确实弄清楚了如何制作通道的x,y,z坐标的3d散点图。

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

ax.scatter(x, y, z)
plt.show()

很抱歉我不太精确,但是我完全处于黑暗中。...

0 个答案:

没有答案