Open jithumurugan opened 3 years ago
Hi, I recently wrote a script that does both downloading files for all the Images in a Dataset, and also re-imports them to another server (for users who wanted to transfer data from one OMERO server to another): https://gist.github.com/will-moore/dab2148ef566125b60625f7773aa1b64
NB: The import uses https://gitlab.com/openmicroscopy/incubator/omero-python-importer/-/blob/master/import.py which is not part of the BlitzGateway or an installable library yet, so you need to download it (see instructions in the script).
Discussion was at https://forum.image.sc/t/transfer-a-project-dataset-between-omero-instances/30295/13
We'll need to discuss what to do with that import script, since it is becoming more widely used cc @joshmoore
Hello Will,
Thank you so much for providing the scripts and sharing the necessary links, I missed one thing, ideally exporting all the data under a dataset and also the regions/annotations done on them. Do you think, if I extend the script you provided, would it be possible to get the regions and additional annotation done on these images also?
Regards Jithu
Please feel free to adapt the script to your needs. Although the "transfer" workflow of the script (from one OMERO server to another) is not what you are needing, right? For your workflow I imagine you'd want to just use some parts of that script, and remove other parts? In what format would you want to download the regions / annotations? Do you need any help with that part, or do the current docs have what you need?
Hello Will,
In my case, I would like to export the images & regions out of OMERO, run some processing algorithms to generate some results (images + ROIs) and send them back to omero server. Right now I am preparing a container to do the external processing and inside which I need to download the data, process it and then send the data back. For which I was looking for some gateway functions which can do the export and import. what would be your suggestion for my requirements, is it the right approach or should I go for a different approach?
The script you have provided is very good and would be helpful for my scenarios, but in general would it not be better to have some gateway functions like _gateway.download('download_loc_local_dir', 'imageid'): specific image download _/gateway.download('download_loc_local_dir', 'datasetid'): batch download from dataset and also something like _gateway.upload('local_dir_image_location', 'data_setid') for downloading and uploading images and also the regions/annotations? Thanks
This approach sounds fine. What format does your processing software need to read the ROIs? JSON? XML? yml? You can access ROIs via Python API as in https://docs.openmicroscopy.org/omero/5.6.3/developers/Python.html#rois
I created a new issue for adding functions to the gateway: https://github.com/ome/omero-py/issues/284
Thanks Will, this would be really great if we have such export import functionalities in gateway. I would always go for JSON and too I think this would be really the representation widely used by many in the community. Thanks for giving the link also,
You can convert omero.model
objects into JSON using https://github.com/ome/omero-marshal
For example:
from omero_marshal import get_encoder
import json
image_id = 153
roi_service = conn.getRoiService()
result = roi_service.findByImage(image_id, None)
with open(f'Image_{image_id}_ROIs.json', 'w') as json_file:
rois_json = []
for roi in result.rois:
encoder = get_encoder(roi.__class__)
rois_json.append(encoder.encode(roi))
json_file.write(json.dumps({'rois': rois_json}))
I could not find any functions specified in documentation to export and import images via python. I can see that, I would be able to render image, but if I want to download a list of .scn images under a dataset and save all of them in a folder, is it somehow possible in the current version. Since we have a lot of clients, not sure if this is somehow possible using gateway api or any other module?
https://github.com/ome/ome-documentation/blob/develop/omero/developers/PythonBlitzGateway.rst
Please let me know if this is possible, ideally my requirement is to download/upload a set of images under a dataset in python. I would expect this to be part of Blitzgateway, If available could someone add this information as part of the gateway documentation above? Thanks
Regards Jithu