Skip to main content

Python data backend for neuroglancer, a WebGL-based viewer for volumetric data

Project description

Neuroglancer Python Integration

This package provides a Python interface for controlling Neuroglancer, a web-based 3-d volumetric data viewer.

The following features are supported:

  • Viewing in-memory NumPy arrays (or any other array type with a similar interface, including HDF5 arrays loaded through h5py)
  • Reading and writing the Neuroglancer viewer state from Python
  • Changing Neuroglancer key and mouse bindings
  • Defining actions (to be triggered by key or mouse bindings) that cause a Python callback to be invoked.

It starts a local web server for communicating state changes using sockjs, serving a copy of the Neuroglancer client code, and for serving data to the Neuroglancer client if Python data sources are used.

Installation

It is recommended that you activate a suitable Python virtual environment before installing.

Python 3.9 or later is required.

You can install the latest published package from PyPI with:

pip install neuroglancer

In most cases, this will use a prebuilt binary wheel, which requires neither node.js (to build the Neuroglancer client) nor a C++ compiler. If no binary wheel is available for your platform, a source distribution (sdist) will be used instead, which requires a C++ compiler to build but does not require node.js (the source distribution includes a prebuilt copy of the Neuroglancer client).

Direct installation from remote git repository

To install the latest version from the Neuroglancer git repository, you can use:

pip install git+https://github.com/google/neuroglancer

Note that installing from a git repository requires Node.js and a C++ compiler.

To install a specific commit XXXXXXXXX:

pip install git+https://github.com/google/neuroglancer@XXXXXXXXX

In another Python package, you can declare a dependency on a git version using the syntax:

setup(
    name='<package>',
    ...,
    install_requires=[
        ...,
        'neuroglancer @ git+https://github.com/google/neuroglancer@XXXXXXXXX',
    ],
)

Installation from local checkout of git repository

You can also install from a local checkout of the git repository. Two forms of installation are supported: normal installation, and an editable installation for development purposes.

As with installation from a remote git repository, installation from a local checkout requires Node.js to build the Neuroglancer client and a C++ compiler to build the C++ mesh generation extension module.

Normal installation

For normal installation, run the following from the root of the repository:

pip install .

That will automatically build the Neuroglancer client using Node.js if it has not already been built (i.e. if neuroglancer/static/client/index.html does not exist). To rebuild the Neuroglancer client explicitly, you can use:

python setup.py bundle_client

or

npm run build-python

Editable installation (for development purposes)

During development, an editable installation allows the package to be imported directly from the local checkout directory:

pip install -e .

Any changes you make to the .py source files take effect the next time the package is imported, without the need to reinstall. If you make changes to the Neuroglancer client, you still need to rebuild it with npm run build-python. You can also keep the Neuroglancer client continuously up-to-date by running npm run build-python:watch.

Examples

See the example programs in the examples/ directory. Run them using the Python interpreter in interactive mode, e.g.

python -i example.py

or using the IPython magic command

%run -i python.py

Do not run an example non-interactively as

python example.py

because then the server will exit immediately.

Mesh generation

For in-memory segmentation volumes, mesh representations of the surface of each object can be generated on-demand as they are requested by the client (e.g. due to the user selecting a segment)

Security

By default the server binds only to the 127.0.0.1 address, and for protection against cross-site scripting attacks only accepts requests that include a valid randomly-generated 160-bit secret key.

Test suite

The test suite can be run using the tox command. Some of the tests require a WebGL2-enabled web browser in order to test interaction with the Neuroglancer client. Both Chrome and Firefox are supported, but currently due to bugs in Swiftshader, Chrome Headless does not work. Firefox Headless also currently does not support WebGL at all. On Linux, you can successfully run the tests headlessly on Firefox using xvfb-run. On other platforms, tests can't be run headlessly.

# For headless using Firefox on xvfb (Linux only)
sudo apt-get instrall xvfb # On Debian-based systems
tox -e firefox-xvfb  # Run tests using non-headless Firefox

# For non-headless using Chrome
tox -e chrome

# For non-headless using Firefox
tox -e firefox

# To run only tests that do not require a browser
tox -e skip-browser-tests

Refer to tox.ini for details of the test procedure.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neuroglancer-2.39.2.tar.gz (3.6 MB view details)

Uploaded Source

Built Distributions

neuroglancer-2.39.2-cp39-abi3-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.9+ Windows x86-64

neuroglancer-2.39.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.9+ manylinux: glibc 2.17+ x86-64

neuroglancer-2.39.2-cp39-abi3-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.9+ macOS 11.0+ ARM64

neuroglancer-2.39.2-cp39-abi3-macosx_10_9_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.9+ macOS 10.9+ x86-64

File details

Details for the file neuroglancer-2.39.2.tar.gz.

File metadata

  • Download URL: neuroglancer-2.39.2.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.18

File hashes

Hashes for neuroglancer-2.39.2.tar.gz
Algorithm Hash digest
SHA256 5011e61876c77e7aee8510f6d94d9005c548bf1b17a6d9627ee69f78d9109c44
MD5 96170a5c3b1fee5a96d725b50467d8cd
BLAKE2b-256 cc10d3e0071f81d2618da93eb18c9529a6395e62fc2a86b1bcf03fb46a9283e2

See more details on using hashes here.

File details

Details for the file neuroglancer-2.39.2-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.39.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b63a80b40b8c5d5695d94314b91220089bc277133f96a462e9af2d21f7c100f5
MD5 7a94f34fe82785862e73316ea1f37dd0
BLAKE2b-256 661236d09c48e7c307a79ac3f39e9169d665b7b48c1446e5161b738821be4518

See more details on using hashes here.

File details

Details for the file neuroglancer-2.39.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.39.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1dd08a37efd4eeb08a76636062a8a0e649a2696588b626c13b3782d2300271b2
MD5 e7702a988eff93e371ed2eee8c349c8a
BLAKE2b-256 f8cf8f0aa150d0285583332adeb966acaae330d594dd009f0d465d219df4bc38

See more details on using hashes here.

File details

Details for the file neuroglancer-2.39.2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.39.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b0c15d097f962a136ece9ea2c7a8037f93de96d5a6ef1ad5ce5728004fc47ad
MD5 61be4253938a4ca309daaa61bb82c6a3
BLAKE2b-256 88a42f045e77280f8c5c022fbe80d8df8bdc561bf5db27db040c9b39fea84b06

See more details on using hashes here.

File details

Details for the file neuroglancer-2.39.2-cp39-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.39.2-cp39-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e6c16a9003dcf553d80ddfdbdb1f200c1ceca99ef558e5c17a0979c6d5e03014
MD5 35543938ec052fc6f4c1cd1f7612977b
BLAKE2b-256 3be88c4ad4c87e8e391a8f5fb03d0082c3386a5eed2e9d75dc89fbd24cbd7b53

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page