# HG changeset patch
# User ufz
# Date 1726158636 0
# Node ID 4f4dc352d660ccaf172ef1e3b7e5e76573431e06
# Parent e957793051a84707194d1f1e5fee5fc5d41d97b2
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 266752b0162fbdb32f132a6702cb661ae36f48f0
diff -r e957793051a8 -r 4f4dc352d660 omero_metadata_upload.py
--- a/omero_metadata_upload.py Fri Sep 06 08:26:12 2024 +0000
+++ b/omero_metadata_upload.py Thu Sep 12 16:30:36 2024 +0000
@@ -1,4 +1,5 @@
import argparse
+import json
from datetime import datetime
import ezomero as ez
@@ -73,8 +74,7 @@
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Import metadata into OMERO.')
- parser.add_argument('--user', required=True, help='OMERO username')
- parser.add_argument('--pws', required=True, help='OMERO password')
+ parser.add_argument("--credential-file", dest="credential_file", type=str, required=True, help="Credential file (JSON file with username and password for OMERO)")
parser.add_argument('--host', required=True, help='OMERO host')
parser.add_argument('--port', required=True, type=int, help='OMERO port')
parser.add_argument('--obj_type', required=True, choices=['project', 'screen', 'dataset', 'image'],
@@ -87,6 +87,9 @@
args = parser.parse_args()
- metadata_import_ezo(user=args.user, pws=args.pws, host=args.host, port=args.port,
+ with open(args.credential_file, 'r') as f:
+ crds = json.load(f)
+
+ metadata_import_ezo(user=crds['username'], pws=crds['password'], host=args.host, port=args.port,
obj_type=args.obj_type, did=args.did, ann_type=args.ann_type,
ann_file=args.ann_file, an_name=args.an_name, log_file=args.log_file)
diff -r e957793051a8 -r 4f4dc352d660 omero_roi_import.xml
--- a/omero_roi_import.xml Fri Sep 06 08:26:12 2024 +0000
+++ b/omero_roi_import.xml Thu Sep 12 16:30:36 2024 +0000
@@ -3,7 +3,7 @@
with ezomero
5.18.0
- 2
+ 3
omero
@@ -15,15 +15,22 @@
openjdk
+
+
+
@@ -52,6 +59,19 @@
+
+
+
+
+
+
+
+
+
@@ -62,7 +82,7 @@
in a tabular format (TSV file). The tool reads the shape information from the TSV file, creates the
corresponding ROIs in OMERO, and links them to a specified image.
-**Column Headers**:
+**Column Headers** (not all columns are required for all shapes):
- shape, x, y, x_rad, y_rad, width, height, label, fontSize, x1, y1, x2, y2, points, fill_color, stroke_color, stroke_width, z, c, t, roi_name, roi_description
@@ -74,6 +94,10 @@
The columns **x**, **y**, **x_rad**, **y_rad**, **width**, and **height** specify the position and dimensions of the shapes, where applicable. For example, Ellipse uses x, y, x_rad, and y_rad, while Rectangle uses x, y, width, and height.
+- *Label*:
+
+ Any ROI can be labelled using the column **label**, this label will appear on the OMERO web interface.
+
- *Text Labels*:
The **label** and **fontSize** columns are used for the Label shape, specifying the text content and font size.
@@ -84,11 +108,11 @@
- *Point Coordinates*:
- The **points** column is used for defining multiple points in shapes like Polygon and Polyline. The points are listed as coordinate pairs.
+ The **points** column is used for defining multiple points in shapes like Polygon and Polyline. The points are listed as coordinate pairs, like '(300,300),(350,350),(300,400)'
- *Colors*:
- The **fill_color** and **stroke_color** columns define the fill and stroke colors of the shapes in RGBA format.
+ The **fill_color** and **stroke_color** columns define the fill and stroke colors of the shapes in RGBA format, like '(0,255,255,128)'.
- *Stroke Width*:
@@ -100,7 +124,7 @@
- *ROI Identification*:
- The **roi_name** and **roi_description** columns provide a name and description for each ROI, allowing for easy identification and documentation within OMERO.
+ The **roi_name** and **roi_description** columns provide a name and description for each ROI, allowing for easy identification and documentation within OMERO however they do not appear on the OMERO web interface.
diff -r e957793051a8 -r 4f4dc352d660 omero_roi_upload.py
--- a/omero_roi_upload.py Fri Sep 06 08:26:12 2024 +0000
+++ b/omero_roi_upload.py Thu Sep 12 16:30:36 2024 +0000
@@ -1,6 +1,8 @@
import argparse
+import json
import re
+import numpy as np
import pandas as pd
from ezomero import connect, post_roi
from ezomero.rois import Ellipse, Label, Line, Point, Polygon, Polyline, Rectangle
@@ -35,6 +37,7 @@
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
+ label=row.get('label'),
fill_color=parse_color(row.get('fill_color')),
stroke_color=parse_color(row.get('stroke_color')),
stroke_width=row.get('stroke_width')
@@ -60,7 +63,7 @@
y2=row['y2'],
markerStart=row.get('markerStart', None),
markerEnd=row.get('markerEnd', None),
- label=row.get('label', None),
+ label=row.get('label'),
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
@@ -75,6 +78,7 @@
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
+ label=row.get('label'),
fill_color=parse_color(row.get('fill_color')),
stroke_color=parse_color(row.get('stroke_color')),
stroke_width=row.get('stroke_width')
@@ -85,6 +89,7 @@
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
+ label=row.get('label'),
fill_color=parse_color(row.get('fill_color')),
stroke_color=parse_color(row.get('stroke_color')),
stroke_width=row.get('stroke_width')
@@ -95,6 +100,7 @@
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
+ label=row.get('label'),
fill_color=parse_color(row.get('fill_color')),
stroke_color=parse_color(row.get('stroke_color')),
stroke_width=row.get('stroke_width')
@@ -108,6 +114,7 @@
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
+ label=row.get('label'),
fill_color=parse_color(row.get('fill_color')),
stroke_color=parse_color(row.get('stroke_color')),
stroke_width=row.get('stroke_width')
@@ -119,6 +126,8 @@
# Open log file
with open(log_file, 'w') as log:
df = pd.read_csv(input_file, sep='\t')
+ # Replace nan to none
+ df = df.replace({np.nan: None})
for index, row in df.iterrows():
msg = f"Processing row {index + 1}/{len(df)}: {row.to_dict()}"
print(msg)
@@ -143,17 +152,19 @@
parser.add_argument("--input_file", help="Path to the input tabular file.")
parser.add_argument("--image_id", type=int, required=True, help="ID of the image to which the ROI will be linked")
parser.add_argument("--host", type=str, required=True, help="OMERO server host")
- parser.add_argument("--user", type=str, required=True, help="OMERO username")
- parser.add_argument("--psw", type=str, required=True, help="OMERO password")
+ parser.add_argument("--credential-file", dest="credential_file", type=str, required=True, help="Credential file (JSON file with username and password for OMERO)")
parser.add_argument("--port", type=int, default=4064, help="OMERO server port")
parser.add_argument("--log_file", type=str, default="process.txt", help="Log file path")
args = parser.parse_args()
+ with open(args.credential_file, 'r') as f:
+ crds = json.load(f)
+
conn = connect(
host=args.host,
- user=args.user,
- password=args.psw,
+ user=crds['username'],
+ password=crds['password'],
port=args.port,
group="",
secure=True
diff -r e957793051a8 -r 4f4dc352d660 test-data/input_roi_minimal.tsv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/input_roi_minimal.tsv Thu Sep 12 16:30:36 2024 +0000
@@ -0,0 +1,2 @@
+shape points label
+Polygon (300,300),(350,350),(300,400) Example ROI
diff -r e957793051a8 -r 4f4dc352d660 test-data/output_table_roi.txt
--- a/test-data/output_table_roi.txt Fri Sep 06 08:26:12 2024 +0000
+++ b/test-data/output_table_roi.txt Thu Sep 12 16:30:36 2024 +0000
@@ -1,14 +1,14 @@
-Processing row 1/7: {'shape': 'Ellipse', 'x': 50.0, 'y': 50.0, 'x_rad': 20.0, 'y_rad': 10.0, 'label': nan, 'fontSize': nan, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': nan, 'width': nan, 'height': nan, 'fill_color': '(255,0,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 1/7: {'shape': 'Ellipse', 'x': 50.0, 'y': 50.0, 'x_rad': 20.0, 'y_rad': 10.0, 'label': None, 'fontSize': None, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': None, 'width': None, 'height': None, 'fill_color': '(255,0,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 1 for row 1
-Processing row 2/7: {'shape': 'Label', 'x': 100.0, 'y': 100.0, 'x_rad': nan, 'y_rad': nan, 'label': 'Test Label', 'fontSize': 12.0, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': nan, 'width': nan, 'height': nan, 'fill_color': '(255,255,255,0)', 'stroke_color': '(0,0,255,255)', 'stroke_width': 1, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 2/7: {'shape': 'Label', 'x': 100.0, 'y': 100.0, 'x_rad': None, 'y_rad': None, 'label': 'Test Label', 'fontSize': 12.0, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': None, 'width': None, 'height': None, 'fill_color': '(255,255,255,0)', 'stroke_color': '(0,0,255,255)', 'stroke_width': 1, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 2 for row 2
-Processing row 3/7: {'shape': 'Line', 'x': nan, 'y': nan, 'x_rad': nan, 'y_rad': nan, 'label': nan, 'fontSize': nan, 'x1': 200.0, 'y1': 200.0, 'x2': 250.0, 'y2': 250.0, 'points': nan, 'width': nan, 'height': nan, 'fill_color': '(0,255,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 1, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 3/7: {'shape': 'Line', 'x': None, 'y': None, 'x_rad': None, 'y_rad': None, 'label': None, 'fontSize': None, 'x1': 200.0, 'y1': 200.0, 'x2': 250.0, 'y2': 250.0, 'points': None, 'width': None, 'height': None, 'fill_color': '(0,255,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 1, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 3 for row 3
-Processing row 4/7: {'shape': 'Point', 'x': 150.0, 'y': 150.0, 'x_rad': nan, 'y_rad': nan, 'label': nan, 'fontSize': nan, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': nan, 'width': nan, 'height': nan, 'fill_color': '(0,0,255,128)', 'stroke_color': '(255,0,0,255)', 'stroke_width': 3, 'z': 0, 'c': 2, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 4/7: {'shape': 'Point', 'x': 150.0, 'y': 150.0, 'x_rad': None, 'y_rad': None, 'label': None, 'fontSize': None, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': None, 'width': None, 'height': None, 'fill_color': '(0,0,255,128)', 'stroke_color': '(255,0,0,255)', 'stroke_width': 3, 'z': 0, 'c': 2, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 4 for row 4
-Processing row 5/7: {'shape': 'Polygon', 'x': nan, 'y': nan, 'x_rad': nan, 'y_rad': nan, 'label': nan, 'fontSize': nan, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': '(300,300),(350,350),(300,400)', 'width': nan, 'height': nan, 'fill_color': '(255,255,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 1, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 5/7: {'shape': 'Polygon', 'x': None, 'y': None, 'x_rad': None, 'y_rad': None, 'label': None, 'fontSize': None, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': '(300,300),(350,350),(300,400)', 'width': None, 'height': None, 'fill_color': '(255,255,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 1, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 5 for row 5
-Processing row 6/7: {'shape': 'Polyline', 'x': nan, 'y': nan, 'x_rad': nan, 'y_rad': nan, 'label': nan, 'fontSize': nan, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': '(400,400),(450,450),(400,500)', 'width': nan, 'height': nan, 'fill_color': '(0,255,255,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 3, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 6/7: {'shape': 'Polyline', 'x': None, 'y': None, 'x_rad': None, 'y_rad': None, 'label': None, 'fontSize': None, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': '(400,400),(450,450),(400,500)', 'width': None, 'height': None, 'fill_color': '(0,255,255,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 3, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 6 for row 6
-Processing row 7/7: {'shape': 'Rectangle', 'x': 500.0, 'y': 500.0, 'x_rad': nan, 'y_rad': nan, 'label': nan, 'fontSize': nan, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': nan, 'width': 100.0, 'height': 50.0, 'fill_color': '(255,0,255,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 7/7: {'shape': 'Rectangle', 'x': 500.0, 'y': 500.0, 'x_rad': None, 'y_rad': None, 'label': None, 'fontSize': None, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': None, 'width': 100.0, 'height': 50.0, 'fill_color': '(255,0,255,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 7 for row 7
diff -r e957793051a8 -r 4f4dc352d660 test-data/output_table_roi_minimal.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/output_table_roi_minimal.txt Thu Sep 12 16:30:36 2024 +0000
@@ -0,0 +1,2 @@
+Processing row 1/1: {'shape': 'Polygon', 'points': '(300,300),(350,350),(300,400)', 'label': 'Example ROI'}
+ROI ID: 8 for row 1