Skip to main content

Neuroglancer compressed_segmentation codec.

Project description

PyPI version

import compressed_segmentation

sx, sy, sz = (128,128,128)
dtype = np.uint64
order = 'C'

labels = np.arange(0, sx*sy*sz, dtype=dtype).reshape((sx,sy,sz), order=order)
compressed = compressed_segmentation.compress(labels, order=order)
recovered = compressed_segmentation.decompress(
    compressed, (sx,sy,sz) dtype=dtype, order=order
)

NOTE: This repository is the PyPI distribution repo but is based on work done by Jeremy Maitin-Shepard (Google), Stephen Plaza (Janelia Research Campus), and William Silversmith (Princeton) here: https://github.com/janelia-flyem/compressedseg

Compress Seg Picture

Library for compressing and decompressing image segmentation (adapted from neuroglancer)

This library contains routined to decompress and compress segmentation and to manipulate compressed segmentation data defined by the neuroglancer project. compressed_segmentation essentially renumbers large bit width labels to smaller ones in chunks. This provides for large reductions in memory usage and higher compression.

Note that limitations in the compressed_segmentation format restrict the size of the chunk that can be compressed. As this limitation is data dependent, for example a random array with 1024 labels passes testing at 256x256x128, but 256x256x256 often does not.

Features

  • Compression and decompression
  • (TBD) Interface to relabel and manipulate segmentation from the compressed data
  • C++, Python, and Go interface (see original repo for Golang)

C++ Compilation

Compiling as a shared library. Feel free to subsititute e.g. clang for the C++ compiler.

g++ -std=c++11 -O3 -fPIC -shared -I./include src/compress_segmentation.cc src/decompress_segmentation.cc -o compress_segmentation.so

Python Installation

pip Binary Installation

$ pip install compressed-segmentation

$ python
>>> import compressed_segmentation as cseg
>>> help(cseg)

If there are pre-built binaries available for your architecture this should just work.

pip Source Installation

If you need to build from source, you will need to have a C++ compiler installed:

$ sudo apt-get install g++ python3-dev 
$ pip install numpy
$ pip install compressed-segmentation

$ python
>>> import compressed_segmentation as cseg
>>> help(cseg)

Direct Installation

Requires a C++ compiler such as g++ or clang.

Works with both Python 2 and 3. Encodes from / decodes to 3D or 4D numpy ndarrays.

$ sudo apt-get install g++ python3-dev 
$ pip install -r requirements.txt
$ python setup.py install

$ python
>>> import compressed_segmentation as cseg
>>> help(cseg)

License

Please see the licenses in this repo.

Project details


Download files

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

Files for compressed-segmentation, version 2.0.1
Filename, size File type Python version Upload date Hashes
Filename, size compressed_segmentation-2.0.1-cp27-cp27m-macosx_10_15_x86_64.whl (106.1 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp35-cp35m-manylinux1_x86_64.whl (519.4 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp35-cp35m-manylinux2010_x86_64.whl (606.7 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp35-cp35m-manylinux2014_x86_64.whl (648.1 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl (106.2 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp36-cp36m-manylinux1_x86_64.whl (526.8 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp36-cp36m-manylinux2010_x86_64.whl (613.5 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp36-cp36m-manylinux2014_x86_64.whl (653.6 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp36-cp36m-win32.whl (77.5 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp36-cp36m-win_amd64.whl (92.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl (106.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp37-cp37m-manylinux1_x86_64.whl (527.7 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp37-cp37m-manylinux2010_x86_64.whl (613.0 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp37-cp37m-manylinux2014_x86_64.whl (657.1 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp37-cp37m-win32.whl (77.5 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp37-cp37m-win_amd64.whl (92.1 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl (106.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp38-cp38-macosx_11_0_arm64.whl (93.5 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp38-cp38-manylinux1_x86_64.whl (533.6 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp38-cp38-manylinux2010_x86_64.whl (666.3 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp38-cp38-manylinux2014_x86_64.whl (703.6 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp38-cp38-win32.whl (79.6 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1-cp38-cp38-win_amd64.whl (94.7 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size compressed_segmentation-2.0.1.tar.gz (148.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page