def vol_density(neurite): """Volume density of a single neurite.""" try: volume = convex_hull(neurite).volume except scipy.spatial.qhull.QhullError: L.exception('Failure to compute neurite volume using the convex hull. ' 'Feature `neurite_volume_density` will return `np.nan`.\n') return np.nan return neurite.volume / volume
def test_volume_density_per_neurite(): vol = np.array(_nf.total_volume_per_neurite(NRN)) hull_vol = np.array([convex_hull(n).volume for n in nm.iter_neurites(NRN)]) vol_density = _nf.volume_density_per_neurite(NRN) nt.eq_(len(vol_density), 4) nt.ok_(np.allclose(vol_density, vol / hull_vol)) ref_density = [0.43756606998299519, 0.52464681266899216, 0.24068543213643726, 0.26289304906104355] nt.ok_(np.allclose(vol_density, ref_density))
def test_neurite_volume_density(): vol = np.array(_nf.total_volume_per_neurite(NRN)) hull_vol = np.array([convex_hull(n).volume for n in nm.iter_neurites(NRN)]) vol_density = _nf.neurite_volume_density(NRN) nt.eq_(len(vol_density), 4) nt.ok_(np.allclose(vol_density, vol / hull_vol)) ref_density = [ 0.43756606998299519, 0.52464681266899216, 0.24068543213643726, 0.26289304906104355 ] assert_allclose(vol_density, ref_density)
def vol_density(neurite): '''volume density of a single neurite''' return neurite.volume / convex_hull(neurite).volume
def test_convex_hull_volume(): # This leverages scipy ConvexHull and we don't want # to re-test scipy, so simply regression test the volume hull = geom.convex_hull(NRN) assert_almost_equal(hull.volume, 208641, decimal=0)
def test_convex_hull_points(): # This leverages scipy ConvexHull and we don't want # to re-test scipy, so simply check that the points are the same. hull = geom.convex_hull(NRN) assert np.alltrue(hull.points == NRN.points[:, :3])
def vol_density(neurite): """volume density of a single neurite""" return neurite.volume / convex_hull(neurite).volume
def test_convex_hull_volume(): # This leverages scipy ConvexHull and we don't want # to re-test scipy, so simply regression test the volume hull = geom.convex_hull(NRN) nt.assert_almost_equal(hull.volume, 208641.65, places=3)
def test_convex_hull_points(): # This leverages scipy ConvexHull and we don't want # to re-test scipy, so simply check that the points are the same. hull = geom.convex_hull(NRN) nt.ok_(np.alltrue(hull.points == NRN.points[:, :3]))
def vol_density(neurite): """Volume density of a single neurite.""" return neurite.volume / convex_hull(neurite).volume