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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.10 Windows x86-64

neuroglancer-2.26.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.26.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.26.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.26.post1.dev0-cp39-cp39-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.7m Windows x86-64

neuroglancer-2.26.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.26.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.26.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.26.post1.dev0.tar.gz.

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0.tar.gz
Algorithm Hash digest
SHA256 1144ee09129c0a588517a1e605f1fc2b1e6212553869affb56efe22f77d84119
MD5 ff3aa511108718f1545e4beee62efcf7
BLAKE2b-256 47feac016d4c2a639fe15b9425aae8ec33eccede0212542986d69f2fa4402bf3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3fe4c820a39778613998761ea62fc7e43707710f748f67e776b7e1dae48f3291
MD5 241b99856236f8db8c52dffd131ba1d0
BLAKE2b-256 26d3bc486746e3e85c33015568d919750317c5c138d461187b377fb74277be52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 8af669799e1e66653396eec4c18d62e3cb8d39398edf05151c48dd2f66367640
MD5 1a6a8e3cd70068087aca658f0ac1505d
BLAKE2b-256 4d8557206d443c00409d64d02efbeda4950bccf384f3b36034b43a25ec0ee9ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e316be4477cc31a0dd4c3bdf874755a9a992d8114b4b2a6063933d641ba0961
MD5 681cd9c6f4f233b61074d3c683eaa769
BLAKE2b-256 0296eefcff0d0b70870500db5e50ef54d2cf9aaa4547123587b101a286571717

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a0f4cd843e0d0f181f4009580225cab88bda6b045727cb99bcf01824c53d678a
MD5 04d4171586d3f1bbed8e473ce700718e
BLAKE2b-256 a318b348cdd6ef2001359a244132c7602af0bd4523e5428491f7851ac6ea7368

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b7c622757d67bd7b30971208743582bb49b66d5c2cd8a8dbbd4f3cb3fed8eda8
MD5 ba9dd896776cf5f7c73ec45bfcc20c92
BLAKE2b-256 7ef7efbd3574fb740d7c2e8f791a7dc977db6061b68040661c425bcd9ce95e38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 8ab79a4aa1b3b08b11d6d2bf04c10b9f37e2336144ad9b2596d2eda51a8ea201
MD5 896216eca62142839e2b7cb48b1c9026
BLAKE2b-256 64dff0a0e9f9df766611f346c1f088328f2ebc3b9e0551bd695a787f3210c7cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e807544bf7fcc29bfe97384a9746ce31998b862aec361a84792439abcb45cf3a
MD5 d74546657a4f8212ad7d2a4dd799ef22
BLAKE2b-256 bb1aceeb48117fea90d89b01a18ab6e36ccd7482fd1740895e0c2df2d7063749

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 92eec08c98b7700ea880697d22db44554d565baca0588e7cf202b9598fdacb8b
MD5 c20667af61103048a150d5cebdb30323
BLAKE2b-256 d5ed046d957ab201d5b8d332cb14845051baa36137f192bc9c7508003876318c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6306767fb41a065b1068c6c4bdfdeabd32d3bda6550304364ab2b80394e49606
MD5 488565a7d3a8ccfde4ffa1ce4c0ebcba
BLAKE2b-256 856be3fddfd1b687ea778e6eb7a06771b4d2cc08e493c60f1ee0bef7d3b4b2e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 6268b1baa77548a1c4c962135486f00f1ac5dcdbdf6344e877dff8c0253bd9d9
MD5 803c75bfa9a0f393808792f5805cc33d
BLAKE2b-256 713606fe894f02cf404f37a478e051af524c289d03fcf92e8902c81310d33e12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a7b80235c843d9fe0a074d001254c1ac45192d31f1a6300e94b79e3f31c3090
MD5 b92f1aba577319fdefe1ba29f59a13ae
BLAKE2b-256 5eb850c7726cb1d6268857a91e9cbffd541b48bd1186cdc2d0e8578e06124076

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d9bd635d78134286f09c955083d1fb3092d204d8cd447c86ba57aff1081b5713
MD5 bf423f3b9a6cfddf89cd24ff7bf650e4
BLAKE2b-256 5793becff49eee159401795d4906c6b3a9f2f256dcf010f5cc5d178e5246428f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 9d0ba7b63cd2e926142bebc65ca91a5e32e0de4e738031963f2ae6ee36fcf0a2
MD5 9aeb91c783531736761532b612dd3007
BLAKE2b-256 d710b3b0ada769371c540df08ee86262fa35d8413ab6b68c3c9bb3f957c91d37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 8eeec8f697ca676b1728a7c527225e0d9c1836525e056cd906efa44946bc08d8
MD5 d595e84fa9b819084e002ea2ab2ea070
BLAKE2b-256 ff9461f5a1d4ea61f4de1fd97d66856a9b04216038669fdeb82e999b11fb3754

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8532e74a4d01741e721639c018de063858e0d1bc5beb339c01c51cac1e787717
MD5 95d10cbea4a5fdc5e25c7ca7dd34d31a
BLAKE2b-256 bddffe6d1c89d1b7be3f4748ecea673753dab0b2ccf9a5f5da731da69a96bc05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroglancer-2.26.post1.dev0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d2b4fd50ecc5eb2e5b429d1f1a33d086ab932350524ce40054146e6e125fbe37
MD5 573cad7315230fce1b65a90ae5724b7e
BLAKE2b-256 1fab9fb4ab1573c9c7d6b9638d25989542d5d900eb7822e267677dbadb65476a

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