Skip to content

Commit

Permalink
datasets: sphere and cube
Browse files Browse the repository at this point in the history
  • Loading branch information
seankmartin committed Feb 27, 2024
1 parent d09679b commit 2b9c7c0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
14 changes: 14 additions & 0 deletions neuroglancer_utils/create_datasets/create_full_cube.py
Original file line number Diff line number Diff line change
@@ -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
)
27 changes: 10 additions & 17 deletions neuroglancer_utils/create_datasets/create_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[:, :, :]

0 comments on commit 2b9c7c0

Please sign in to comment.