Skip to main content

Annotation Database pendant to the chunkedgraph

Project description

DynamicAnnotationDB

Actions Status PyPI version Documentation Status

DynamicAnnotationDB (DADB) is an interface layer for creating, modifying and interacting with PostgreSQL databases used to store spatial point annotations and segmentation data defined by a chunkedgraph.

Features

  • Create and manage PostgreSQL databases for annotation storage
  • Handle spatial point annotations with PostGIS integration
  • Support for segmentation data linked to annotations
  • Dynamic schema generation and validation
  • CRUD operations for annotations and segmentation data
  • Reference annotation support with table linking
  • Built-in versioning and tracking of modifications

Installation

You can install DynamicAnnotationDB using pip:

pip install DynamicAnnotationDB

Or install from source:

git clone https://github.com/CAVEconnectome/DynamicAnnotationDB
cd DynamicAnnotationDB
pip install -e .

Quick Start

Here's a basic example of using DynamicAnnotationDB:

from dynamicannotationdb import DynamicAnnotationInterface

# Connect to database
sql_uri = "postgresql://postgres:postgres@localhost:5432"
aligned_volume = "my_annotations"
interface = DynamicAnnotationInterface(sql_uri, aligned_volume)

# Create a new annotation table
table_name = "synapse_annotations"
interface.annotation.create_table(
    table_name=table_name,
    schema_type="synapse",
    description="Synapse annotations for dataset X",
    user_id="user@example.com",
    voxel_resolution_x=4.0,
    voxel_resolution_y=4.0,
    voxel_resolution_z=40.0
)

# Insert annotations
annotations = [{
    "pre_pt": {"position": [121, 123, 1232]},
    "ctr_pt": {"position": [128, 143, 1232]},
    "post_pt": {"position": [235, 187, 1232]},
    "size": 1
}]

annotation_ids = interface.annotation.insert_annotations(table_name, annotations)

Key Components

The interface consists of several key components:

  • Annotation Client: Handle CRUD operations for annotation data
  • Segmentation Client: Manage segmentation data linked to annotations
  • Schema Client: Generate and validate dynamic schemas
  • Database Client: Core database operations and metadata management

Documentation

Full documentation is available at dynamicannotationdb.readthedocs.io.

Features in Detail

Dynamic Schema Support

DADB uses EMAnnotationSchemas to define table structures:

# Create a table with a specific schema
interface.annotation.create_table(
    table_name="my_table",
    schema_type="synapse",
    description="Description",
    user_id="user@example.com",
    voxel_resolution_x=4.0,
    voxel_resolution_y=4.0,
    voxel_resolution_z=40.0
)

Segmentation Support

Link segmentation data to annotations:

# Create a segmentation table
seg_table = interface.segmentation.create_segmentation_table(
    table_name="my_table",
    schema_type="synapse", 
    segmentation_source="seg_source"
)

# Insert linked data
interface.segmentation.insert_linked_annotations(
    table_name="my_table",
    pcg_table_name="seg_source",
    annotations=[...]
)

Reference Tables

Create tables that reference other annotations:

# Create a reference table
interface.annotation.create_table(
    table_name="reference_table",
    schema_type="reference_type",
    description="Reference annotations",
    user_id="user@example.com",
    voxel_resolution_x=4.0,
    voxel_resolution_y=4.0,
    voxel_resolution_z=40.0,
    table_metadata={
        "reference_table": "target_table",
        "track_target_id_updates": True
    }
)

Development

Requirements

  • Python 3.7+
  • PostgreSQL with PostGIS extension
  • Docker (optional, for testing)

Testing

Run tests with pytest:

# Install test requirements
pip install -r test_requirements.txt

# Run tests (requires a PostgreSQL with PostGIS extension running)
pytest

# Run tests with a temporary Docker PostgreSQL instance (preferred local testing method)
pytest --docker=true

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, please open an issue on the GitHub repository.

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

DynamicAnnotationDB-5.13.1.tar.gz (32.3 kB view details)

Uploaded Source

File details

Details for the file DynamicAnnotationDB-5.13.1.tar.gz.

File metadata

  • Download URL: DynamicAnnotationDB-5.13.1.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for DynamicAnnotationDB-5.13.1.tar.gz
Algorithm Hash digest
SHA256 fd047086090ce0169f59f469789c58f8f145681052db56291d6741419325a2b4
MD5 286be2a2610c7d81e3e3f3fc47abecff
BLAKE2b-256 40b5476da64a201aaf4287fa9f6e66fc4b899192c741d436afdb2e8e862b625b

See more details on using hashes here.

Provenance

The following attestation bundles were made for DynamicAnnotationDB-5.13.1.tar.gz:

Publisher: release.yml on CAVEconnectome/DynamicAnnotationDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page