Search code examples
tagscopydm-script

How can I extract EELS spectra from a Spectrum Image?


I have used the following script to extract an EELS spectrum from a 3D spectrum-image.
(This script was published answering a similar question.)

    number px = 5
    number py = 3
    image SIblock := GetFrontImage()
    number sx, sy, sz 
    Get3DSize( SIblock, sx, sy, sz ) 
    image spec := Slice1( SIblock, px,py,0,  2,sz,1 ) 
    image specCopy := ImageClone( spec ) 
    ShowImage( specCopy )

However, when I try to analyse the spectrum (for instance with EELS Quantification), I obtain the following result:

No valid EELS data front-most

I assume that I have not properly extracted the metadata.

What am I doing wrong? Thank you in advance.


Solution

  • When you do an ImageClone() you copy all tags and calibrations. In particular, you copy the Meta Data info which tells DM that the data is a Spectrum Image

    enter image description here

    However, the extracted spectrum is no longer an SI, it is a spectrum. You therefore need to change this tag (before the image is displayed).

    enter image description here

    You can do this, with a little adjustement of the script:

    number px = 5
    number py = 3
    image SIblock := GetFrontImage()
    number sx, sy, sz 
    Get3DSize( SIblock, sx, sy, sz ) 
    image specCopy := SIblock.Slice1( px,py,0,  2,sz,1 ).ImageClone() 
    specCopy.ImageGetTagGroup().TagGroupSetTagAsString( "Meta Data:Format", "Spectrum" )   
    ShowImage( specCopy )