Skip to content

SpectrumImage

icbicket edited this page Mar 21, 2017 · 1 revision

A spectrum image (SI) is a 3D dataset, with subclasses of either electron energy loss spectroscopy (EELS) or cathodoluminescence (CL) spectrum images. The SI has two spatial dimensions and one energy/wavelength dimension. The class SpectrumImage can be initialized as is, or as a CL spectrum image or EELS spectrum image; this affects what functions are available to the user and how it will be plotted.

Syntax

SpectrumImage(SI, spectrum_units, calibration=0)

Input:

Required:

  • SI: 3D numpy array
  • spectrum_units: Units of the spectrum axis, this will be included in plot labels
    • 'eV' for EELS
    • 'nm' for CL

Optional:

  • calibration: calibration of the spatial dimensions (in meter/pixel). Used for plotting the image with a scalebar. Default is 0; a calibration value of 0 means no calibration is set and no scalebar can be displayed.

CLSpectrumImage

A subclass of SpectrumImage specifically made for CL data.

Syntax

CLSpectrumImage(SI, WavelengthRange, spectrum_units='nm', calibration=0)

Input:

Required:

  • SI: 3D numpy array
  • WavelengthRange: the range along the spectrum axis

Optional:

  • spectrum_units: units of the spectrum, this keyword is used in the plot labels, default is 'nm'
  • calibration: calibration of the spatial dimensions (in meter/pixel). Used for plotting the image with a scalebar. Default is 0; a calibration value of 0 means no calibration is set and no scalebar can be displayed.

Methods:

ExtractSpectrum

Function returns the averaged spectrum underneath an applied mask as a CLSpectrum object.

Input:

  • mask3D: a 3D mask with the same shape as the SI data to apply to the SI.

SpikeRemoval

Function identifies and removes spikes (eg, from cosmic rays) in the image, using a 3D median filter around the identified spike pixels to provide a new value.

Input:

  • threshold: defines the maximum allowed gradient between neighbouring pixels before a spike is identified.

Example Usage

Import SpectrumImage, set the spatial calibration to 20nm/pixel, initialize SpectrumImage object with 3D array data and wavelength range (wavelengths)

import SpectrumImage
calibration = 20e-9
SI = SpectrumImage.CLSpectrumImage(data, wavelengths, calibration=calibration)

EELSSpectrumImage

A subclass of SpectrumImage specifically made for EELS data

Syntax

EELSSpectrumImage(SI, dispersion=0.005, spectrum_units='eV', calibration=0)

Input:

Required:

  • SI: 3D numpy array

Optional:

  • dispersion: the dispersion/channel width in the energy axis of the spectrum, default is 0.005
  • spectrum_units: units along the energy axis, default is 'eV'. Used in the plot labels
  • calibration: calibration of the spatial dimensions (in meter/pixel). Used for plotting the image with a scalebar. Default is 0; a calibration value of 0 means no calibration is set and no scalebar can be displayed.

Methods:**

FindZLP

Uses the mode of the maxima of the spectra to identify the zero loss peak (ZLP) (currently assumes spectrum contains a ZLP). Returns the array index of the ZLP.

Input:

Required:

  • a numpy array that represents the data

ExtractSpectrum*

Function returns the averaged spectrum underneath an applied mask as a CLSpectrum object.

Input:

Required:

  • mask3D: a 3D mask with the same shape as the SI data to apply to the SI.

Threshold

Masks out pixels where the zero loss peak is less than a given value (eg to eliminate noisy pixels when normalizing). Modifies the data of this class in place.

Input:

Required:

  • threshold: the minimum allowed value of the ZLP before it is masked out

RLDeconvolution

Function to apply the Richardson-Lucy deconvolution method to the spectrum image. Makes use of multithreading to utilize all available CPUs in parallel. Pads out the point spread function (PSF) to give the same number of channels on each side of the ZLP - this reduces the artifacts which show up during deconvolution.

Input:

Required:

  • RLiterations: the number of iterations of the algorithm to perform. Suggested is between 5-20, depending on the dataset and noise levels.
  • PSF: the point spread function of the system, with which to deconvolve the dataset, should be an EELSSpectrum object.

Optional:

  • threads: the number of threads to run in parallel during calculation (approximately equal to the number of CPUs to be used). Default is the maximum number of CPUs available on the computer being used.
  • PSF_pad: the value with which to pad out the PSF. Default is 0.

Example Usage

Import SpectrumImage, set the dispersion to 10 meV, set the spatial calibration to 5nm/pixel, initialize SpectrumImage object with 3D array data.

import SpectrumImage
dispersion = 0.01
calibration = 5e-9
SI = SpectrumImage.EELSSpectrumImage(data, dispersion=dispersion, calibration=calibration)

Clone this wiki locally