Skip to main content

pypi Python Version

nps: distributed point cloud sampling

nps samples point clouds of every segment in a large segmentation volumes

  • Compatible with CloudVolume (precomputed or graphene).
  • It processes the volume blockwise on local, LSF or Slurm workers and writes the points in pocaduck format.
pip install nps-cli
nps --help

Usage

# Whole volume
nps --cv-path precomputed://gs://neuroglancer-janelia-flyem-hemibrain/v1.0/segmentation

# Subvolume (begin_x begin_y begin_z end_x end_y end_z, in voxels), 1% of each segment
nps --cv-path precomputed://gs://neuroglancer-janelia-flyem-hemibrain/v1.0/segmentation \
    --bbox 15347 19712 18606 15859 20224 19118 --fraction 0.01

# Also store the supervoxel ID of every point, looked up in a separate volume
# that shares the voxel grid of --cv-path
nps --cv-path precomputed://gs://<bucket>/agglomerated \
    --svid-cv-path precomputed://gs://<bucket>/supervoxels

# Graphene: read supervoxels from the same volume (agglomerate=False)
nps --cv-path graphene://https://<server>/segmentation/table/<table> --sample_svids

Key options (run nps --help for all of them):

Option Default Meaning
--fraction 0.001 Fraction of each segment's voxels to sample (at least 1 per segment and block).
--mip 0 Resolution level to sample at. Coordinates are voxels of this mip.
--bbox whole volume ROI in voxels.
--block-size 128 128 128 Block size per task, in voxels.
--worker-type / --num-workers / --cpus-per-worker / --queue LocalWorker / 8 / 4 / local Where and how the blocks are processed.
--fill-missing off Treat missing chunks as empty instead of raising an error.
--overwrite off Delete points of an earlier run in --output-dir instead of refusing to start.
--skip-empty / --block-mask / --mask-mip on Skipping empty blocks, see below.

Output

<output-dir>/
  block_mask.npy            # occupancy mask from the empty-block pre-scan
  points/
    unified_index.db        # pocaduck index over all workers
    worker_<id>/...         # parquet files + per-worker index

Each point is [x, y, z], or [x, y, z, svid] when SVIDs are sampled, stored under its segment label.

nps refuses to write into an --output-dir that already holds points, since every run re-samples all blocks and old points would show up as duplicates. Pass --overwrite to delete them first.

Skipping empty blocks

Before sampling, nps scans the ROI at a coarse mip (--mask-mip, default the coarsest one) and never dispatches blocks without labels. The mask is dilated by one block, so thin structures lost in downsampling are still sampled. Use --no-skip-empty to disable the scan, or --block-mask <path> to reuse a block_mask.npy from an earlier run with the same --bbox, --block-size and --mip.

Reading point clouds

from pocaduck import Query, StorageConfig

query = Query(storage_config=StorageConfig(base_path="<output-dir>/points"))
labels = query.get_labels()
points = query.get_points(label=12345)  # all points of one segment
query.close()

See the pocaduck docs for more, including optimizing the storage for fast reads.

Example scripts

Script What it does
liconn_local.sh Points only, local workers
liconn_svids_local.sh Points + SVIDs from a separate precomputed volume
flywire_cluster.sh Points + SVIDs for FlyWire on LSF (LABEL_NAME=flywire_v141_m783 for the 2023 snapshot)

Release

pip install -e ".[dev]"
python -m build
twine upload dist/*

Metadata

Release files for nps-cli 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nps-cli 0.1.5
File Size Uploaded Provenance Actions
nps_cli-0.1.5.tar.gz 13.2 kB Without provenance Details for nps_cli-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nps-cli 0.1.5
File Interpreter ABI Platform Actions
nps_cli-0.1.5-py3-none-any.whl Python 3 none any Details for nps_cli-0.1.5-py3-none-any.whl

Total release size: 25.6 kB

Release files / nps_cli-0.1.5.tar.gz

Download URL nps_cli-0.1.5.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8d42e8040640c58b9d79c55d285c9494c6ccb624e3f77e6cc9ef147ff8016901
BLAKE2b-256 checksum
How to use checksums
2a12132ef889f5cf34ccd2ad17f46a218f1b0131405a84e65b6eee323a6bb720
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / nps_cli-0.1.5-py3-none-any.whl

Download URL nps_cli-0.1.5-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44e8475ae70b5d64fa06abdf0e6298379f897ba5c6ef66945e8539a308e4fb7a
BLAKE2b-256 checksum
How to use checksums
f597d559b642554ac93f3e2fc965dce4e989f0c8f9c4d4324133ab140409a9ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for nps-cli 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page