示例#1
0
 def test_save(self, mock_writegeo):
     """ Test the save method.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     out_file = "/my/path/mock_destination"
     surf.save(out_file)
 def test_save(self, mock_writegeo):
     """ Test the save method.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     out_file = "/my/path/mock_destination"
     surf.save(out_file)
 def test_labelize(self):
     """ Test the labelize method.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     surf.vertices += 1
     label_array, nb_of_labels = surf.labelize(shape=(3, 3, 3))
     self.assertEqual(6, nb_of_labels)
 def test_savevtk(self, mock_vtkpoint, mock_vtkcell, mock_vtkuarray,
                  mock_vtktriangle, mock_vtkpoly, mock_vtkwrite):
     """ Test the save vtk method.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     out_file = "/my/path/mock_destination"
     surf.save_vtk(out_file, inflated=True)
示例#5
0
 def test_labelize(self):
     """ Test the labelize method.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     surf.vertices += 1
     label_array, nb_of_labels = surf.labelize(shape=(3, 3, 3))
     self.assertEqual(6, nb_of_labels)
示例#6
0
 def test_savevtk(self, mock_vtkpoint, mock_vtkcell, mock_vtkuarray,
                  mock_vtktriangle, mock_vtkpoly, mock_vtkwrite):
     """ Test the save vtk method.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     out_file = "/my/path/mock_destination"
     surf.save_vtk(out_file, inflated=True)
 def test_normal_execution(self):
     """ Test the normal behaviour of the function.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     self.assertTrue(numpy.allclose(self.kwargs["vertices"], surf.vertices))
     self.assertTrue(
         numpy.allclose(self.kwargs["triangles"], surf.triangles))
     self.assertTrue(
         numpy.allclose(self.kwargs["inflated_vertices"],
                        surf.inflated_vertices))
     self.assertEqual(surf.shape(), (6, 18, 8))
示例#8
0
 def test_normal_execution(self):
     """ Test the normal behaviour of the function.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     self.assertTrue(numpy.allclose(self.kwargs["vertices"],
                                    surf.vertices))
     self.assertTrue(numpy.allclose(self.kwargs["triangles"],
                                    surf.triangles))
     self.assertTrue(numpy.allclose(self.kwargs["inflated_vertices"],
                                    surf.inflated_vertices))
     self.assertEqual(surf.shape(), (6, 18, 8))
示例#9
0
    def test_voxelize(self, mock_vtkpoint, mock_vtkpoly, mock_poly,
                      mock_vtkslect, mock_vtkutil, mock_vtkwrite):
        """ Test the voxelize vtk method.
        """
        # Set the mocked functions returned values
        mock_poly.return_value = object()
        mock_vtkutil.numpy_support.vtk_to_numpy.return_value = numpy.ones(
            (3, 3, 3), dtype=int)

        # Test execution
        surf = TriSurface(**self.kwargs)
        out_file = "/my/path/mock_destination"
        inside_array = surf.voxelize(shape=(3, 3, 3), tol=0)
        self.assertTrue(numpy.allclose(
            inside_array,
            mock_vtkutil.numpy_support.vtk_to_numpy.return_value))
示例#10
0
    def test_voxelize(self, mock_vtkpoint, mock_vtkpoly, mock_poly,
                      mock_vtkslect, mock_vtkutil, mock_vtkwrite):
        """ Test the voxelize vtk method.
        """
        # Set the mocked functions returned values
        mock_poly.return_value = object()
        mock_vtkutil.numpy_support.vtk_to_numpy.return_value = numpy.ones(
            (3, 3, 3), dtype=int)

        # Test execution
        surf = TriSurface(**self.kwargs)
        out_file = "/my/path/mock_destination"
        inside_array = surf.voxelize(shape=(3, 3, 3), tol=0)
        self.assertTrue(
            numpy.allclose(
                inside_array,
                mock_vtkutil.numpy_support.vtk_to_numpy.return_value))
示例#11
0
    def test_load(self, mock_readgeo, mock_readannot):
        """ Test the load method.
        """
        # Set the mocked functions returned values
        mock_readgeo.side_effect = [
            (self.kwargs["vertices"], self.kwargs["triangles"]),
            (self.kwargs["inflated_vertices"], self.kwargs["triangles"])]
        mock_readannot.return_value = [
            self.labels, self.ctab, self.labels]

        # Test execution
        meshfile = "/my/path/mock_mesh"
        inflatedmeshpath = "/my/path/mock_infmesh"
        annotfile = "/my/path/mock_annot"
        surf = TriSurface.load(meshfile, inflatedmeshpath=inflatedmeshpath,
                               annotfile=annotfile)
        self.assertTrue(numpy.allclose(self.kwargs["vertices"],
                                       surf.vertices))
        self.assertTrue(numpy.allclose(self.kwargs["triangles"],
                                       surf.triangles))
        self.assertTrue(numpy.allclose(self.kwargs["inflated_vertices"],
                                       surf.inflated_vertices))
        self.assertEqual(surf.shape(), (6, 18, 8))
示例#12
0
    def test_load(self, mock_readgeo, mock_readannot):
        """ Test the load method.
        """
        # Set the mocked functions returned values
        mock_readgeo.side_effect = [
            (self.kwargs["vertices"], self.kwargs["triangles"]),
            (self.kwargs["inflated_vertices"], self.kwargs["triangles"])
        ]
        mock_readannot.return_value = [self.labels, self.ctab, self.labels]

        # Test execution
        meshfile = "/my/path/mock_mesh"
        inflatedmeshpath = "/my/path/mock_infmesh"
        annotfile = "/my/path/mock_annot"
        surf = TriSurface.load(meshfile,
                               inflatedmeshpath=inflatedmeshpath,
                               annotfile=annotfile)
        self.assertTrue(numpy.allclose(self.kwargs["vertices"], surf.vertices))
        self.assertTrue(
            numpy.allclose(self.kwargs["triangles"], surf.triangles))
        self.assertTrue(
            numpy.allclose(self.kwargs["inflated_vertices"],
                           surf.inflated_vertices))
        self.assertEqual(surf.shape(), (6, 18, 8))