Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch export ROIs from screen #156

Merged
merged 5 commits into from
Feb 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions omero/export_scripts/Batch_ROI_Export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

# -----------------------------------------------------------------------------
# Copyright (C) 2018-2019 University of Dundee. All rights reserved.
# Copyright (C) 2018-2020 University of Dundee. All rights reserved.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -247,15 +247,36 @@ def link_annotation(objects, file_ann):
o.linkAnnotation(file_ann)


def get_images_from_plate(plate):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for self
This is the kind of method to add to "omero-py-toolbox"

imgs = []
for well in plate.listChildren():
for ws in well.listChildren():
imgs.append(ws.image())
return imgs


def batch_roi_export(conn, script_params):
"""Main entry point. Get images, process them and return result."""
images = []

if script_params['Data_Type'] == "Image":
images = list(conn.getObjects("Image", script_params['IDs']))
else:
for dataset in conn.getObjects("Dataset", script_params['IDs']):
dtype = script_params['Data_Type']
ids = script_params['IDs']
if dtype == "Image":
images = list(conn.getObjects("Image", ids))
elif dtype == "Dataset":
for dataset in conn.getObjects("Dataset", ids):
images.extend(list(dataset.listChildren()))
elif dtype == "Project":
for project in conn.getObjects("Project", ids):
for dataset in project.listChildren():
images.extend(list(dataset.listChildren()))
elif dtype == "Plate":
for plate in conn.getObjects("Plate", ids):
images.extend(get_images_from_plate(plate))
elif dtype == "Screen":
for screen in conn.getObjects("Screen", ids):
for plate in screen.listChildren():
images.extend(get_images_from_plate(plate))

log("Processing %s images..." % len(images))
if len(images) == 0:
Expand All @@ -278,18 +299,19 @@ def batch_roi_export(conn, script_params):

# Write to csv
file_ann = write_csv(conn, export_data, script_params, symbol)
if script_params['Data_Type'] == "Dataset":
datasets = conn.getObjects("Dataset", script_params['IDs'])
link_annotation(datasets, file_ann)
else:
if dtype == "Image":
link_annotation(images, file_ann)
else:
objects = conn.getObjects(dtype, script_params['IDs'])
link_annotation(objects, file_ann)
message = "Exported %s shapes" % len(export_data)
return file_ann, message


def run_script():
"""The main entry point of the script, as called by the client."""
data_types = [rstring('Dataset'), rstring('Image')]
data_types = [rstring(s) for s in
Copy link
Member

@jburel jburel Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much more than Screen as indicated in the PR title.
All types of containers need to be reviewed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is in the description. Not space in the title for all testing instructions.

['Screen', 'Plate', 'Project', 'Dataset', 'Image']]

client = scripts.client(
'Batch_ROI_Export.py',
Expand Down