<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Josh (Titlow)
<div class=""><br class="">
</div>
<div class=""> cc’ing ome-devel since this could be of general interest.</div>
<div class=""><br class="">
</div>
<div class="">Creating OMERO.figures directly in Python is something we’ve played with a little, but never</div>
<div class="">documented as it’s a bit experimental. There’s no formal spec for a figure JSON or what</div>
<div class="">is a ‘valid’ file. There have been some breaking changes to the format as you can see from the</div>
<div class="">version_transform() <a href="https://github.com/ome/omero-figure/blob/v4.0.0/src/js/models/figure_model.js#L102" class="">https://github.com/ome/omero-figure/blob/v4.0.0/src/js/models/figure_model.js#L102</a>.</div>
<div class=""><br class="">
</div>
<div class="">One issue is that the imgData JSON that OMERO.figure uses as the basis for each panel of the figure</div>
<div class="">is generated by webgateway imageMarshal() at <a href="https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroWeb/omeroweb/webgateway/marshal.py#L90" class="">https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroWeb/omeroweb/webgateway/marshal.py#L90</a></div>
<div class="">and the web gateway code is not always available where you’re running Python scripts.</div>
<div class=""><br class="">
</div>
<div class="">However, if you’ve already generated ‘imgData’ JSON (e.g. <a href="https://omero.lifesci.dundee.ac.uk/webclient/imgData/4154018/" class="">https://omero.lifesci.dundee.ac.uk/webclient/imgData/4154018/</a> )</div>
<div class="">for your images, then it shouldn’t be too hard to turn that into Figure JSON.</div>
<div class=""><br class="">
</div>
<div class="">The mapping between imgData JSON and each panel of the figure happens at </div>
<div class=""><a href="https://github.com/ome/omero-figure/blob/v4.0.0/src/js/models/figure_model.js#L348" class="">https://github.com/ome/omero-figure/blob/v4.0.0/src/js/models/figure_model.js#L348</a></div>
<div class=""><br class="">
</div>
<div class="">And there are other attributes of the Figure itself at</div>
<div class=""><a href="https://github.com/ome/omero-figure/blob/v4.0.0/src/js/models/figure_model.js#L11" class="">https://github.com/ome/omero-figure/blob/v4.0.0/src/js/models/figure_model.js#L11</a></div>
<div class=""><br class="">
</div>
<div class="">Probably the easiest way to see how this goes together is to File > Export as JSON to get the JSON for your current figure.</div>
<div class=""><br class="">
</div>
<div class="">The "Import from JSON” feature doesn’t save anything to the server until you hit Save.</div>
<div class="">You can create a file and file annotation of the correct namespace directly in Python.</div>
<div class=""><br class="">
</div>
<div class="">For example, see <span style="color: rgb(111, 66, 193); font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; orphans: 2; white-space: pre; widows: 2; background-color: rgb(255, 251, 221);" class="">create_figure_file()</span> at <a href="https://github.com/ome/training-scripts/blob/master/practical/python/server/simple_frap_with_figure.py#L99" class="">https://github.com/ome/training-scripts/blob/master/practical/python/server/simple_frap_with_figure.py#L99</a></div>
<div class=""><br class="">
</div>
<div class="">This is a server-side Python script that is doing some simple FRAP analysis and then creating a Figure to show the result.</div>
<div class="">(screenshot at <a href="https://github.com/ome/training-scripts/pull/32#issuecomment-413571405" class="">https://github.com/ome/training-scripts/pull/32#issuecomment-413571405</a>)</div>
<div class=""><br class="">
</div>
<div class="">Here, we’re not using webgateway imageMarshal() since we don’t actually need all of it, and I’ve copied over the channelMarshal</div>
<div class="">from webgateway.</div>
<div class=""><br class="">
</div>
<div class=""> Hope that helps,</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">   Will.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div>
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div class="">We're writing Python code to generate OMERO.Figures from json files en masse. </div>
<div class=""><br class="">
</div>
<div class="">Can you please recommend a way to do this?</div>
<div class=""><br class="">
</div>
<div class="">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...</div>
<div class=""><br class="">
</div>
<div class="">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. <br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Any ideas?</div>
<div class="">Thanks for your help,</div>
<div class="">j</div>
</div>
</blockquote>
</div>
<br class="">
</div>
<br>
<span style="font-size:10pt;">The University of Dundee is a registered Scottish Charity, No: SC015096</span>
</body>
</html>