Scripting Resources for DigitalMicrograph™

banner

Dave Mitchell's DigitalMicrograph™ Scripting Website

Home | Scripts | Examples | Functions | Recent Updates | Tutorials | Resources | Publications | Consulting | Projects | Contact & Bio |PyJEM| Search

 

EELS Display Component Spectra
Function
Extracts and displays each slice in a composite EELS spectrum as stand-alone spectra.
Version
version:150912, v1.1
Author
D. R. G. Mitchell
Acknowledgements
-
Comments
Although this script is billed as a EELS script - it should work on any intensity profile, EDS spectrum etc. These frequently consist of overlaid spectra and in the case of EELS, background fits and extracted edges. This script will extract all such slices present in the front-most spectrum and display them as stand-alone spectra.

 

System Requirements
This script should be compatible with all recent versions of DigitalMicrograph.
Known Issues
-
Supported
Yes
Included Files
Main script.
Source Code

// Script to extract and display overlaid spectra. For example an EELS spectrum with a

// background fitted contains the spectrum, the background and the extracted edge.

// Running this script with such a spectrum front-most would display the three component

// spectra as individual spectra.

 

// D. R. G. Mitchell, adminnospam@dmscripting.com (remove the nospam to make this work)

// version:20150912, v1.1, September 2015, www.dmscripting.com

 

// Source the front-most image and check that it is a 1D spectrum

 

number nodocs=countdocumentwindowsoftype(5)

if(nodocs<1)

{

showalert("Ensure an EELS Spectrum is shown front-most.",2)

exit(0)

}

 

 

image front:=getfrontimage()

number xsize, ysize

getsize(front, xsize, ysize)

if(ysize>1)

{

showalert("Ensure an EELS spectrum is shown front-most.",2)

exit(0)

}

 

 

// Count the number of slices in the image and get some info

 

number i, noslices, found

imagedisplay imgdisp=front.imagegetimagedisplay(0)

noslices=imgdisp.imagedisplaycountslices()

string imgname=getname(front)

taggroup sourcetags=front.imagegettaggroup()

 

 

// Loop through the slices in the spectrum, displaying each slice as a stand-alone spectrum

 

 

for(i=0; i<noslices; i++)

{

// Get the slice

object sliceid=imgdisp.imagedisplaygetsliceidbyindex(i)

string slicename=imgdisp.imagedisplaygetslicelabelbyid(sliceid)

 

 

// Extract it as an image and display it

image slice:=imageclone(front{i})// clone the actual slice to pick up all the image calibrations, tags etc

showimage(slice)

 

// label and display the component spectrum

setname(slice, imgname+" ("+slicename+")")

documentwindow docwin=getdocumentwindow(0)

docwin.windowsetframeposition(found*30, found*30)

imagecopycalibrationfrom(slice, front)

found=found+1

}