Example #1
0
def test_fractional_anisotropy():
    """
    Test the calculation of FA
    """
    # Test this both with and without numexpr, if you can:
    try:
        import numexpr
        has_numexpr = True
    except ImportError:
        has_numexpr = False

    if has_numexpr:
        for tst_numexpr in [False, True]:
            ozu.has_numexpr = tst_numexpr
            npt.assert_almost_equal(ozu.fractional_anisotropy(1, 0, 0), 1)
            npt.assert_almost_equal(ozu.fractional_anisotropy(1, 1, 1), 0)
    else:
        npt.assert_almost_equal(ozu.fractional_anisotropy(1, 0, 0), 1)
        npt.assert_almost_equal(ozu.fractional_anisotropy(1, 1, 1), 0)
Example #2
0
def test_fractional_anisotropy():
    """
    Test the calculation of FA
    """
    # Test this both with and without numexpr, if you can: 
    try:
        import numexpr
        has_numexpr = True
    except ImportError:
        has_numexpr = False

    if has_numexpr:
        for tst_numexpr in [False,True]:
            ozu.has_numexpr = tst_numexpr
            npt.assert_almost_equal(ozu.fractional_anisotropy(1,0,0), 1)
            npt.assert_almost_equal(ozu.fractional_anisotropy(1,1,1), 0)
    else:
            npt.assert_almost_equal(ozu.fractional_anisotropy(1,0,0), 1)
            npt.assert_almost_equal(ozu.fractional_anisotropy(1,1,1), 0)
Example #3
0
    def fractional_anisotropy(self):
        """
        .. math::

            FA = \sqrt{\frac{1}{2}\frac{(\lambda_1-\lambda_2)^2+(\lambda_1-
                        \lambda_3)^2+(\lambda_2-lambda_3)^2}{\lambda_1^2+
                        \lambda_2^2+\lambda_3^2} }

        """
        out = ozu.nans(self.data.shape[:3])
        
        lambda_1 = self.evals[..., 0][self.mask]
        lambda_2 = self.evals[..., 1][self.mask]
        lambda_3 = self.evals[..., 2][self.mask]

        out[self.mask] = ozu.fractional_anisotropy(lambda_1, lambda_2, lambda_3)

        return out
Example #4
0
    def fractional_anisotropy(self):
        """
        .. math::

            FA = \sqrt{\frac{1}{2}\frac{(\lambda_1-\lambda_2)^2+(\lambda_1-
                        \lambda_3)^2+(\lambda_2-lambda_3)^2}{\lambda_1^2+
                        \lambda_2^2+\lambda_3^2} }

        """
        out = ozu.nans(self.data.shape[:3])

        lambda_1 = self.evals[..., 0][self.mask]
        lambda_2 = self.evals[..., 1][self.mask]
        lambda_3 = self.evals[..., 2][self.mask]

        out[self.mask] = ozu.fractional_anisotropy(lambda_1, lambda_2,
                                                   lambda_3)

        return out