Closed dstansby closed 1 month ago
Thanks for reporting this one @dstansby! Is this happening for you on main? I think the neuroglancer pypi package might be outdated and causing the issue if this isn't on main.
For me the code below launches up a viewer with max projection volume rendering selected for the image layer with a local build of neuroglancer's Python API from main:
import argparse
import webbrowser
import neuroglancer
import numpy as np
import neuroglancer.cli
def add_image_layer(state):
shape = (50,) * 3
dimensions = neuroglancer.CoordinateSpace(
names=["x", "y", "z"], units="nm", scales=[40, 40, 40]
)
data = np.full(shape=shape, fill_value=255, dtype=np.uint8)
local_volume = neuroglancer.LocalVolume(data, dimensions)
state.layers.append(
name="image",
layer=neuroglancer.ImageLayer(
source=local_volume,
volume_rendering_mode="max",
volume_rendering_depth_samples=400,
),
shader="""
void main() {
emitIntensity(1.0);
emitRGBA(vec4(1.0, 1.0, 1.0, 0.01));
}
""",
)
state.layout = "3d"
def launch_nglancer():
ap = argparse.ArgumentParser()
neuroglancer.cli.add_server_arguments(ap)
args = ap.parse_args()
neuroglancer.cli.handle_server_arguments(args)
viewer = neuroglancer.Viewer()
return viewer
def main():
viewer = launch_nglancer()
with viewer.txn() as s:
add_image_layer(s)
webbrowser.open_new(viewer.get_viewer_url())
if __name__ == "__main__":
main()
Ahh thanks for checking, I'm on 2.39.1. Will try 2.40 soon and report back if it's fixed or still and issue 👍
Thanks - looks good in 2.40
In the example neuroglancer state below (taken from the web app), volumeRendering is set to a string ("max") indicating the rendering method. Trying to set this in the Python API using
neuroglancer.ImageLayer(..., volume_rendering="max")
fails with: