hyperspy / rosettasciio

Python library for reading and writing scientific data format
https://hyperspy.org/rosettasciio
GNU General Public License v3.0
44 stars 26 forks source link

EDS map from recent .emd file: Element selection missing from the metadata #273

Closed OliDG closed 1 month ago

OliDG commented 1 month ago

Describe the bug

Dear developpers,

the EDS element selection is visible in the original metadata but not loaded to the metadata.Sample information. (Former .emd format seems to load the list of element correctly, exemples below)

To Reproduce

Steps to reproduce the behavior:

s = hs.load(file)
s
Out[194]: 
[<EDSTEMSpectrum, title: EDS, dimensions: (|4096)>,
 <EDSTEMSpectrum, title: EDS, dimensions: (|4096)>,
   [...]
 <Signal2D, title: Ti, dimensions: (|308, 308)>,
 <EDSTEMSpectrum, title: EDS, dimensions: (308, 308|4096)>]
s[-1].original_metadata
EDSSpectrumQuantificationSettings
│   │   ├── 0e3648a4c07a47fd9616289dbe0036f6
│   │   │   ├── absorptionCorrection
│   │   │   ├── backgroundCorrection = /SharedProperties/BackgroundCorrection/107c75affaf84aac9a1edbf2f615a3a9
│   │   │   ├── backgroundWindows = /SharedProperties/BackgroundWindows/e7a2a4876cbd4ddd87628410bef92f51
│   │   │   ├── elementProperties <list>
│   │   │   ├── elementSelection = [22, 23, 24, 29, 31, 41]     <------------
│   │   │   ├── ionizationCrossSectionModel = BrownPowell
s[-1].metadata
Out[193]: 
├── Acquisition_instrument
[...]
├── General
│   ├── FileIO
│   │   └── 0
│   │       ├── hyperspy_version = 2.0.1
│   │       ├── io_plugin = rsciio.emd
│   │       ├── operation = load
│   │       └── timestamp = 2024-06-11T11:55:48.578441+02:00
│   ├── date = 2024-05-28
│   ├── original_filename = 1401_KEM-H1_SC-Nb16-1_Ex-situ_SI_Diffraction_Nano_776_nm_130_kx.emd
│   ├── time = 14:01:12
│   ├── time_zone = Västeuropa, sommartid
│   └── title = EDS
└── Signal
    └── signal_type = EDS_TEM

Expected behavior

List of elements loaded under "s[-1].metadata.Sample.elements" Here is the same using an older .emd file.

Acquisition_instrument
[...]
├── General
│   ├── FileIO
│   │   └── 0
│   │       ├── hyperspy_version = 2.0.1
│   │       ├── io_plugin = rsciio.emd
│   │       ├── operation = load
│   │       └── timestamp = 2024-06-11T12:12:36.134231+02:00
│   ├── date = 2023-08-08
│   ├── original_filename = 1041 TMV-C8_posC_ SI Diffraction Nano HAADF-DF4-DF2-BF 550 nm.emd
│   ├── time = 10:41:02
│   ├── time_zone = Västeuropa, sommartid
│   └── title = EDS
├── Sample                                                                  <------------
│   └── elements = ['N', 'O', 'Al', 'Si', 'Cu', 'Zr']                                  <------------
└── Signal
    └── signal_type = EDS_TEM

Python environement:

Additional context

Add any other context about the problem here. If necessary, add screenshots to help explain your problem.

ericpre commented 1 month ago

Is it from a spectrum, a spectrum image or both? Do you have a file to share?

OliDG commented 1 month ago

Both, the individual segment spectra (s[0:4]) sand the spectrum image (s[-1]) has no category 'metadata.Sample', here is a typical dataset from the updated Velox (uploaded to a dropbox).

https://uppsala.box.com/s/rsxinjb9eq6zaniftzaj1eeq6fbfmrrl

\Olivier

jlaehne commented 1 month ago

@OliDG it should be fixed in the development branch now.

OliDG commented 1 month ago

@ericpre @jlaehne Thanks, I have tested it and it mostly works. There is an error generated (maybe here previously?) when no elements were selected for quantification before saving the .emd file from Velox ("elementSelection" key doesn't exist then).

ERROR | Hyperspy | If this file format is supported, please report this error to the HyperSpy developers. (hyperspy.io:600)
caught <class 'AttributeError'>: 'DictionaryTreeBrowser' object has no attribute 'elementSelection'

\Olivier