def test_resample_astrocyte_section__double_density():
    """If we have points 1um apart with a density of 1 points per um
    then the result should the same as the input.
    """

    section = Mock(
        points=np.array([[0., 0., 0.], [1., 0., 0.], [2., 0., 0.]]),
        diameters=np.array([3., 2., 1.]),
        perimeters=np.array([1., 2., 3.])
    )

    tested._resample_astrocyte_section(section, linear_density=2.)

    npt.assert_allclose(
        section.points,
        [[0.0, 0., 0.],
         [0.5, 0., 0.],
         [1.0, 0., 0.],
         [1.5, 0., 0.],
         [2.0, 0., 0.]])
    npt.assert_allclose(section.diameters, [3., 2.5, 2., 1.5, 1.])
    npt.assert_allclose(section.perimeters, [1., 1.5, 2., 2.5, 3.])

    # let's do a full cycle now!
    tested._resample_astrocyte_section(section, linear_density=1.)

    npt.assert_allclose(
        section.points,
        [[0.0, 0., 0.],
         [1.0, 0., 0.],
         [2.0, 0., 0.]])
    npt.assert_allclose(section.diameters, [3., 2., 1.])
    npt.assert_allclose(section.perimeters, [1., 2., 3.])
Пример #2
0
def test_resample_astrocyte_section_strip():
    """Check that only the first and last points and diameters remain
    if linear_density is zero.
    """
    section = Mock(points=np.array([[0., 0., 0.], [1., 1., 1.], [2., 2., 2.]]),
                   diameters=np.array([3., 2., 1.]),
                   perimeters=np.array([1., 2., 3.]))

    tested._resample_astrocyte_section(section, linear_density=0.)

    npt.assert_allclose(section.points, [[0., 0., 0.], [2., 2., 2.]])
    npt.assert_allclose(section.diameters, [3., 1.])
    npt.assert_allclose(section.perimeters, [1., 3.])