Пример #1
0
def test_forward_direct():
    for args in tested_args:
        plan = Plan(**args)
        numpy.copyto(plan.x,
                     ranf_unit_shifted(plan.x.shape, plan.x.dtype))
        numpy.copyto(plan.f_hat,
                     ranf_unit_complex(plan.f_hat.shape, plan.f_hat.dtype))
        plan.precompute()
        yield check_forward_direct, plan
knots = constructRadialKnots2D(numSpokes, numSamplesPerSpoke)

# Compute analytical weights to compensate for sampling density
# For details, see "Non-Cartesian Reconstruction" by John Pauly
rr = np.arange(1 + numSamplesPerSpoke // 2)
dkr = 1.0 / (1.0 * numSamplesPerSpoke)
# Note that we leave out a factor of 2 here to account for the fact that we are only considering the disks from 0 to pi instead of 2 pi and mirroring the other half
dka = np.pi / numSpokes
w = rr * dka * dkr ** 2
w[0] = dka * dkr ** 2 / 8.0
wAnaly = np.hstack((w[::-1], w[1:]))
# Scale weights to preserve the intensity range
wAnaly = wAnaly / (nPE * oFE / Nx)

# Forward transform
plan = Plan((Nx, Ny), knots.shape[0])
np.copyto(plan.f_hat, phantom)
np.copyto(plan.x, knots)
plan.precompute()
plan.forward()
kspace = np.copy(plan.f)

# Compute point spread function
np.copyto(plan.f, np.ones(numSpokes * numSamplesPerSpoke) * \
    np.tile(wAnaly, numSpokes))
psfAnaly = np.copy(plan.adjoint())

# Compute adjoint without the sampling density compensation
np.copyto(plan.f, kspace)
fHatNoDcf = np.copy(plan.adjoint())