Exemplo n.º 1
0
    def test_surface(self):
        dt = surfaces.Surface(valid_for_simulations=True)
        dt.vertices = numpy.array(list(range(30))).reshape(10, 3).astype(
            numpy.float64)
        dt.triangles = numpy.array(list(range(9))).reshape(3, 3)
        dt.triangle_normals = numpy.array(list(range(9))).reshape(3, 3)
        dt.vertex_normals = numpy.array(list(range(30))).reshape(10,
                                                                 3).astype('f')

        dt.configure()

        summary_info = dt.summary_info()
        assert summary_info['Number of edges'] == 9
        assert summary_info['Number of triangles'] == 3
        assert summary_info['Number of vertices'] == 10
        assert summary_info['Surface type'] == 'Surface'
        assert len(dt.vertex_neighbours) == 10
        assert isinstance(dt.vertex_neighbours[0], frozenset)
        assert len(dt.vertex_triangles) == 10
        assert isinstance(dt.vertex_triangles[0], frozenset)
        assert len(dt.nth_ring(0)) == 0
        assert dt.triangle_areas.shape == (3, 1)
        assert dt.triangle_angles.shape == (3, 3)
        assert len(dt.edges) == 9
        assert len(dt.edge_triangles) == 9
        assert [] != dt.validate_topology_for_simulations().warnings
        assert dt.vertices.shape == (10, 3)
        assert dt.vertex_normals.shape == (10, 3)
        assert dt.triangles.shape == (3, 3)
Exemplo n.º 2
0
 def test_surface(self):
     dt = surfaces.Surface()
     dt.vertices = numpy.array(range(30)).reshape(10,
                                                  3).astype(numpy.float64)
     dt.triangles = numpy.array(range(9)).reshape(3, 3)
     dt.configure()
     summary_info = dt.summary_info
     self.assertEqual(summary_info['Number of edges'], 9)
     self.assertEqual(summary_info['Number of triangles'], 3)
     self.assertEqual(summary_info['Number of vertices'], 10)
     self.assertEqual(summary_info['Surface type'], 'Surface')
     self.assertEqual(len(dt.vertex_neighbours), 10)
     self.assertTrue(isinstance(dt.vertex_neighbours[0], frozenset))
     self.assertEqual(len(dt.vertex_triangles), 10)
     self.assertTrue(isinstance(dt.vertex_triangles[0], frozenset))
     self.assertEqual(len(dt.nth_ring(0)), 0)
     self.assertEqual(dt.triangle_areas.shape, (3, 1))
     self.assertEqual(dt.triangle_angles.shape, (3, 3))
     self.assertEqual(len(dt.edges), 9)
     self.assertEqual(len(dt.edge_triangles), 9)
     self.assertNotEqual([],
                         dt.validate_topology_for_simulations().warnings)
     self.assertEqual(dt.get_data_shape('vertices'), (10, 3))
     self.assertEqual(dt.get_data_shape('vertex_normals'), (10, 3))
     self.assertEqual(dt.get_data_shape('triangles'), (3, 3))
Exemplo n.º 3
0
    def test_cortical_topology_hole(self):
        dt = surfaces.Surface()
        dt.vertices = numpy.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]]).astype(numpy.float64)
        dt.triangles = numpy.array([[0, 2, 1], [0, 1, 3], [0, 3, 2]])
        dt.configure()

        euler, isolated, pinched_off, holes = dt.compute_topological_constants()
        assert 1 == euler
        assert 3 == isolated.size
        assert 0 == pinched_off.size
        assert 3 == holes.size
Exemplo n.º 4
0
    def test_cortical_topology_hole(self):
        dt = surfaces.Surface()
        dt.vertices = numpy.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]])
        dt.triangles = numpy.array([[0, 2, 1], [0, 1, 3], [0, 3, 2]])
        dt.configure()

        euler, isolated, pinched_off, holes = dt.compute_topological_constants(
        )
        self.assertEqual(1, euler)
        self.assertEqual(3, isolated.size)
        self.assertEqual(0, pinched_off.size)
        self.assertEqual(3, holes.size)
Exemplo n.º 5
0
 def test_surface(self):
     dt = surfaces.Surface()
     dt.vertices = numpy.array(range(30)).reshape(10, 3)
     dt.triangles = numpy.array(range(9)).reshape(3, 3)
     dt.configure()
     summary_info = dt.summary_info
     self.assertEqual(summary_info['Number of edges'], 9)
     self.assertEqual(summary_info['Number of triangles'], 3)
     self.assertEqual(summary_info['Number of vertices'], 10)
     self.assertEqual(summary_info['Surface type'], 'Surface')
     self.assertEqual(len(dt.vertex_neighbours), 10)
     self.assertTrue(isinstance(dt.vertex_neighbours[0], frozenset))
     self.assertEqual(len(dt.vertex_triangles), 10)
     self.assertTrue(isinstance(dt.vertex_triangles[0], frozenset))
     self.assertEqual(len(dt.nth_ring(0)), 0)
     self.assertEqual(dt.triangle_areas.shape, (3, 1))
     self.assertEqual(dt.triangle_angles.shape, (3, 3))
     self.assertEqual(len(dt.edges), 9)
     self.assertEqual(len(dt.edge_triangles), 9)
     self.assertFalse(dt.check()[0])
     self.assertEqual(dt.get_data_shape('vertices'), (10, 3))
     self.assertEqual(dt.get_data_shape('vertex_normals'), (10, 3))
     self.assertEqual(dt.get_data_shape('triangles'), (3, 3))
Exemplo n.º 6
0
 def test_surface(self):
     dt = surfaces.Surface()
     dt.configure()
     summary_info = dt.summary_info
     self.assertEqual(summary_info['Number of edges'], 49140)
     self.assertEqual(summary_info['Number of triangles'], 32760)
     self.assertEqual(summary_info['Number of vertices'], 16384)
     self.assertEqual(summary_info['Surface type'], 'Surface')
     self.assertEqual(len(dt.vertex_neighbours), 16384)
     self.assertTrue(isinstance(dt.vertex_neighbours[0], frozenset))
     self.assertEqual(len(dt.vertex_triangles), 16384)
     self.assertTrue(isinstance(dt.vertex_triangles[0], frozenset))
     self.assertEqual(len(dt.nth_ring(0)), 17)
     self.assertEqual(dt.triangle_areas.shape, (32760, 1))
     self.assertEqual(dt.triangle_angles.shape, (32760, 3))
     self.assertEqual(len(dt.edges), 49140)
     self.assertTrue(abs(dt.edge_length_mean - 3.97605292887) < 0.00000001)
     self.assertTrue(abs(dt.edge_length_min - 0.663807567201) < 0.00000001)
     self.assertTrue(abs(dt.edge_length_max - 7.75671853782) < 0.00000001)
     self.assertEqual(len(dt.edge_triangles), 49140)
     self.assertEqual(dt.check(), (True, 4, [], [], []))
     self.assertEqual(dt.get_data_shape('vertices'), (16384, 3))
     self.assertEqual(dt.get_data_shape('vertex_normals'), (16384, 3))
     self.assertEqual(dt.get_data_shape('triangles'), (32760, 3))
Exemplo n.º 7
0
 def test_surface(self):
     dt = surfaces.Surface()
     dt.vertices = numpy.array(range(30)).reshape(10,
                                                  3).astype(numpy.float64)
     dt.triangles = numpy.array(range(9)).reshape(3, 3)
     dt.configure()
     summary_info = dt._find_summary_info()
     assert summary_info['Number of edges'] == 9
     assert summary_info['Number of triangles'] == 3
     assert summary_info['Number of vertices'] == 10
     assert summary_info['Surface type'] == 'Surface'
     assert len(dt.vertex_neighbours) == 10
     assert isinstance(dt.vertex_neighbours[0], frozenset)
     assert len(dt.vertex_triangles) == 10
     assert isinstance(dt.vertex_triangles[0], frozenset)
     assert len(dt.nth_ring(0)) == 0
     assert dt.triangle_areas.shape == (3, 1)
     assert dt.triangle_angles.shape == (3, 3)
     assert len(dt.edges) == 9
     assert len(dt.edge_triangles) == 9
     # dt.validate_topology_for_simulations() #-- the surface is broken by definition
     assert dt.vertices.shape == (10, 3)
     assert dt.vertex_normals.shape == (10, 3)
     assert dt.triangles.shape == (3, 3)
Exemplo n.º 8
0
 def test_surface_reload(self):
     dt = surfaces.Surface()
     dt.default.reload(dt, folder_path=os.path.join("surfaces", "cortex_tvb_whitematter"))
     self.assertEqual(dt.get_data_shape('vertices'), (81924, 3))
     self.assertEqual(dt.get_data_shape('vertex_normals'), (81924, 3))
     self.assertEqual(dt.get_data_shape('triangles'), (163840, 3))