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.5 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:

python setup.py install

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

python setup.py bundle_client

or

npm run build-python

Note: Installing from a local checkout using pip install . also works, but it may be slower because it makes a full copy of the local directory (https://github.com/pypa/pip/pull/7882), including the possibly-large .git and node_modules directories.

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 dev-server-python.

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.23.post1.dev0.tar.gz (2.5 MB view details)

Uploaded Source

Built Distributions

neuroglancer-2.23.post1.dev0-cp39-cp39-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.9 Windows x86-64

neuroglancer-2.23.post1.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

neuroglancer-2.23.post1.dev0-cp39-cp39-macosx_10_9_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

neuroglancer-2.23.post1.dev0-cp38-cp38-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.8 Windows x86-64

neuroglancer-2.23.post1.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

neuroglancer-2.23.post1.dev0-cp38-cp38-macosx_10_9_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

neuroglancer-2.23.post1.dev0-cp37-cp37m-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.7m Windows x86-64

neuroglancer-2.23.post1.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

neuroglancer-2.23.post1.dev0-cp37-cp37m-macosx_10_9_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

Details for the file neuroglancer-2.23.post1.dev0.tar.gz.

File metadata

  • Download URL: neuroglancer-2.23.post1.dev0.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for neuroglancer-2.23.post1.dev0.tar.gz
Algorithm Hash digest
SHA256 ec9e924b6f98dfda67015d81b50f35fc4d36286b67ad393e60616ef8ec391338
MD5 71849bd3f126507316b2dabde7d364d9
BLAKE2b-256 6d34f486fc9681a775bced98a0c7103add28acf25698409f50c6ad71d02ee5a8

See more details on using hashes here.

File details

Details for the file neuroglancer-2.23.post1.dev0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: neuroglancer-2.23.post1.dev0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for neuroglancer-2.23.post1.dev0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7cc215f3ce17684ae5f3632feffb2b21a6854c45379284b202b521b8aa50d310
MD5 bebdc26adbf3c02257c527ea8e9f0308
BLAKE2b-256 54a9f4e056b80f2122b592a284395aff19cb47524f8a3e36223ec33be20daf48

See more details on using hashes here.

File details

Details for the file neuroglancer-2.23.post1.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.23.post1.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84f4c13bd978c3653e0331e80497545babf4c293ed53665eb7cbc7ff84d5caa2
MD5 85d28842adf9b1dabcc660bd164b1477
BLAKE2b-256 0cd1a585bc536cdf4f307ce3fe6330f05878f7c3f9924665f61249dbebf136e3

See more details on using hashes here.

File details

Details for the file neuroglancer-2.23.post1.dev0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: neuroglancer-2.23.post1.dev0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for neuroglancer-2.23.post1.dev0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4e5eeb71f2e50554875b1e82ccac7bd8fe1707a538a4983ed5660098d22478c0
MD5 f2d775789d4cb545bd9345a814a4b02c
BLAKE2b-256 d95aec818bc8b8f38407df55dd4c05bb3394ee39be752f18c18109f666de45c2

See more details on using hashes here.

File details

Details for the file neuroglancer-2.23.post1.dev0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: neuroglancer-2.23.post1.dev0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for neuroglancer-2.23.post1.dev0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a3a0a15488259cbdecef2300e713cf2c441a607a62f6cd7f249cbf8d5c0a9430
MD5 8a514a975acb5131db9db42ffe4b7866
BLAKE2b-256 55ae0bf68fd7d4ea0f214dc3773211db3cd99ba996d49aa4e487a49c1f3f9135

See more details on using hashes here.

File details

Details for the file neuroglancer-2.23.post1.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.23.post1.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c653680df4a56ca61067f9bc2db7e1671abf83e18512218594f3b8513e67ad2
MD5 7edc4fd5f3c3430dd080adc1914173d1
BLAKE2b-256 d20fff2ef21c780f19941a1f0f9cb5f71938b62f34b62805c19da52de8918443

See more details on using hashes here.

File details

Details for the file neuroglancer-2.23.post1.dev0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: neuroglancer-2.23.post1.dev0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for neuroglancer-2.23.post1.dev0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d634dcc5967382b8276a807aa0bc13572dd539f5fd8317e7624d067c8425852d
MD5 c98da79bbb7fa2cc5075c54ab4b7bd0e
BLAKE2b-256 20955d8d0d27a5a5a6d6692afe800af3a6bdee6b3ffc101cbb9629d1e9a297ed

See more details on using hashes here.

File details

Details for the file neuroglancer-2.23.post1.dev0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: neuroglancer-2.23.post1.dev0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for neuroglancer-2.23.post1.dev0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5cd05f53e42cf65b4ba2ea319bde1bc69be2a08b3d90a180e14e76571a3f880a
MD5 2881a7ff1fdad525abc3d14664d49260
BLAKE2b-256 ff22b30e57cd7a8fcad2a82d00c915a2ddbebacf817a67cd5e71416151596768

See more details on using hashes here.

File details

Details for the file neuroglancer-2.23.post1.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.23.post1.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9712aa57f6b483e7b95b697a96fe157e3d931928a057baf559e68c474d831f9b
MD5 155149c8c50990c6eee9dbb2bd987ded
BLAKE2b-256 47bd52c36e50d6efea4e15fc6f086bc0b1812b63cdc5034125a633460ebc78d9

See more details on using hashes here.

File details

Details for the file neuroglancer-2.23.post1.dev0-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: neuroglancer-2.23.post1.dev0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for neuroglancer-2.23.post1.dev0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8cbf491ade0734cf823147a38ef06468df09ff1c3748a991aa682f2133ff3abd
MD5 567e1dc5f3c68d58b3a3a88abe68a460
BLAKE2b-256 82d1d228b4d161d8becbef6b8fd6bb9ad52c8b3c06154c1d158401066b513e3f

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