【发布时间】:2018-12-02 18:05:15
【问题描述】:
我实际上是在尝试完成 this 然后 this 但使用 3D 矩阵,例如 (128,128,60,6)。第 4 维是一个数组向量,表示该体素处的扩散数组,例如:
d[30,30,30,:] = [dxx, dxy, dxz, dyy, dyz, dzz] = D_array
其中 dxx 等是特定方向的扩散。 D_array 也可以看作是一个三角矩阵(因为 dxy == dyx 等)。所以我可以使用这两个其他答案从 D_array 到 D_square,例如
D_square = [[dxx, dxy, dxz], [dyx, dyy, dyz],[dzx, dzy, dzz]]
我似乎无法弄清楚下一步 - 如何将 D_array 到 D_square 的单位转换应用于整个 3D 体积。
这是适用于单个张量的代码 sn-p:
#this solves an linear eq. that provides us with diffusion arrays at each voxel in a 3D space
D = np.einsum('ijkt,tl->ijkl',X,bi_plus)
#our issue at this point is we have a vector that represents a triangular matrix.
# first make a tri matx from the vector, testing on unit tensor first
D_tri = np.zeros((3,3))
D_array = D[30][30][30]
D_tri[np.triu_indices(3)] = D_array
# then getting the full sqr matrix
D_square = D_tri.T + D_tri
np.fill_diagonal(D_square, np.diag(D_tri))
那么,将 Diffusion 张量的单位变换同时公式化到整个 3D 体积的 numpy 方法是什么?
【问题讨论】:
标签: arrays python-3.x numpy