seung-lab / neuroglancer

WebGL-based viewer for volumetric data
https://neuromancer-seung-import.appspot.com/
Apache License 2.0
22 stars 10 forks source link

The viewer obtained using the examples in the python directory does not render the mesh #620

Closed liuyx599 closed 1 year ago

liuyx599 commented 1 year ago

When I use the script in the python/examples directory and open the corresponding viewer with the browser, the mesh is not rendered in the 3D view when I click on the selected segmengt of an id, other display functions and interaction functions work fine.

example_overlay.py

from __future__ import print_function

import time
import webbrowser

import numpy as np

import neuroglancer

viewer = neuroglancer.Viewer()

a = np.zeros((3, 100, 100, 100), dtype=np.uint8)
ix, iy, iz = np.meshgrid(* [np.linspace(0, 1, n) for n in a.shape[1:]], indexing='ij')
a[0, :, :, :] = np.abs(np.sin(4 * (ix + iy))) * 255
a[1, :, :, :] = np.abs(np.sin(4 * (iy + iz))) * 255
a[2, :, :, :] = np.abs(np.sin(4 * (ix + iz))) * 255

with viewer.txn() as s:
    s.layers['image'] = neuroglancer.ImageLayer(
        source='precomputed://gs://neuroglancer-public-data/flyem_fib-25/image',
    )
    s.layers['ground_truth'] = neuroglancer.SegmentationLayer(
        source='precomputed://gs://neuroglancer-public-data/flyem_fib-25/ground_truth',
    )
    s.layers['overlay'] = neuroglancer.ImageLayer(
        source=neuroglancer.LocalVolume(a, voxel_size=[8, 8, 8], voxel_offset=[3000, 3000, 3000]),
        shader="""
void main() {
  emitRGB(vec3(toNormalized(getDataValue(0)),
               toNormalized(getDataValue(1)),
               toNormalized(getDataValue(2))));
}
""",
    )
    s.voxel_coordinates = [3000, 3000, 3000]
print(viewer.state)
print(viewer)
webbrowser.open_new(viewer.get_viewer_url())

while(1):
    time.sleep(1)

However, when I use npm run to get a neuroglancer server, I input the same source of segmentation layer and select the same ID of segment, I can render the corresponding mesh.

I don't know how to solve this, please help!