vop.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:pyem 作者: asarnow 项目源码 文件源码
def resample_volume(vol, r=None, t=None, ori=None, order=3, compat="mrc2014", indexing="ij"):
    if r is None and t is None:
        return vol.copy()

    center = np.array(vol.shape) // 2

    x, y, z = np.meshgrid(*[np.arange(-c, c) for c in center], indexing=indexing)
    xyz = np.vstack([x.reshape(-1), y.reshape(-1), z.reshape(-1), np.ones(x.size)])

    if ori is not None:
        xyz -= ori[:, None]

    th = np.eye(4)
    if t is None and r.shape[1] == 4:
        t = np.squeeze(r[:, 3])
    elif t is not None:
        th[:3, 3] = t

    rh = np.eye(4)
    if r is not None:
        rh[:3:, :3] = r[:3, :3].T

    xyz = th.dot(rh.dot(xyz))[:3, :] + center[:, None]
    xyz = np.array([arr.reshape(vol.shape) for arr in xyz])

    if "relion" in compat.lower() or "xmipp" in compat.lower():
        xyz = xyz[::-1]

    newvol = map_coordinates(vol, xyz, order=order)
    return newvol
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号