Neuroglancer
repository·master·Indexed 23 days ago
https://github.com/google/neuroglancerA high-performance, WebGL-based volumetric data visualizer for large-scale scientific datasets. It enables the exploration of 3D volumes, meshes, and segmentations via orthogonal cross-sections and 3D views in a web browser. The project includes a Python integration and ngauth, a lightweight server for accessing non-public Google Cloud Storage buckets.
What's inside neuroglancer
- Neuroglancer is a WebGL-based viewer designed for volumetric data visualization. It supports displaying arbitrary (non-axis-aligned) cross-sectional views, 3D meshes, and line-segment based models (skeletons). The viewer typically uses a four-pane layout: three orthogonal cross-sectional views and one 3D view that displays 3D models for selected objects. All four views maintain a synchronized center position.
Overview of Neuroglancer capabilities
masterNeuroglancer is a WebGL-based viewer designed for volumetric data visualization. It supports the following visualization types:
- Volumetric Data: Arbitrary (non-axis-aligned) cross-sectional views.
- 3-D Meshes: Rendering of complex 3D surfaces.
- Line-segment based models: Visualization of skeletons or similar structures.
Overview of GPU Hash implementations
masterThe
gpu_hashdirectory provides hash functions, hash sets, and hash maps designed for efficient use from both JavaScript and WebGL shaders on the GPU. These implementations are primarily used for:- Pseudo-random color mapping: Mapping
uint64object IDs to colors. - Object ID highlighting: Highlighting a specific set of object IDs.
- Equivalence maps: Managing equivalence maps over object IDs.
Implementation Constraints
The implementation is specifically designed to work within the limitations of WebGL 1.0 (OpenGL ES Shading Language 1.0):
- Floating Point Arithmetic: Since WebGL 1.0 lacks integer arithmetic and texture operations, all computations use 24-bit-precision floating point operations. This requires careful handling of rounding and optimizations.
- Cuckoo Hashing: Because WebGL shaders do not permit non-constant loops, the implementation uses Cuckoo hashing. This is optimized for GPU lookups, as the complexity of insertion and deletion is handled on the CPU/JavaScript side.
- 2-D Texture Layout: Since 1-D textures are not supported in WebGL, hash tables are structured as 2-D arrays to match supported 2-D texture dimensions.
- Pseudo-random color mapping: Mapping
Access non-public Google Cloud Storage buckets via ngauth
masterTo access non-public Google Cloud Storage (GCS) buckets within Neuroglancer, you must use an
ngauthserver. This server acts as a bridge to provide authenticated access to private GCS resources.For detailed implementation and configuration instructions, refer to the
ngauth_serverdocumentation.Core features of Neuroglancer Python Integration
masterThe Python interface allows you to control the Neuroglancer web viewer with the following capabilities:
- Data Visualization: View in-memory NumPy arrays or other array-like types (e.g., HDF5 arrays via
h5py). - State Management: Read and write the Neuroglancer viewer state directly from Python.
- Input Customization: Change Neuroglancer key and mouse bindings.
- Python Callbacks: Define actions triggered by key or mouse bindings that invoke Python functions.
- Mesh Generation: Generate mesh representations of the surface of in-memory segmentation volumes on-demand as requested by the client.
- Data Visualization: View in-memory NumPy arrays or other array-like types (e.g., HDF5 arrays via
Use Draco mesh compression in Neuroglancer
masterNeuroglancer provides an interface to the Draco mesh compression library. This allows for efficient loading and visualization of compressed 3D meshes within the Neuroglancer interface.Neuroglancer Python API Overview
masterThe Neuroglancer Python API allows developers to programmatically control the Neuroglancer viewer, manage viewer state (such as segment sets, layers, and tools), and handle data sources. It includes utilities for serving local data, managing credentials, capturing screenshots, and interacting with precomputed annotation I/O.Use Unsharded vs Sharded uint64 indices
masterDepending on the
shardingconfiguration in theinfofile, indices are stored in one of two ways:- Unsharded uint64 index: Data for a
uint64ID is stored in a file named<id>(the base-10 string representation of the ID) within the directory specified by thekey. - Sharded uint64 index: The
uint64ID is used directly as the key within the sharded representation within the directory specified by thekey.
- Unsharded uint64 index: Data for a
Create UI controls with #uicontrol
masterThe
#uicontroldirective allows you to add interactive widgets to the Neuroglancer UI that can be used within your shader code.Common types include:
color: A color picker (e.g.,vec3orvec4).slider: A continuous range control (e.g.,float). Usemin,max,step, anddefaultparameters.checkbox: A boolean toggle (e.g.,bool).invlerp: An inverse linear interpolation control for remapping annotation properties to a 0-1 range.uint: A discrete integer slider.
// Slider example #uicontrol float red slider(min=0.0, max=1.0, step=0.05, default=1.0) void main() { vec3 mycolor = vec3(red, 0.0, 0.0); setColor(mycolor); } // Checkbox example #uicontrol bool showBorders checkbox(default=true) void main() { if (showBorders) { // ... logic } }Neuroglancer Precomputed Segment Properties Format
masterNeuroglancer supports associating a collection of property values with
uint64segment IDs (typically used for segmentation volumes, meshes, or skeletons).Currently, only inline properties are supported. This means the entire mapping of segment IDs to their associated property values must be stored within a single
infoJSON file.To use this format, your data must be organized into a directory containing exactly one
infoJSON file.Use the precomputed data source format
masterThe
precomputed://data source format is used for static collections of files served over HTTP (e.g., Google Cloud Storage or Amazon S3). It does not require special serving infrastructure, but you must either host the Neuroglancer client on the same server as the data or enable CORS access on the data server.Supported data types include:
- Single-resolution or multi-resolution image/segmentation volumes
- Single-resolution or multi-resolution object surface meshes (keyed by
uint64object ids) - Object skeleton representations (keyed by
uint64object ids) - Collections of point, line, bounding box, or ellipsoid annotations
- Segment property maps
To use a standard precomputed dataset, provide the URL to the directory containing the
infometadata file using theprecomputed://scheme.precomputed://FILE_URLManage Viewer State via Python
masterThe Python API provides interfaces to manipulate the current state of the Neuroglancer viewer. This includes:
- Segment sets: Managing which segment sets are currently loaded.
- URL representation: Interacting with the state as represented in the viewer's URL.
- Coordinate space: Controlling the viewer's coordinate system.
- Layers: Managing volumetric or segmentation layers.
- Tools: Controlling active viewer tools (e.g., selection tools, measurement tools).