Some thoughts about how to improve the DM3/DM4 file support
Posted: 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
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
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 :
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 :
Which gives :
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 :
Then :
Which gives a cleaner picture :
------------> More on scaling
Even if Omero seems to fully support scaling from DM3/DM4, this package can be used to get it back :
Proof here :
------------> 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 :
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
---> 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 :
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 :
------------> 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()
------------> 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