Neuroglancer

repository·master·Indexed 23 days ago

https://github.com/google/neuroglancer

A 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.

Tokens
52.7K
Snippets
91
Records
331
Agent score
80%

What's inside neuroglancer

  1. Overview of Neuroglancer

    master
    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.
  2. Overview of Neuroglancer capabilities

    master

    Neuroglancer 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.
  3. Overview of GPU Hash implementations

    master

    The gpu_hash directory 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 uint64 object 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.
  4. Access non-public Google Cloud Storage buckets via ngauth

    master

    To access non-public Google Cloud Storage (GCS) buckets within Neuroglancer, you must use an ngauth server. This server acts as a bridge to provide authenticated access to private GCS resources.

    For detailed implementation and configuration instructions, refer to the ngauth_server documentation.

  5. Core features of Neuroglancer Python Integration

    master

    The 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.
  6. Neuroglancer Python API Overview

    master
    The 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.
  7. Use Unsharded vs Sharded uint64 indices

    master

    Depending on the sharding configuration in the info file, indices are stored in one of two ways:

    • Unsharded uint64 index: Data for a uint64 ID is stored in a file named <id> (the base-10 string representation of the ID) within the directory specified by the key.
    • Sharded uint64 index: The uint64 ID is used directly as the key within the sharded representation within the directory specified by the key.
  8. Create UI controls with #uicontrol

    master

    The #uicontrol directive 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., vec3 or vec4).
    • slider: A continuous range control (e.g., float). Use min, max, step, and default parameters.
    • 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
      }
    }
  9. Neuroglancer Precomputed Segment Properties Format

    master

    Neuroglancer supports associating a collection of property values with uint64 segment 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 info JSON file.

    To use this format, your data must be organized into a directory containing exactly one info JSON file.

  10. Use the precomputed data source format

    master

    The 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 uint64 object ids)
    • Object skeleton representations (keyed by uint64 object 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 info metadata file using the precomputed:// scheme.

    precomputed://FILE_URL
  11. Manage Viewer State via Python

    master

    The 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).