Пример #1
0
def test_orthogonality_basis_functions():
    # numerical integration parameters
    diffusivity = 0.0015
    qmin = 0
    qmax = 1000

    int1 = integrate.quad(
        lambda x: np.real(mapmri.mapmri_phi_1d(0, x, diffusivity)) * np.real(
            mapmri.mapmri_phi_1d(2, x, diffusivity)), qmin, qmax)[0]
    int2 = integrate.quad(
        lambda x: np.real(mapmri.mapmri_phi_1d(2, x, diffusivity)) * np.real(
            mapmri.mapmri_phi_1d(4, x, diffusivity)), qmin, qmax)[0]
    int3 = integrate.quad(
        lambda x: np.real(mapmri.mapmri_phi_1d(4, x, diffusivity)) * np.real(
            mapmri.mapmri_phi_1d(6, x, diffusivity)), qmin, qmax)[0]
    int4 = integrate.quad(
        lambda x: np.real(mapmri.mapmri_phi_1d(6, x, diffusivity)) * np.real(
            mapmri.mapmri_phi_1d(8, x, diffusivity)), qmin, qmax)[0]

    # checking for first 5 basis functions if they are indeed orthogonal
    assert_almost_equal(int1, 0.)
    assert_almost_equal(int2, 0.)
    assert_almost_equal(int3, 0.)
    assert_almost_equal(int4, 0.)

    # do the same for the isotropic mapmri basis functions
    # we already know the spherical harmonics are orthonormal
    # only check j>0, l=0 basis functions
    C1 = mapmri.mapmri_isotropic_radial_pdf_basis(1, 0, diffusivity, 0)
    C2 = mapmri.mapmri_isotropic_radial_pdf_basis(2, 0, diffusivity, 0)
    C3 = mapmri.mapmri_isotropic_radial_pdf_basis(3, 0, diffusivity, 0)
    C4 = mapmri.mapmri_isotropic_radial_pdf_basis(4, 0, diffusivity, 0)
    C5 = mapmri.mapmri_isotropic_radial_pdf_basis(4, 0, diffusivity, 0)

    int1 = integrate.quad(
        lambda q: mapmri.mapmri_isotropic_radial_signal_basis(
            1, 0, diffusivity, q) * mapmri.
        mapmri_isotropic_radial_signal_basis(2, 0, diffusivity, q) * q**2,
        qmin, qmax)[0]
    int2 = integrate.quad(
        lambda q: mapmri.mapmri_isotropic_radial_signal_basis(
            2, 0, diffusivity, q) * mapmri.
        mapmri_isotropic_radial_signal_basis(3, 0, diffusivity, q) * q**2,
        qmin, qmax)[0]
    int3 = integrate.quad(
        lambda q: mapmri.mapmri_isotropic_radial_signal_basis(
            3, 0, diffusivity, q) * mapmri.
        mapmri_isotropic_radial_signal_basis(4, 0, diffusivity, q) * q**2,
        qmin, qmax)[0]
    int4 = integrate.quad(
        lambda q: mapmri.mapmri_isotropic_radial_signal_basis(
            4, 0, diffusivity, q) * mapmri.
        mapmri_isotropic_radial_signal_basis(5, 0, diffusivity, q) * q**2,
        qmin, qmax)[0]

    # checking for first 5 basis functions if they are indeed orthogonal
    assert_almost_equal(int1, 0.)
    assert_almost_equal(int2, 0.)
    assert_almost_equal(int3, 0.)
    assert_almost_equal(int4, 0.)
Пример #2
0
def test_orthogonality_basis_functions():
    # numerical integration parameters
    diffusivity = 0.0015
    qmin = 0
    qmax = 1000

    int1 = integrate.quad(lambda x:
                          np.real(mapmri.mapmri_phi_1d(0, x, diffusivity)) *
                          np.real(mapmri.mapmri_phi_1d(2, x, diffusivity)),
                          qmin, qmax)[0]
    int2 = integrate.quad(lambda x:
                          np.real(mapmri.mapmri_phi_1d(2, x, diffusivity)) *
                          np.real(mapmri.mapmri_phi_1d(4, x, diffusivity)),
                          qmin, qmax)[0]
    int3 = integrate.quad(lambda x:
                          np.real(mapmri.mapmri_phi_1d(4, x, diffusivity)) *
                          np.real(mapmri.mapmri_phi_1d(6, x, diffusivity)),
                          qmin, qmax)[0]
    int4 = integrate.quad(lambda x:
                          np.real(mapmri.mapmri_phi_1d(6, x, diffusivity)) *
                          np.real(mapmri.mapmri_phi_1d(8, x, diffusivity)),
                          qmin, qmax)[0]

    # checking for first 5 basis functions if they are indeed orthogonal
    assert_almost_equal(int1, 0.)
    assert_almost_equal(int2, 0.)
    assert_almost_equal(int3, 0.)
    assert_almost_equal(int4, 0.)

    # do the same for the isotropic mapmri basis functions
    # we already know the spherical harmonics are orthonormal
    # only check j>0, l=0 basis functions

    int1 = integrate.quad(lambda q:
                          mapmri.mapmri_isotropic_radial_signal_basis(
                              1, 0, diffusivity, q) *
                          mapmri.mapmri_isotropic_radial_signal_basis(
                              2, 0, diffusivity, q) * q ** 2, qmin, qmax)[0]
    int2 = integrate.quad(lambda q:
                          mapmri.mapmri_isotropic_radial_signal_basis(
                              2, 0, diffusivity, q) *
                          mapmri.mapmri_isotropic_radial_signal_basis(
                              3, 0, diffusivity, q) * q ** 2, qmin, qmax)[0]
    int3 = integrate.quad(lambda q:
                          mapmri.mapmri_isotropic_radial_signal_basis(
                              3, 0, diffusivity, q) *
                          mapmri.mapmri_isotropic_radial_signal_basis(
                              4, 0, diffusivity, q) * q ** 2, qmin, qmax)[0]
    int4 = integrate.quad(lambda q:
                          mapmri.mapmri_isotropic_radial_signal_basis(
                              4, 0, diffusivity, q) *
                          mapmri.mapmri_isotropic_radial_signal_basis(
                              5, 0, diffusivity, q) * q ** 2, qmin, qmax)[0]

    # checking for first 5 basis functions if they are indeed orthogonal
    assert_almost_equal(int1, 0.)
    assert_almost_equal(int2, 0.)
    assert_almost_equal(int3, 0.)
    assert_almost_equal(int4, 0.)