コード例 #1
0
 def test_reverse_directions(self):
     bc = BrainCoordinates(nxyz=(6, 7, 8), xyz0=[50, 60, 70], dxyz=[-10, -10, -10])
     self.assertTrue(bc.i2x(0) == 50 and bc.i2x(bc.nx - 1) == 0)
     self.assertTrue(bc.i2y(0) == 60 and bc.i2y(bc.ny - 1) == 0)
     self.assertTrue(np.all(bc.i2z(np.array([0, 1])) == np.array([70, 60])))
     bc = BrainCoordinates(nxyz=(6, 7, 8), xyz0=[50, 60, 70], dxyz=-10)
     self.assertTrue(bc.dx == bc.dy == bc.dz == -10)
コード例 #2
0
 def test_brain_coordinates(self):
     vshape = (6, 7, 8)
     bc = BrainCoordinates(vshape)
     self.assertTrue(bc.i2x(0) == 0)
     self.assertTrue(bc.i2x(6) == 6)
     self.assertTrue(bc.nx == 6)
     self.assertTrue(bc.ny == 7)
     self.assertTrue(bc.nz == 8)
     # test array functions
     in_out = [([6, 7, 8], np.array([6, 7, 8])),
               (np.array([6, 7, 8]), np.array([6, 7, 8])),
               (np.array([[6, 7, 8], [6, 7, 8]]), np.array([[6, 7, 8], [6, 7, 8]])),
               ]
     for io in in_out:
         self.assertTrue(np.all(bc.xyz2i(io[0]) == io[1]))
         self.assertTrue(np.all(bc.i2xyz(io[1]) == io[0]))
コード例 #3
0
 def test_exit_volume(self):
     bc = BrainCoordinates((11, 13, 15), xyz0=(-5, -6, -7))
     # test arbitrary line
     line = Trajectory.fit(np.array([[0.1, 0.1, 0], [0, 0, 1]]))
     epoints = Trajectory.exit_points(line, bc)
     self.assertTrue(np.all(np.isclose(epoints, np.array([[0.8, 0.8, -7.], [-0.6, -0.6, 7.]]))))
     # test apline
     hline = Trajectory.fit(np.array([[0, 0, 0], [0, 1, 0]]))
     epoints = Trajectory.exit_points(hline, bc)
     self.assertTrue(np.all(np.isclose(epoints, np.array([[0, -6, 0], [0, 6, 0]]))))
     # test mlline
     hline = Trajectory.fit(np.array([[0, 0, 0], [1, 0, 0]]))
     epoints = Trajectory.exit_points(hline, bc)
     self.assertTrue(np.all(np.isclose(epoints, np.array([[-5, 0, 0], [5, 0, 0]]))))
     # test vertical line
     vline = Trajectory.fit(np.array([[0, 0, 0], [0, 0, 1]]))
     epoints = Trajectory.exit_points(vline, bc)
     self.assertTrue(np.all(np.isclose(epoints, np.array([[0, 0, -7.], [0, 0, 7.]]))))