Define rules that create tags in an omero server.
Project description
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
- This is because the omero-py package doesn't have getters for specific annotation types
- 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:
- Validate rules:
omero-ruletagger validate rules.yml
- Apply tags:
omero-ruletagger run rules.yml -O "Image:123" -O "Dataset:456"
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed807ed646e8d095446379f0e57f4ad42611983cec4258e12aba4e8d18900331
|
|
| MD5 |
5d33cc0ce9032661c282cd8a1795e99a
|
|
| BLAKE2b-256 |
802dc421e6f042016c9556828acfe7dfc46071a44516e2e98fa199ec3e085f59
|
Provenance
The following attestation bundles were made for omero_ruletagger-1.0.0.tar.gz:
Publisher:
python-publish.yml on laviolette-lab/omero-ruletagger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omero_ruletagger-1.0.0.tar.gz -
Subject digest:
ed807ed646e8d095446379f0e57f4ad42611983cec4258e12aba4e8d18900331 - Sigstore transparency entry: 172177509
- Sigstore integration time:
-
Permalink:
laviolette-lab/omero-ruletagger@f55274c4764bf7cd7d61d56846b10b7788a427e0 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/laviolette-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f55274c4764bf7cd7d61d56846b10b7788a427e0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file omero_ruletagger-1.0.0-py3-none-any.whl.
File metadata
- Download URL: omero_ruletagger-1.0.0-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e2fa64130ca01f37ba76b92a28776584a817e524340eff63832f1de4e7f5a4b
|
|
| MD5 |
cb6eba53713f0d1ee18937bc16e96fcd
|
|
| BLAKE2b-256 |
df226a1b2ff920321e4add1b6fc848ef833681ddd4ba5f3bc4241c4ef5e09481
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omero_ruletagger-1.0.0-py3-none-any.whl -
Subject digest:
0e2fa64130ca01f37ba76b92a28776584a817e524340eff63832f1de4e7f5a4b - Sigstore transparency entry: 172177512
- Sigstore integration time:
-
Permalink:
laviolette-lab/omero-ruletagger@f55274c4764bf7cd7d61d56846b10b7788a427e0 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/laviolette-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f55274c4764bf7cd7d61d56846b10b7788a427e0 -
Trigger Event:
release
-
Statement type: