Exemplo n.º 1
0
def test_skeleton_read_write_with_props(simple_skeleton_with_properties,
                                        tmp_path):
    sk = simple_skeleton_with_properties

    fname = os.path.join(tmp_path, 'test.swc')
    skeleton_io.write_skeleton_h5(sk, fname, overwrite=True)
    skback = skeleton_io.read_skeleton_h5(fname)
    assert np.all(
        skback.vertex_properties['test'] == sk.vertex_properties['test'])
    assert np.all(skback.mesh_to_skel_map == sk.mesh_to_skel_map)
Exemplo n.º 2
0
    def write_to_h5(self, filename, overwrite=True):
        """Write the skeleton to an HDF5 file. Note that this is done in the original dimensons, not the scaled dimensions.

        Parameters
        ----------
        filename : str
            Filename to save file
        overwrite : bool, optional
            Flag to specify whether to overwrite existing files, by default True
        """
        existing_voxel_scaling = self.voxel_scaling
        self.voxel_scaling = None
        skeleton_io.write_skeleton_h5(self, filename, overwrite=overwrite)
        self.voxel_scaling = existing_voxel_scaling
Exemplo n.º 3
0
def test_skeleton_read_write(simple_skeleton, overwrite_flag, file_exist):
    sk = simple_skeleton

    with tempfile.NamedTemporaryFile(suffix='.h5',
                                     delete=(not file_exist)) as tf:
        fname = tf.name

    skeleton_io.write_skeleton_h5(sk, fname, overwrite=overwrite_flag)

    if file_exist and not overwrite_flag:
        with pytest.raises(OSError):
            skback = skeleton_io.read_skeleton_h5(fname)
    else:
        skback = skeleton_io.read_skeleton_h5(fname)
        assert np.all(skback.vertices == sk.vertices)
        assert np.all(skback.edges == sk.edges)
        assert skback.root == sk.root