MCPcopy Create free account
hub / github.com/Kaggle/docker-python / TestDipy

Class TestDipy

tests/test_dipy.py:13–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11from dipy.viz import window, actor
12
13class TestDipy(unittest.TestCase):
14 def test_scene(self):
15 xyz = 10 * np.random.rand(100, 3)
16 colors = np.random.rand(100, 4)
17 radii = np.random.rand(100) + 0.5
18
19 sphere_actor = actor.sphere(centers=xyz, colors=colors, radii=radii)
20
21 scene = window.Scene()
22 scene.add(sphere_actor)
23
24 self.assertEqual((0, 0), scene.GetSize())
25
26 def test_graph(self):
27 g = Graph()
28 g.add_node('a', 5)
29 g.add_node('b', 6)
30 self.assertEqual(2, len(g.node))
31
32 # From: https://github.com/nipy/dipy/blob/51234a4437638535ff8f6e5819e14ccf7e1d1483/dipy/tracking/tests/test_fbc.py
33 def test_fbc(self):
34 """Test the FBC measures on a set of fibers"""
35
36 # Generate two fibers of 10 points
37 streamlines = []
38 for i in range(2):
39 fiber = np.zeros((10, 3))
40 for j in range(10):
41 fiber[j, 0] = j
42 fiber[j, 1] = i*0.2
43 fiber[j, 2] = 0
44 streamlines.append(fiber)
45
46 # Create lookup table.
47 # A fixed set of orientations is used to guarantee deterministic results
48 D33 = 1.0
49 D44 = 0.04
50 t = 1
51 sphere = Sphere(xyz=np.array([[0.82819078, 0.51050355, 0.23127074],
52 [-0.10761926, -0.95554309, 0.27450957],
53 [0.4101745, -0.07154038, 0.90919682],
54 [-0.75573448, 0.64854889, 0.09082809],
55 [-0.56874549, 0.01377562, 0.8223982]]))
56 k = EnhancementKernel(D33, D44, t, orientations=sphere,
57 force_recompute=True)
58
59 # run FBC
60 fbc = FBCMeasures(streamlines, k, verbose=True)
61
62 # get FBC values
63 fbc_sl_orig, clrs_orig, rfbc_orig = \
64 fbc.get_points_rfbc_thresholded(0, emphasis=0.01)
65
66 # check mean RFBC against tested value
67 npt.assert_almost_equal(np.mean(rfbc_orig), 1.0500466494329224, decimal=4)
68
69

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected