|
| 1 | +import argparse |
| 2 | + |
| 3 | +import neuroglancer |
| 4 | +import neuroglancer.cli |
| 5 | + |
| 6 | +if __name__ == "__main__": |
| 7 | + ap = argparse.ArgumentParser() |
| 8 | + neuroglancer.cli.add_server_arguments(ap) |
| 9 | + args = ap.parse_args() |
| 10 | + neuroglancer.cli.handle_server_arguments(args) |
| 11 | + viewer = neuroglancer.Viewer() |
| 12 | + with viewer.txn() as s: |
| 13 | + s.dimensions = neuroglancer.CoordinateSpace( |
| 14 | + names=["x", "y"], units="nm", scales=[1, 1] |
| 15 | + ) |
| 16 | + s.position = [150, 150] |
| 17 | + s.layers.append( |
| 18 | + name="a", |
| 19 | + layer=neuroglancer.LocalAnnotationLayer( |
| 20 | + dimensions=s.dimensions, |
| 21 | + annotation_properties=[ |
| 22 | + neuroglancer.AnnotationPropertySpec( |
| 23 | + id="color", |
| 24 | + type="rgb", |
| 25 | + default="red", |
| 26 | + ), |
| 27 | + neuroglancer.AnnotationPropertySpec( |
| 28 | + id="size", |
| 29 | + type="float32", |
| 30 | + default=10, |
| 31 | + ), |
| 32 | + neuroglancer.AnnotationPropertySpec( |
| 33 | + id="p_int8", |
| 34 | + type="int8", |
| 35 | + default=10, |
| 36 | + ), |
| 37 | + neuroglancer.AnnotationPropertySpec( |
| 38 | + id="p_uint8", |
| 39 | + type="uint8", |
| 40 | + default=10, |
| 41 | + ), |
| 42 | + ], |
| 43 | + annotations=[ |
| 44 | + neuroglancer.PolyLineAnnotation( |
| 45 | + id="1", |
| 46 | + points=[[150, 150], [200, 100], [30, 40]], |
| 47 | + props=["#0f0", 5, 6, 7], |
| 48 | + ), |
| 49 | + neuroglancer.PolyLineAnnotation( |
| 50 | + id="2", |
| 51 | + points=[[250, 100], [20, 20]], |
| 52 | + props=["#ff0", 30, 7, 9], |
| 53 | + ), |
| 54 | + ], |
| 55 | + shader=""" |
| 56 | +void main() { |
| 57 | + setColor(prop_color()); |
| 58 | + setPointMarkerSize(prop_size()); |
| 59 | +} |
| 60 | +""", |
| 61 | + ), |
| 62 | + ) |
| 63 | + s.layout = "xy" |
| 64 | + s.selected_layer.layer = "a" |
| 65 | + print("Use `Control+right click` to display annotation details.") |
| 66 | + print(viewer) |
0 commit comments