diff --git a/neuroglancer_utils/create_datasets/create_full_cube.py b/neuroglancer_utils/create_datasets/create_full_cube.py new file mode 100644 index 0000000..12d6918 --- /dev/null +++ b/neuroglancer_utils/create_datasets/create_full_cube.py @@ -0,0 +1,14 @@ +from cloudvolume import CloudVolume +import numpy as np + +def create_volume(output_path="file://datasets/cube"): + rawdata = np.full(shape=(100, 100, 100), fill_value=255.0).astype(np.float32) + CloudVolume.from_numpy( + rawdata, + vol_path=output_path, + resolution=(40, 40, 40), + chunk_size=(100, 100, 100), + layer_type="image", + progress=True, + compress=False + ) \ No newline at end of file diff --git a/neuroglancer_utils/create_datasets/create_sphere.py b/neuroglancer_utils/create_datasets/create_sphere.py index 0169e51..626d33d 100644 --- a/neuroglancer_utils/create_datasets/create_sphere.py +++ b/neuroglancer_utils/create_datasets/create_sphere.py @@ -20,25 +20,18 @@ def create_sphere_in_cube(size, radius): sphere[0 : size // 10, :, :] = 0.5 sphere[9 * size // 10 :, :, :] = 0.5 - return (sphere.astype(np.float32) * 255.0) + return sphere.astype(np.float32) * 255.0 def create_volume(output_path="file://datasets/sphere"): - info = CloudVolume.create_new_info( - num_channels=1, + rawdata = create_sphere_in_cube(100, 0.9) + #rawdata = np.full(shape=(100, 100, 100), fill_value=255.0).astype(np.float32) + CloudVolume.from_numpy( + rawdata, + vol_path=output_path, + resolution=(40, 40, 40), + chunk_size=(100, 100, 100), layer_type="image", - data_type="float32", # Channel images might be 'uint8' - # raw, png, jpeg, compressed_segmentation, fpzip, kempressed, zfpc, compresso, crackle - encoding="raw", - resolution=[40, 40, 40], # Voxel scaling, units are in nanometers - voxel_offset=[0, 0, 0], # x,y,z offset in voxels from the origin - # Pick a convenient size for your underlying chunk representation - # Powers of two are recommended, doesn't need to cover image exactly - chunk_size=[100, 100, 100], # units are voxels - volume_size=[100, 100, 100], # e.g. a cubic millimeter dataset + progress=True, + compress=False ) - vol = CloudVolume(output_path, info=info) - vol.commit_info() - rawdata = create_sphere_in_cube(100, 0.9) - print(rawdata[30:40]) - vol[:, :, :] = rawdata[:, :, :]