Skip to content

Commit

Permalink
Merge 3527b1a into c930f89
Browse files Browse the repository at this point in the history
  • Loading branch information
jingpengw committed Aug 22, 2020
2 parents c930f89 + 3527b1a commit 9040e1e
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions chunkflow/flow/neuroglancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,45 @@ def __init__(self,
def __call__(self, chunks: dict):
"""
Parameters:
chunks: multiple chunks
chunks: multiple chunks
"""
ng.set_static_content_source(
url='https://neuromancer-seung-import.appspot.com')
# ng.set_static_content_source(
# url='https://neuromancer-seung-import.appspot.com')
ng.set_server_bind_address(bind_port=self.port)
viewer = ng.Viewer()

with viewer.txn() as s:
for chunk_name, chunk in chunks.items():
global_offset = chunk.global_offset
chunk = np.ascontiguousarray(chunk)
# neuroglancer uses F order
chunk = np.transpose(chunk)

if np.ndim(chunk) == 3:
dimensions = ng.CoordinateSpace(
scales=self.voxel_size[::-1],
units=['nm', 'nm', 'nm'],
names=['x', 'y', 'z']
)
elif np.ndim(chunk) == 4:
dimensions = ng.CoordinateSpace(
scales=self.voxel_size[::-1] + [1],
units=['nm', 'nm', 'nm', ''],
names=['x', 'y', 'z', 'c^']
)
else:
raise ValueError('only support 3/4 dimension volume.')

s.layers.append(
name=chunk_name,
layer=ng.LocalVolume(
data=chunk,
dimensions=neuroglancer.CordinateSpace(
scales=[1, *self.voxel_size[::-1]],
units = ['', 'nm', 'nm', 'nm'],
names = ['c^', 'x', 'y', 'z']
),
dimensions=dimensions,
# offset is in nm, not voxels
offset=list(o * v for o, v in zip(
global_offset[::-1][-3:], self.voxel_size[::-1])))
# chunkflow use C order with zyx,
# while neuroglancer use F order with xyz
voxel_offset=global_offset[::-1][:3]
)
)
print('Open this url in browser: ')
print(viewer)
Expand Down

0 comments on commit 9040e1e

Please sign in to comment.