def push_backward(echoes, voxshift, ivoxshift, extrapolate, out=None): """Push echoes "backward" (reversed gradient)""" if out is None: out = torch.zeros_like(echoes) if extrapolate: if voxshift is None: if not utils.same_storage(out, echoes): out.copy_(echoes) return out out[0::2] = push1d(echoes[0::2], ivoxshift) out[1::2] = push1d(echoes[1::2], voxshift) else: if voxshift is None: if not utils.same_storage(out, echoes): out[1:-1].copy_(echoes[1:-1]) return out out[2::2] = push1d(echoes[2::2], ivoxshift) out[1:-1:2] = push1d(echoes[1:-1:2], voxshift) return out
def push_forward(echoes, voxshift, ivoxshift, out=None): """Push echoes "forward" (nonreversed gradient)""" if out is None: out = torch.empty_like(echoes) if voxshift is None: if not utils.same_storage(out, echoes): out.copy_(echoes) return out out[0::2] = push1d(echoes[0::2], voxshift) out[1::2] = push1d(echoes[1::2], ivoxshift) return out