def test_read_surface_and_save_as_stack(self):
        img = ImageStack(filename='', load=False)
        img.data = np.zeros([10, 100, 100])
        img.data[2:7, 10:-10, 10:-10] = 1
        voxel_size = [4, 0.3824, 0.3824]
        img.extract_surfaces('data/test_data/surfaces/',
                             voxel_size=voxel_size,
                             reconstruct=False)
        surf = Surface(filename='data/test_data/surfaces/_Cell00001.csv')
        for coord in ['x', 'y', 'z']:
            self.assertIsNotNone(surf.__dict__[coord])

        surf.save_as_stack(filename='data/test_data/stack.tif', voxel_size=0.5)
        self.assertEqual(os.path.exists('data/test_data/stack.tif'), True)
        self.assertEqual(os.path.exists('data/test_data/stack.txt'), True)
        shutil.rmtree('data/test_data/')
def convert_to_tiff(**kwargs):
    """
    Save the surface as a 3D image stack.
    
    Keyword arguments
    -----------------
    *inputfolder* : str
        Directory with the input surface.
    *item* : str
        File name of the input surface.
    *outputfolder* : str
        Directory to save the output 3D stack.
    """
    inputfolder = kwargs.get('inputfolder')
    outputfolder = kwargs.get('outputfolder', inputfolder + '../stacks/')
    filename = kwargs.get('item')

    surface = Surface(filename=inputfolder + filename, **kwargs)
    surface.save_as_stack(outputfolder + filename + '.tif',
                          voxel_size=kwargs.get('voxel_size'))