Skip to content

Commit

Permalink
Merge pull request #124 from stuarteberg/fix-singleres-mesh
Browse files Browse the repository at this point in the history
neuprint: Two fixes
  • Loading branch information
schlegelp authored Oct 17, 2023
2 parents 77a14d5 + dde4331 commit 0c0cc6e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions navis/interfaces/neuprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ def __fetch_mesh(bodyId, *, vol, lod, missing_mesh='raise'):
# Fetch mesh
import cloudvolume
try:
mesh = vol.mesh.get(bodyId, lod=lod)[bodyId]
if lod is None:
mesh = vol.mesh.get(bodyId)
else:
mesh = vol.mesh.get(bodyId, lod=lod)
except cloudvolume.exceptions.MeshDecodeError as err:
if 'not found' in str(err):
if missing_mesh in ['warn', 'skip']:
Expand Down Expand Up @@ -574,13 +577,23 @@ def get_seg_source(*, client=None):
if len(named_segs):
segs = named_segs

# Get the first entry
# If there are multiple segmentation layers, select the first entry
seg_source = segs[0]['source']

# Make sure it's actually a string and not a {'source': url, 'subsources'...} dict
# If there are multiple segmentation sources for
# the layer we picked, select the first source.
if isinstance(seg_source, list):
seg_source = seg_source[0]

# If it's a dict like {'source': url, 'subsources'...},
# select the url.
if isinstance(seg_source, dict):
seg_source = seg_source['url']

if not isinstance(seg_source, str):
e = f"Could not understand segmentation source: {seg_source}"
raise RuntimeError(e)

if len(segs) > 1:
logger.warning(f'{len(segs)} segmentation sources found. Using the '
f'first entry: "{seg_source}"')
Expand Down

0 comments on commit 0c0cc6e

Please sign in to comment.