We're Hiring!

Some thoughts about how to improve the DM3/DM4 file support

General user discussion about using the OMERO platform to its fullest. Please ask new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

There are workflow guides for various OMERO functions on our help site - http://help.openmicroscopy.org

You should find answers to any basic questions about using the clients there.

Some thoughts about how to improve the DM3/DM4 file support

Postby victor.garric » Mon Sep 24, 2018 12:13 pm

Greetings,

---> Informative introduction
I hereby begin this topic on how to improve the DM3/DM4 file support in Omero. Before anything, i want to acknowledge the fact that I'm no Java developper and have no clue about how omero import file and get informations and may be this post will be nonsense. In fact, I'm more a Omero user with somehow Python skills.

---> About the DM3/DM4 in Omero
The state of art of Omero file support on DM3/DM4 is very poor : imported image pictures the poorest metadata acquisition, thumbnails are very dark due to no min/max contrast import : i consider this as a main issue because DigitalMicrograph format is one of the mostly used in the transmission microscopy field.
This issue is mainly due to the fact that DIgitalMicrograph format is proprietary and very few information about it is available. However, I propose here to use "dm3_reader" library (https://bitbucket.org/piraynal/pydm3rea ... .5beta.zip) to complete such weaknesses. As i said before, I have no clue of how the importer work but as the Omero server has a Python engine, i guess it is possible to use such script during the import.

---> Enhances proposition
------------> About the importer
Code: Select all
from matplotlib_scalebar.scalebar import ScaleBar
import matplotlib.pyplot as plt
from scipy.misc import toimage
import dm3_lib as dm3


The three first lines here will only be used for displays in this proposal. However, the last line is the main import of the file. The source code of this python package is available at the adress given before. Please note i am using the 1.5_beta version as it is the only one supporting both DM3 and DM4 (1.2 release only supports DM3)

------------> Getting the main data
Code: Select all
dm3f = dm3.DM3("example.dm4")
keywords={k: v.decode('utf-8') for k, v in dm3f.info.items()}
for item in keywords :
    print (item +':' + keywords[item])


This code imports the DM3/DM4 file and then get the main "keyword" that will be the main metadata. Here is the result of this code :

hv_f:300kV
mag_f:115kx
specimen:3F-HX-FIB
mag:115000.0
name_old:FEI Tecnai Remote
micro:FEI
gms_v:2.32.888.0
device:Orius SC200D 1
hv:300000.0
binning:1
acq_time:14:35:39
acq_date:04/07/2018
mode:IMAGING
gms_v_:2.32.888.0
operator:VG


Here we get voltage, magnification, microscope model, date, time and camera informations.

------------> About imaging
One of the main issue in the DM support is the fact no brightness min nor max value is imported. Here is a code that picture what do you get in Omero importing a DM3/DM4 file :
Code: Select all
bad_picture=toimage(dm3f.imagedata)
bad_picture.show()

Which gives :
Image
Which is, actually, what you get when you import this type of file in Omero.
To improve, a way is to get the min/max value from histogram and implant it in Omero. The limits can be found here :
Code: Select all
cmin,cmax=dm3f.cuts

Then :
Code: Select all
good_picture=toimage(dm3f.imagedata,cmin=cmin,cmax=cmax)
good_picture.show()

Which gives a cleaner picture :
Image

------------> More on scaling
Even if Omero seems to fully support scaling from DM3/DM4, this package can be used to get it back :
Code: Select all
pix_conv=float(dm3f.pxsize[0])
unit=dm3f.pxsize[1].decode('utf-8')

Proof here :
Code: Select all
plt.imshow(good_picture)
scalebar = ScaleBar(pix_conv,unit)
plt.gca().add_artist(scalebar)
plt.show()

Image

------------> More on Metadata
Earlier in this post, we presented how to get basic metadata. Here is a way to get the full metadata from DM3/DM4 files :
Code: Select all
for item in dm3f.tags :
    print (item +':' + dm3f.tags[item])

Which gives an extraordinary long list of data from the file. The result is attached with this post.

---> Final words
This simple coded is a way to improve DM3/DM4 imports in Omero. As it is one of the standards in transmission electron microscopy, it might be of primary interest to go on this direction. You will find attached the source code and the metadata extracted.

Best regards,
Victor
Attachments
all_metadata.zip
Metadata
(4.65 KiB) Downloaded 102 times
omero_example.py.zip
Source code
(1.2 KiB) Downloaded 99 times
victor.garric
 
Posts: 5
Joined: Tue Jun 12, 2018 8:54 am

Re: Some thoughts about how to improve the DM3/DM4 file supp

Postby sbesson » Tue Sep 25, 2018 3:56 pm

Hi Victor,

thanks for the detailed investigation and your contribution. Answering a few high-level questions raised by your thread:

- the reading of Gatan files including all metadata in OMERO is performed by the Bio-Formats library which supports over 150 proprietary file formats via a unified API
- for the Gatan Digital Micrograph format, the Java reader source code is available here
- metadata parsed by Bio-Formats is generally classified in two categories: the OME metadata i.e. everything that can be mapped to the open OME imaging specification and Original Metadata expressed as a list of key/value pairs
- for the rendering settings, the default behavior of the OMERO importer is to do a best effort of computing the absolute minimum and maximum values for the whole image. As your example demonstrates, this does not respect min/max settings that have been stored internally in the file format itself.

As you mentioned, a fundamental issue with the Gatan format like many others is the lack of information about its structure like a format specification. From the open-source perspective, re-using knowledge that has been captured by libraries like pydm3reader is certainly a nice way to improve our support and improve the experience of our users.

To help us assess how much we can improve the metadata parsing in Bio-Formats and OMERO, is the sample file used in your Python script (example.dm4) available publically? If not, could you share it with us at http://qa.openmicroscopy.org.uk/qa/upload/ so that we can compare the output of our parsing with the expectations from the pydm3reader library.

Best,
Sebastien
User avatar
sbesson
Team Member
 
Posts: 421
Joined: Tue Feb 28, 2012 7:20 pm

Re: Some thoughts about how to improve the DM3/DM4 file supp

Postby victor.garric » Tue Sep 25, 2018 7:08 pm

Hi Sebastien,

Thank you for the extremely detailed answer you gave there. 'example.dm4' has been uploaded using the given form, i hope it will help the community to make the raw metadata from Gatan compete with OME specifications and improve the min/max issue. Feel free to contact me if need be. Hoping this will open a way to a better compatibility for the Gatan format in the future.

Best regards,
Victor
victor.garric
 
Posts: 5
Joined: Tue Jun 12, 2018 8:54 am

Re: Some thoughts about how to improve the DM3/DM4 file supp

Postby dgault » Wed Sep 26, 2018 2:01 pm

Hi Victor,

Thank you for sending the sample file. We received it successfully and I have been able to test it with the latest Bio-Formats release and can reproduce the issues you have been seeing. I have created a Trello card on the Bio-Formats inbox to detail and track this issue going forward: https://trello.com/c/kTL4I4HP/282-gatan ... g-metadata

David Gault
User avatar
dgault
Team Member
 
Posts: 208
Joined: Fri Aug 14, 2015 2:56 pm


Return to User Discussion

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron