Skip to main content

Define rules that create tags in an omero server.

Project description

PyPI version License: MIT Python Versions

OMERO.RuleTagger (Previously Known as OMERO.Autotagger)

A Python package for automated tagging of OMERO objects based on customizable rules and regex.

It works by walking the omero model as described by the omero-py wrappers and the underlying ObjectI classes. After the walk it compares a given reference value against the value it walked to, then tags if the condition passes.

Known Limitations

  • Currently impossible to add arguments to the model walk
    • For example a you can't filter a condition to only check annotations in a certain namespace
    • This example could be fixed by comparing the 'ns' property against the desired value, but it still won't filter
  • Cannot specify objects to operate on within the rules file.
    • Planned addition in schemav2 but wanted to get this out and get some feedback for schemav2
  • Doesn't handle Annotations very well.
    • This is because the omero-py package doesn't have getters for specific annotation types
      • This causes AttributeErrors
    • Map and Table Annotations especially need extra thought to be able to meaningfully rule against
  • Also doesn't handle properties
    • Due to the compilation process, we need getters to access properties
    • Could be possible to add with some lambda
      • Decided to leave as is for now because most properties have a getter (thanks java!)
  • Pretty slow and inefficient
    • Makes more requests than it needs to
    • Causes it to take longer than it needs to
    • Decided to leave as is for readability sake
      • We run it once a night, could probably do it once a week
      • Both walking and recursion can get complex, tried my best to stay legible (unlike my first implementation)

Documentation

For a proper in-depth explanation of the tool use the documentation.

Installation

Install using pip:

pip install omero-ruletagger

Dependencies

  • Python ≥3.8
  • PyYAML
  • inflect
  • omero-py

Usage

Command Line Interface

The package provides three main commands:

  1. Validate rules:
omero-ruletagger validate rules.yml
  1. Apply tags:
omero-ruletagger run rules.yml -O "Image:123" -O "Dataset:456"
  1. Dry run:
omero-ruletagger dry-run rules.yml -O "Image:789" -o results.csv

Connection Options

  • -s, --server: OMERO server hostname
  • -p, --port: OMERO server port
  • -u, --user: OMERO username
  • -w, --password: OMERO password
  • -k, --key: Existing session key
  • -S, --secure: Use secure connection
  • --sudo: Connect as administrator
  • -v, --verbose: Enable verbose logging

Rule Configuration

Create a YAML file defining your tagging rules. Example:

# test_rules.yml
- capture: "([^-.]+)"
  blacklist:
    - 1

- name: "FALSE"
  rules:
    - attribute_path: ["image", "roicount"]
      operation: lt
      value: 1

- name: "TRUE"
  rules:
    - attribute_path: ["image", "roi", "count"]
      operation: gt
      value: 0

- name: "Subtractive"
  absolute: false
  type: subtractive
  rules:
    - attribute_path: ["image", "roi","count"]
      operation: gt
      value: 0

- name: "UselessAND_TRUE"
  rules:
    - attribute_path: ["image", "roi", "shape", "strokecolor"]
      operation: eq
      value: 255
    - attribute_path: ["image", "roi", "shape", "count"]
      operation: eq
      value: 1

- name: "InherentlyFalseAND"
  rules:
    - attribute_path: ["image", "roi", "shape", "strokecolor"]
      operation: eq
      value: 255
    - attribute_path: ["image", "roi", "shape", "strokecolor"]
      operation: eq
      value: 254

- name: "DescriptionTest"
  rules:
    - attribute_path: ["image", "descriptions"]
      operation: match
      value: ".*test.*"

- name: "PhysicalSizeTest"
  rules:
    - attribute_path: ["image", "primarypixel", "physicalsizex"]
      operation: eq
      value: 1000
    - attribute_path: ["image", "primarypixel", "physicalsizey"]
      operation: eq
      value: 1000
    - attribute_path: ["image", "primarypixel", "physicalsizex", "unit", "name"]
      operation: eq
      value: "MICROMETER"

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

Links

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

omero_ruletagger-1.0.0.tar.gz (102.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omero_ruletagger-1.0.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file omero_ruletagger-1.0.0.tar.gz.

File metadata

  • Download URL: omero_ruletagger-1.0.0.tar.gz
  • Upload date:
  • Size: 102.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for omero_ruletagger-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ed807ed646e8d095446379f0e57f4ad42611983cec4258e12aba4e8d18900331
MD5 5d33cc0ce9032661c282cd8a1795e99a
BLAKE2b-256 802dc421e6f042016c9556828acfe7dfc46071a44516e2e98fa199ec3e085f59

See more details on using hashes here.

Provenance

The following attestation bundles were made for omero_ruletagger-1.0.0.tar.gz:

Publisher: python-publish.yml on laviolette-lab/omero-ruletagger

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

File details

Details for the file omero_ruletagger-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for omero_ruletagger-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e2fa64130ca01f37ba76b92a28776584a817e524340eff63832f1de4e7f5a4b
MD5 cb6eba53713f0d1ee18937bc16e96fcd
BLAKE2b-256 df226a1b2ff920321e4add1b6fc848ef833681ddd4ba5f3bc4241c4ef5e09481

See more details on using hashes here.

Provenance

The following attestation bundles were made for omero_ruletagger-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on laviolette-lab/omero-ruletagger

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