[ome-devel] Import from json using Python
William Moore (Staff)
W.Moore at dundee.ac.uk
Thu Aug 30 14:27:59 BST 2018
Hi Josh (Titlow)
cc’ing ome-devel since this could be of general interest.
Creating OMERO.figures directly in Python is something we’ve played with a little, but never
documented as it’s a bit experimental. There’s no formal spec for a figure JSON or what
is a ‘valid’ file. There have been some breaking changes to the format as you can see from the
One issue is that the imgData JSON that OMERO.figure uses as the basis for each panel of the figure
is generated by webgateway imageMarshal() at https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroWeb/omeroweb/webgateway/marshal.py#L90
and the web gateway code is not always available where you’re running Python scripts.
However, if you’ve already generated ‘imgData’ JSON (e.g. https://omero.lifesci.dundee.ac.uk/webclient/imgData/4154018/ )
for your images, then it shouldn’t be too hard to turn that into Figure JSON.
The mapping between imgData JSON and each panel of the figure happens at
And there are other attributes of the Figure itself at
Probably the easiest way to see how this goes together is to File > Export as JSON to get the JSON for your current figure.
The "Import from JSON” feature doesn’t save anything to the server until you hit Save.
You can create a file and file annotation of the correct namespace directly in Python.
For example, see create_figure_file() at https://github.com/ome/training-scripts/blob/master/practical/python/server/simple_frap_with_figure.py#L99
This is a server-side Python script that is doing some simple FRAP analysis and then creating a Figure to show the result.
(screenshot at https://github.com/ome/training-scripts/pull/32#issuecomment-413571405)
Here, we’re not using webgateway imageMarshal() since we don’t actually need all of it, and I’ve copied over the channelMarshal
Hope that helps,
We're writing Python code to generate OMERO.Figures from json files en masse.
Can you please recommend a way to do this?
It looks like the 'Import from json' command will work if we could call that function directly. But I can't find it in the Figure code...
We have generated json files for all of the images for which we want to build figures. Now we want to programmatically generate the Figures and store them in OMERO.
Thanks for your help,
The University of Dundee is a registered Scottish Charity, No: SC015096
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ome-devel