How to read the energy-axis properly of a dm3-file?

85 views
Skip to first unread message

Johan Persson

unread,
Dec 9, 2013, 6:02:22 AM12/9/13
to hypersp...@googlegroups.com
Dear hyperspy-users,

I have a problem reading my dm3-files into hyperspy - when I do the s.plot() the energy-axis is actually in pixels, rather than in eV. I can of course do an s.calibration(), but I don't quite like it since this brings up a GUI and I want to batch my work. If I use s.data I only get the intensity array, and of course I can make an energy-array myself (knowing the start-value and the dispersion) but I can't see why I should have to. In fact I know that the energy values are in the variable s, since if I save it as a .msa-file with format='xy', it also saves the x-values.

Of course I now have two workarounds to the issue (I can make my own x-array, or I can reload the .msi-file with a csv-reader), but seriously... I must be doing something wrong? There must be a good way to extract the x-values directly from s. Did anyone else find this issue or is it just a problem with the way DM is set up on our scope? Does anyone else have a solution? Is this already solved, maybe I am just bad at googling?

I included a sample dm3-file in case someone wants to try it. O and Fe edges. Note that a plot give pixels for the x-axis, but in a save the x-axis data is stored...

s=load("EELS_spectrum_cumulative_001.dm3")
s.plot()
s.save('sample.msa', format='XY')

When I am at it anyway - can I calibrate without the gui? Changing the x-values of the "s"-data-set by something like s.set_x-axis(min, max) or s.set_x-axis(min, dispersion) would be awesome.

Best regards,
Johan
EELS_spectrum_cumulative_001.dm3

Pierre Burdet

unread,
Dec 9, 2013, 6:47:17 AM12/9/13
to hypersp...@googlegroups.com
Hi Johan,

To answer one of your question, you can access everything link to axes with s.axes_manager

either through a gui s.axes_manager.gui()

or you set the value yourself s.axes_manager[0].scale = 0.1

Francisco de la Peña

unread,
Dec 9, 2013, 7:29:47 AM12/9/13
to hypersp...@googlegroups.com
Johan,

Hyperspy 0.6 does not read correctly the calibration of some dm3 files. This is a known bug that has been fixed in the development version. Upgrading to the version 0.7 once is ready should fix this problem for you. In the meantime you can use Pierre's workaround to manually set the calibration.

Actually, HyperSpy 0.6 reads correctly the dm3 files but it fails to find the information in this case. The calibration information for your file is stored in this attribute:

    >>> s.original_parameters.root.ImageList.Number_1.ImageData.Calibrations
   
    ├── Brightness
    │   ├── Origin = 0.0
    │   ├── Scale = 0.133511349559
    │   └── Units = e-
    ├── Dimension
    │   ├── 0
    │   │   ├── Origin = -2300.0
    │   │   ├── Scale = 0.20000000298
    │   │   └── Units = eV
    │   └── 1
    │       ├── Origin = 0.0
    │       ├── Scale = 1.0
    │       └── Units =
    └── DisplayCalibratedUnits = True


Best wishes,

Francisco


--
You received this message because you are subscribed to the Google Groups "hyperspy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hyperspy-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Johan Persson

unread,
Dec 9, 2013, 8:07:18 AM12/9/13
to hypersp...@googlegroups.com
Thank you Pierre, thank you Francisco!

Awesome feedback. Good to hear that it is fixed for 0.7 . As for the data in the Calibrations attribute... I don't quite understand how the origin can be -2300. But at least the scale and the units are correct, and that is always something!

Since this apparently is solved I don't know if it will help someone in the future... but since I anyway stumbled upon some more information on the way, here it is:
I now have noticed the same issue when opening the file in imageJ. If I open it using the "official" DM3-Reader plugin by Gregory Jefferis[1] I can not get a proper x-axis in the CSI plugin, but if I open it using the CSI_DM3_Reader[2] which is basically the same but slightly modified by Paul Cueva, then I do get a correct x-axis. So it seems to indeed be an issue with the dm3-reading.

Thanks again for the help, and best regards,
Johan

[1] http://rsb.info.nih.gov/ij/plugins/DM3_Reader.html
[2] http://code.google.com/p/cornell-spectrum-imager/wiki/Home

Francisco de la Peña

unread,
Dec 9, 2013, 9:29:22 AM12/9/13
to hypersp...@googlegroups.com
Johan,

Thank you for sharing your findings regarding the dm3 readers. Unfortunately there are not one but many issues with dm3 reading because dm3 is not an open format. Readers exist because the format has been partly reverse engineered, but without the full specifications of the format we can never be sure that our readers will work for all files.

Concerning the origin parameter, its value is correct. You can obtain the offset parameter to calibrate the spectrum in HyperSpy like this: offset = - Scale * Origin = - (-2300) * 0.2 = 460

Best wishes,

Francisco


--

Johan Persson

unread,
Dec 9, 2013, 11:36:54 AM12/9/13
to hypersp...@googlegroups.com
That makes total sense now. Thank you again!

Best regards,
Johan
Reply all
Reply to author
Forward
0 new messages