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

Uploaded Source

Built Distributions

neuroglancer-2.25.post1.dev0-cp310-cp310-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.10 Windows x86-64

neuroglancer-2.25.post1.dev0-cp310-cp310-musllinux_1_1_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

neuroglancer-2.25.post1.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

neuroglancer-2.25.post1.dev0-cp310-cp310-macosx_10_9_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

neuroglancer-2.25.post1.dev0-cp39-cp39-musllinux_1_1_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

neuroglancer-2.25.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.25.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.25.post1.dev0-cp38-cp38-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.8 Windows x86-64

neuroglancer-2.25.post1.dev0-cp38-cp38-musllinux_1_1_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

neuroglancer-2.25.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.25.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.25.post1.dev0-cp37-cp37m-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.7m Windows x86-64

neuroglancer-2.25.post1.dev0-cp37-cp37m-musllinux_1_1_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

neuroglancer-2.25.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.25.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.25.post1.dev0.tar.gz.

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0.tar.gz
Algorithm Hash digest
SHA256 0efb70df933547143c6cd1aae5bd57f171901fd48ba2e10bb8aa6e7eade50a8b
MD5 3affc41dccbb8f885e08f179076d2955
BLAKE2b-256 d0b01fbc497d71e16a5ca6414f28e862b14aea6c6c1b23e0be44ba4a32c4b441

See more details on using hashes here.

File details

Details for the file neuroglancer-2.25.post1.dev0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 877620b7058ec522658be4fc8f01c46ee971e15249cc1c99eb1a69922159d8c0
MD5 a03a12d0bfc2acc21beae9f7e1c9d9a0
BLAKE2b-256 0148a87143c57f53f9f4321f769b6bfec3a94a72100a308ee274877404632118

See more details on using hashes here.

File details

Details for the file neuroglancer-2.25.post1.dev0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 4c90e8ffaa3504a9f95638735982ff2d708a979f1da3bab6861d553d804b3b0c
MD5 a98c615c3c8526c7e8da49917ebb5ad1
BLAKE2b-256 8a6fad1b5925c9dc99c1893da77abdbfc4bb64e4ef2134f0f022e9bd0600a752

See more details on using hashes here.

File details

Details for the file neuroglancer-2.25.post1.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b1cac4392cc2ee34536ce63b880866bb686eae6ee6e77dc8bd912fe09a942346
MD5 ff39ac1c9fb6ab37a26ea284ca082f83
BLAKE2b-256 31fdcf1a8846aefc7e394833c4291883db2ccb05b3ce7f194b6896e42e7e3098

See more details on using hashes here.

File details

Details for the file neuroglancer-2.25.post1.dev0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ae6ffa2bfe610e0867c79a01d451c456d80aed5664e1d5602e8590751ed8202f
MD5 b41c77dd55b746720d4e8f214148f8fa
BLAKE2b-256 0fbe733e80bc43dfb9fc17bc3bf66894288ef377f76f534902243de43f11c257

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2f79e26894b48b1502a0548edf848374fa10f8df93d2196caee582c2cbb64b54
MD5 dc4c938a7f58e85b7a9686cd6fe4f157
BLAKE2b-256 4c354880d9c76719d3d5caaaca85a85b7c2c15281dadc53ee4648fd340eb9794

See more details on using hashes here.

File details

Details for the file neuroglancer-2.25.post1.dev0-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 2a7204be554c45501fb2c1a887f22eb0e25789c45972f3312891ce7253ef3d09
MD5 2c17d1a8c75b12a4f7287a0750a71e01
BLAKE2b-256 3c0cdc1a4be4a8078264191bd6c40cc159a6944753bb8190bb4ab38914cbac70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 785b256225738524e21d701c8ca5a6282d0f46ed926580f746d16dc46b478d15
MD5 9ac1b5489e8f69b3f5200550660ad84a
BLAKE2b-256 c1f27bc974b156e48aaf4144ad901900cf64e48cdac0c9e55fa887f9b40943b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6075e503ed3002ee66c98907cd9db512a4fc50bfed98d188bf6a96e5d0992ab4
MD5 d2775fd682f3b8c1901976eccb021e2e
BLAKE2b-256 87afeadd9c551f4892fe6d0c07e9e012d011e8a76237540b891188100155776c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 f4aa7c92a6e00689064178cd6b54b9aa780d2980b306d95d47ed838b180986f6
MD5 43b4efbe3eb49de198ce83e25255ee4f
BLAKE2b-256 5eeae5ccfad220f6db7af60122a9168c84984b1848f7a5dd70a63ee4499ff373

See more details on using hashes here.

File details

Details for the file neuroglancer-2.25.post1.dev0-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 afdeeb2c4f9e8ee5f78ab4c86f312e533282a8a711a6d6ab59430ce54d222a36
MD5 74c6997b65e55861eaa712f1c8e58cb3
BLAKE2b-256 45229ecb2aaffbfa0bcc48c96d4f1a637164a6585993d98e2bccedb2af3dbc7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ccaca989f82e0d9aea33e6deca948f8457bd5d42f787c7d0138228f1239c9e86
MD5 1c070ab1270b266999a10c885ce92c67
BLAKE2b-256 b26528da334cdff4bcee717f8cd1f8312ddc9f90cc7238744d9dbd766243b54f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5a7fad15a5153022ef80dbc401134b557503141a0da525f83c76127536575095
MD5 8a5fdc0c234eddbc658ebb7712b91619
BLAKE2b-256 fc915ccbbe3d639b9c718e117a1822ee74ef846d86abaec6c1210bf47a8582ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0d01d19447c21a41367597375578fac590e01ea37b71c9bafa04d59219f8da28
MD5 8ab4c8e7138cfdf5f2a222efa5eea06a
BLAKE2b-256 15de4b0fada0e573992af04be0c484fcdff7c38817b5efa0a70b53f0fc59971c

See more details on using hashes here.

File details

Details for the file neuroglancer-2.25.post1.dev0-cp37-cp37m-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 87605ea777ec4be8e5cfe490093043c826fb66901c0374476a8d0cd863f94636
MD5 6886a0e3ffe84c19f9a2a47118fb8826
BLAKE2b-256 db1a22fcde45d90493b2977258c4bea460d3550f541cef0bb5fadbb1ad778c00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 97caf21d300eccc97e43ca636004dc371222ab46af74654d0f4d863bc4b823f9
MD5 41bf97ae8882c651e552f3838f5a860a
BLAKE2b-256 2968b09c0e3e1b0518a410a02c791d5dc42970d9ed0a6de53f23fe27eb7c4389

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.25.post1.dev0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f3e6e132dbc9682f8e8f61f4640037cfc55c6e4a7c9f47b64d47200f52aca88d
MD5 1d39a117854a872b773a0e4288280d4f
BLAKE2b-256 3fe784e2bf998af8822bdb04a85f8ea7fa222539ae732f3948e79d59d4af62d8

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