Import metadata using the Command Line Interface (CLI)


This chapter will show how to import metadata starting from a local CSV file and ending with OMERO.tables on images or Key-Value pairs on images using the Command Line Interface (CLI) and the OMERO server-side scripts.

This action is typically done after a successful import of images.

We will show:

  • How to import metadata from local CSV file in a bulk manner and turn them into OMERO.tables on images using CLI
  • How to turn the OMERO.tables on images into Key-Value pairs on images in bulk manner using CLI
  • How to import metadata from local CSV file and use a server-side script in OMERO to turn these into OMERO.tables on images
  • How to construct a simple file to turn the metadata stored in OMERO.tables into Key-Value pairs on images using CLI



Metadata plugin installation

  • Go to the environment where you installed your OMERO.cli as specified under - CLI installation.

  • Activate the virtual environment.

  • Run:

    $ pip install omero-metadata


  1. On your local machine, open a terminal

  2. If you did not do so already, activate the virtual environment where omero-py is installed or add it to PATH e.g.:

    $ export PATH=/opt/omero/server/venv3/bin:$PATH
  3. Download the CSV from idr0021-experimentA-annotation.csv if you have access to the idr0021 data in your OMERO.server. Alternatively, download simple-annotation.csv, which will allow you to work with the siRNAi-HeLa dataset.

  4. The variable $ID​ below is the ID of the ​Project, in this example case it is the Project containing the idr0021 study. If you are working with the siRNAi-HeLa data, replace in the following example the “Project” with a “Dataset” and the idr0021-experimentA-annotation.csv with simple-annotation.csv. To add annotations from a local CSV file to the images in the said Project or Dataset in the form of OMERO.tables, run:

    $ omero metadata populate --report --batch 1000 --file local/path/to/idr0021-experimentA-annotation.csv Project:$ID
  5. Open your browser and login to the OMERO.web. Navigate to the Project or Dataset you just worked with, expand the “Attachments” harmonica in the right-hand pane and verify that a new attachment is on that Project named bulk_annotations.


  6. You can inspect its content by clicking on the “eye” icon image1 inside the annotation.

  7. Select an image inside the Project/Dataset and expand the “Tables” harmonica in the right-hand pane. These tables contain the appropriate line from the bulk_annotations attachment you just created for that particular image.


  8. Go back to your terminal. Download the idr0021-experimentA-bulkmap-config.yml file . Alternatively, in case you are working with the siRNAi-HeLa Dataset, download simple-annotation-bulkmap-config.yml.

  9. If you are working with the IDR data, open the downloaded idr0021-experimentA-bulkmap-config.yml file in a text editor and delete the Advanced options... section. Save the file and run:

    $ omero metadata populate --context bulkmap --cfg local/path/to/idr0021-experimentA-bulkmap-config.yml --batch 100 Project:$ID
  10. If you work with the siRNAi-HeLa data, open the downloaded simple-annotation-bulkmap-config.yml and study the comments in the file itself, which will give you hints about how to manipulate the file to fit your particular needs with respect to the resulting Key-Value pairs layout. Make your changes (no need to change anything if you do not want), save the file locally and run:

    $ omero metadata populate --context bulkmap --cfg local/path/to/simple-annotation-bulkmap-config.yml --batch 100 Dataset:$ID
  11. Go to your browser and in OMERO.web, select the images in the Project or Dataset you targeted and verify that they have now new Key-Value pairs displayed in the right-hand pane.


  12. Still in OMERO.web, create a new Dataset and copy into it four images, preferably images which have neither OMERO.tables on them nor any Key-Value pairs attached. Note the name of the images you are copying in.


  13. Go to the and find the section named populate. Study the project.csv. You can either take the project.csv file from there, or more conveniently, you can download directly its copy four-images.csv. Open the CSV file in Excel and edit the name of the images in the first column to match the names of the images you copied into your Dataset in the previous step. Also, edit the name of the Dataset in the second column to match the name of your Dataset in OMERO.web. Save the file locally as CSV.

  14. In your OMERO.web, upload the CSV file you just saved and attach it onto the Dataset you created previously.


  15. Select the Dataset you created and attached to it the CSV. Find the script icon image6 above the central pane, expand it and find the Import scripts section. In there, select the Populate metadata script.


  16. Run the script.

  17. Click again onto the Dataset in the left-hand pane to refresh and observe that there is a new Attachment in the right hand pane under “Attachments” harmonica.


  18. Click on single images inside the Dataset and observe that in the “Tables” harmonica in the right-hand pane there are new values coming originally from your edited CSV.