-
Notifications
You must be signed in to change notification settings - Fork 32
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
Changes from all commits
e293288
7e21b30
2734a4f
aa40781
9a3e84b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -247,15 +247,36 @@ def link_annotation(objects, file_ann): | |
o.linkAnnotation(file_ann) | ||
|
||
|
||
def get_images_from_plate(plate): | ||
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: | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is much more than Screen as indicated in the PR title. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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', | ||
|
There was a problem hiding this comment.
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"