def test_cut_plane(): dt = np.dtype(np.float32) refx = np.array([[0,0,0],[1,0,0],[2,0,0],[3,0,0]],dtype=dt) bundlex = [np.array([[0.5,1,0],[1.5,2,0],[2.5,3,0]],dtype=dt), np.array([[0.5,2,0],[1.5,3,0],[2.5,4,0]],dtype=dt), np.array([[0.5,1,1],[1.5,2,2],[2.5,3,3]],dtype=dt), np.array([[-0.5,2,-1],[-1.5,3,-2],[-2.5,4,-3]],dtype=dt)] expected_hit0 = [ [ 1. , 1.5 , 0. , 0.70710683, 0. ], [ 1. , 2.5 , 0. , 0.70710677, 1. ], [ 1. , 1.5 , 1.5 , 0.81649661, 2. ]] expected_hit1 = [ [ 2. , 2.5 , 0. , 0.70710677, 0. ], [ 2. , 3.5 , 0. , 0.70710677, 1. ], [ 2. , 2.5 , 2.5 , 0.81649655, 2. ]] hitx=pf.cut_plane(bundlex,refx) yield assert_array_almost_equal, hitx[0], expected_hit0 yield assert_array_almost_equal, hitx[1], expected_hit1 # check that algorithm allows types other than float32 bundlex[0] = np.asarray(bundlex[0], dtype=np.float64) hitx=pf.cut_plane(bundlex,refx) yield assert_array_almost_equal, hitx[0], expected_hit0 yield assert_array_almost_equal, hitx[1], expected_hit1 refx = np.asarray(refx, dtype=np.float64) hitx=pf.cut_plane(bundlex,refx) yield assert_array_almost_equal, hitx[0], expected_hit0 yield assert_array_almost_equal, hitx[1], expected_hit1
def test_cut_plane(): dt = np.dtype(np.float32) refx = np.array([[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0]], dtype=dt) bundlex = [ np.array([[0.5, 1, 0], [1.5, 2, 0], [2.5, 3, 0]], dtype=dt), np.array([[0.5, 2, 0], [1.5, 3, 0], [2.5, 4, 0]], dtype=dt), np.array([[0.5, 1, 1], [1.5, 2, 2], [2.5, 3, 3]], dtype=dt), np.array([[-0.5, 2, -1], [-1.5, 3, -2], [-2.5, 4, -3]], dtype=dt) ] expected_hit0 = [[1., 1.5, 0., 0.70710683, 0.], [1., 2.5, 0., 0.70710677, 1.], [1., 1.5, 1.5, 0.81649661, 2.]] expected_hit1 = [[2., 2.5, 0., 0.70710677, 0.], [2., 3.5, 0., 0.70710677, 1.], [2., 2.5, 2.5, 0.81649655, 2.]] hitx = pf.cut_plane(bundlex, refx) yield assert_array_almost_equal, hitx[0], expected_hit0 yield assert_array_almost_equal, hitx[1], expected_hit1 # check that algorithm allows types other than float32 bundlex[0] = np.asarray(bundlex[0], dtype=np.float64) hitx = pf.cut_plane(bundlex, refx) yield assert_array_almost_equal, hitx[0], expected_hit0 yield assert_array_almost_equal, hitx[1], expected_hit1 refx = np.asarray(refx, dtype=np.float64) hitx = pf.cut_plane(bundlex, refx) yield assert_array_almost_equal, hitx[0], expected_hit0 yield assert_array_almost_equal, hitx[1], expected_hit1
def refconc(brain, ref, divergence_threshold=0.3, fibre_weight=0.7): ''' given a reference fibre locates the parallel fibres in brain (tracks) with threshold_hitdata applied to cut_planes output then follows with concentration to locate the locus of a neck ''' hitdata = pf.cut_plane(brain, ref) reduced_hitdata, heavy_weight_fibres = threshold_hitdata(hitdata, divergence_threshold, fibre_weight) #index, centre, log_max_concentration = max_concentration(reduced_hitdata, ref) index=None centre=None log_max_concentration=None return heavy_weight_fibres, index, centre