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

feat: allow pointing directly at mesh and skeleton paths #628

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
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
Next Next commit
feat: allow direct use of skeleton or mesh paths
william-silversmith authored and William Silversmith committed Aug 2, 2024
commit 29721545a164cbf3f81794010a341b07ac543d4e
40 changes: 35 additions & 5 deletions cloudvolume/datasource/precomputed/__init__.py
Original file line number Diff line number Diff line change
@@ -58,13 +58,27 @@ def create_precomputed(
use_https=use_https # for parsing redirects
)

readonly = bool(meta.redirected_from)

if meta.info.get("@type", "") == "neuroglancer_skeletons":
info = meta.info
meta = synthetic_meta(cloudpath, config, cache_service)
skeleton = PrecomputedSkeletonSource(meta, cache_service, config, readonly, info=info)
else:
skeleton = PrecomputedSkeletonSource(meta, cache_service, config, readonly)

if meta.info.get("@type", "") in ["neuroglancer_legacy_mesh", "neuroglancer_multilod_draco"]:
info = meta.info
meta = synthetic_meta(cloudpath, config, cache_service)
mesh = PrecomputedMeshSource(meta, cache_service, config, readonly, info=info)
else:
mesh = PrecomputedMeshSource(meta, cache_service, config, readonly)

if mesh_dir:
meta.info['mesh'] = str(mesh_dir)
if skel_dir:
meta.info['skeletons'] = str(skel_dir)

readonly = bool(meta.redirected_from)

if readonly:
print(yellow("""
Redirected
@@ -99,9 +113,6 @@ def create_precomputed(
lru_bytes=lru_bytes,
)

mesh = PrecomputedMeshSource(meta, cache_service, config, readonly)
skeleton = PrecomputedSkeletonSource(meta, cache_service, config, readonly)

cv = CloudVolumePrecomputed(
meta, cache_service, config,
image, mesh, skeleton,
@@ -113,6 +124,25 @@ def create_precomputed(

return cv

def synthetic_meta(cloudpath, config, cache_service) -> PrecomputedMetadata:
info = PrecomputedMetadata.create_info(
num_channels=1,
layer_type="segmentation",
data_type='uint8',
encoding="raw",
resolution=[1,1,1],
voxel_offset=[0,0,0],
volume_size=[1,1,1],
)
return PrecomputedMetadata(
cloudpath,
config=config,
cache=cache_service,
info=info, provenance=None,
max_redirects=0,
use_https=True # for parsing redirects
)


def register():
register_plugin('precomputed', create_precomputed)
3 changes: 3 additions & 0 deletions cloudvolume/datasource/precomputed/metadata.py
Original file line number Diff line number Diff line change
@@ -189,6 +189,9 @@ def refresh_info(self, max_redirects=10, force_fetch=False):

def parse_rois(self, info) -> List[Bbox]:
"""Parse ROIs from the info file at mip 0."""
if 'scales' not in info:
return None

scale = info['scales'][0]
if 'rois' not in scale:
return None