Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add segment_prop_dir and segment_properties arguments for the precomputed format #638

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cloudvolume/cloudvolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __new__(cls,
compress:CompressType=None, compress_level:Optional[int]=None,
non_aligned_writes:bool=False, parallel:ParallelType=1, delete_black_uploads:bool=False,
background_color:int=0, green_threads:bool=False, use_https:bool=False,
max_redirects:int=10, mesh_dir:Optional[str]=None, skel_dir:Optional[str]=None,
max_redirects:int=10, mesh_dir:Optional[str]=None, skel_dir:Optional[str]=None, segment_prop_dir:Optional[str]=None,
agglomerate:bool=False, secrets:SecretsType=None,
spatial_index_db:Optional[str]=None, lru_bytes:int = 0,
cache_locking:bool = True
Expand Down Expand Up @@ -207,6 +207,8 @@ def __new__(cls,
file, use this one.
secrets: (dict) provide per-instance authorization tokens. If not provided,
defaults to looking in .cloudvolume/secrets for necessary tokens.
segment_prop_dir: (str) if not None, override the info['segment_properties']
key before pulling the segment properties info file.
skel_dir: (str) if not None, override the info['skeletons'] key before
pulling the skeleton info file.
spatial_index_db: (str) A path to an sqlite3 or mysql database that follows
Expand Down
9 changes: 7 additions & 2 deletions cloudvolume/datasource/precomputed/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def check_for_placeholder_scale(self, mip:int):
def create_info(cls,
num_channels, layer_type, data_type, encoding,
resolution, voxel_offset, volume_size,
mesh=None, skeletons=None, chunk_size=(128,128,64),
mesh=None, skeletons=None, segment_properties=None,
chunk_size=(128,128,64),
compressed_segmentation_block_size=(8,8,8),
max_mip=0, factor=Vec(2,2,1), redirect=None
):
Expand All @@ -98,6 +99,7 @@ def create_info(cls,
Optional:
mesh: (str) name of mesh directory, typically "mesh"
skeletons: (str) name of skeletons directory, typically "skeletons"
segment_properties: (str) name of segment properties directory, typically "segment_properties"
chunk_size: int (x,y,z), dimensions of each downloadable 3D image chunk in voxels
compressed_segmentation_block_size: (x,y,z) dimensions of each compressed sub-block
(only used when encoding is 'compressed_segmentation')
Expand Down Expand Up @@ -150,6 +152,9 @@ def create_info(cls,

if skeletons:
info['skeletons'] = 'skeletons' if not isinstance(skeletons, string_types) else skeletons

if segment_properties:
info['segment_properties'] = 'segment_properties' if not isinstance(segment_properties, string_types) else segment_properties

return info

Expand Down Expand Up @@ -877,4 +882,4 @@ def unlock_mips(self, mips):
raise exceptions.WriteLockReleaseError(msg)

def locked_mips(self):
return set([ i for i, scale in enumerate(self.info['scales']) if scale.get('locked', False) ])
return set([ i for i, scale in enumerate(self.info['scales']) if scale.get('locked', False) ])
9 changes: 6 additions & 3 deletions cloudvolume/frontends/precomputed.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def warn(text):
class CloudVolumePrecomputed(object):
def __init__(self,
meta, cache, config,
image=None, mesh=None, skeleton=None,
image=None, mesh=None, skeleton=None, segment_properties=None
mip=0
):
self.config = config
Expand All @@ -48,6 +48,7 @@ def __init__(self,
self.image = image
self.mesh = mesh
self.skeleton = skeleton
self.segment_properties = segment_properties

self.green_threads = self.config.green # display warning message

Expand Down Expand Up @@ -216,7 +217,8 @@ def __setstate__(self, d):
def create_new_info(cls,
num_channels, layer_type, data_type, encoding,
resolution, voxel_offset, volume_size,
mesh=None, skeletons=None, chunk_size=(64,64,64),
mesh=None, skeletons=None, segment_properties= None,
chunk_size=(64,64,64),
compressed_segmentation_block_size=(8,8,8),
max_mip=0, factor=Vec(2,2,1), redirect=None,
*args, **kwargs
Expand All @@ -236,6 +238,7 @@ def create_new_info(cls,
Optional:
mesh: (str) name of mesh directory, typically "mesh"
skeletons: (str) name of skeletons directory, typically "skeletons"
segment_properties: (str) name of segment properties directory, typically "segment_properties"
chunk_size: int (x,y,z), dimensions of each downloadable 3D image chunk in voxels
compressed_segmentation_block_size: (x,y,z) dimensions of each compressed sub-block
(only used when encoding is 'compressed_segmentation')
Expand All @@ -249,7 +252,7 @@ def create_new_info(cls,
return PrecomputedMetadata.create_info(
num_channels, layer_type, data_type, encoding,
resolution, voxel_offset, volume_size,
mesh, skeletons, chunk_size,
mesh, skeletons, segment_properties, chunk_size,
compressed_segmentation_block_size,
max_mip, factor,
*args, **kwargs
Expand Down