IDR / idr.openmicroscopy.org

Source for the IDR static website.
https://idr.openmicroscopy.org/about
Creative Commons Attribution 4.0 International
4 stars 16 forks source link

List image magnification in IDR API #149

Open gwaybio opened 3 years ago

gwaybio commented 3 years ago

Thanks for your helpful pointers in #147, I have another API-related question :)

Is there a way for me to pull microscopy image magnification from the API?

I imagine this info would have been in the image annotations endpoint (see example below), but I am not readily seeing it. I also did not see this mentioned in the API docs. Maybe magnification exists in another API section?

Thanks! Greg

MAP_URL = f"https://idr.openmicroscopy.org/webclient/api/annotations/?type=map&image={rand_image}"

annotations = session.get(MAP_URL).json()["annotations"]

print(annotations)

[{'id': 6625160,
  'ns': 'openmicroscopy.org/mapr/gene',
  'description': None,
  'owner': {'id': 2},
  'date': '2016-12-13T23:05:19+00:00',
  'permissions': {'canDelete': False,
   'canAnnotate': False,
   'canLink': False,
   'canEdit': False},
  'link': {'id': 22801231,
   'owner': {'id': 2},
   'parent': {'id': 14529,
    'class': 'ImageI',
    'name': 'DTT p1 [Well 77, Field 1 (Spot 229)]'},
   'date': '2016-12-13T23:05:19+00:00',
   'permissions': {'canDelete': False,
    'canAnnotate': False,
    'canLink': False,
    'canEdit': False}},
  'class': 'MapAnnotationI',
  'values': [['Gene Identifier', 'YNL106C'],
   ['Gene Identifier URL', 'https://www.yeastgenome.org/locus/YNL106C'],
   ['Gene Symbol', 'INP52']]},
 {'id': 6625787,
  'ns': 'openmicroscopy.org/mapr/organism',
  'description': None,
  'owner': {'id': 2},
  'date': '2016-12-13T23:06:04+00:00',
  'permissions': {'canDelete': False,
   'canAnnotate': False,
   'canLink': False,
   'canEdit': False},
  'link': {'id': 22834937,
   'owner': {'id': 2},
   'parent': {'id': 14529,
    'class': 'ImageI',
    'name': 'DTT p1 [Well 77, Field 1 (Spot 229)]'},
   'date': '2016-12-13T23:06:35+00:00',
   'permissions': {'canDelete': False,
    'canAnnotate': False,
    'canLink': False,
    'canEdit': False}},
  'class': 'MapAnnotationI',
  'values': [['Organism', 'Saccharomyces cerevisiae']]},
 {'id': 6626243,
  'ns': 'openmicroscopy.org/mapr/phenotype',
  'description': None,
  'owner': {'id': 2},
  'date': '2016-12-13T23:09:03+00:00',
  'permissions': {'canDelete': False,
   'canAnnotate': False,
   'canLink': False,
   'canEdit': False},
  'link': {'id': 22918669,
   'owner': {'id': 2},
   'parent': {'id': 14529,
    'class': 'ImageI',
    'name': 'DTT p1 [Well 77, Field 1 (Spot 229)]'},
   'date': '2016-12-13T23:09:04+00:00',
   'permissions': {'canDelete': False,
    'canAnnotate': False,
    'canLink': False,
    'canEdit': False}},
  'class': 'MapAnnotationI',
  'values': [['Phenotype', 'GFP localization: punctate'],
   ['Phenotype Term Name', 'protein localized in punctate foci phenotype'],
   ['Phenotype Term Accession', 'CMPO_0000400'],
   ['Phenotype Term Accession URL',
    'http://www.ebi.ac.uk/cmpo/CMPO_0000400']]},
 {'id': 6631107,
  'ns': 'openmicroscopy.org/omero/bulk_annotations',
  'description': None,
  'owner': {'id': 2},
  'date': '2016-12-13T23:14:34+00:00',
  'permissions': {'canDelete': False,
   'canAnnotate': False,
   'canLink': False,
   'canEdit': False},
  'link': {'id': 23067151,
   'owner': {'id': 2},
   'parent': {'id': 14529,
    'class': 'ImageI',
    'name': 'DTT p1 [Well 77, Field 1 (Spot 229)]'},
   'date': '2016-12-13T23:14:34+00:00',
   'permissions': {'canDelete': False,
    'canAnnotate': False,
    'canLink': False,
    'canEdit': False}},
  'class': 'MapAnnotationI',
  'values': [['Strain', 'Y6545'],
   ['Environmental Stress', 'dithiothreitol'],
   ['Channels',
    'H2B-mCherry:cytosol;GFP:tagged protein;bright field/transmitted:cell'],
   ['Has Phenotype', 'yes'],
   ['Phenotype Annotation Level', 'experimental condition and gene']]}]
will-moore commented 3 years ago

Hi Greg, I'm afraid this data isn't available via any JSON api currently. The webclient code that loads Image acquisition metadata is some of the older code there, and all the html is rendered on the server. E.g. https://idr.openmicroscopy.org/webclient/metadata_acquisition/image/11514301/

The code that loads the data from OMERO and renders that page is at https://github.com/ome/omero-web/blob/394e75170f5d6e9997edf12f6906c489186d5f22/omeroweb/webclient/views.py#L1834 It creates a context dict, but unfortunately we can't simply dump that to JSON as it includes a bunch of objects (Django forms etc) that aren't JSON serializable.

But please create an issue on omero-web repo for supporting acquisition metadata as JSON. Regards, Will.

will-moore commented 3 years ago

It occurred to me that another way you could get the data from IDR, while you're waiting on https://github.com/ome/omero-web/pull/336 is to use the OMERO python api (see https://docs.openmicroscopy.org/omero/5.6.3/developers/Python.html) with the code samples I added to that PR. If that seems viable for you I can give you some more pointers as the PR is unlikely to be available on IDR for a while.