Skip to main content

A Nion Swift package to simulate a STEM microscope, scanner, and cameras.

Project description

Nion Swift STEM Microscope Simulator

The Nion Swift STEM Microscope Simulator Library (used in Nion Swift)

A STEM microscope simulator for use with Nion Swift. Used for debugging Nion Swift acquisition and developing acquisition tools, techniques, and apps.

tests

Travis CI build status (Linux)

package

Latest PyPI version

Introduction

Microscopes come in many varieties such as light/optical microscopes, electron microscopes, scanning probe microscopes. Within each of those broad categories are many sub-categories such as fluorescence and super resolution optical microscopes, and transmission or scanning electron microscopes.

This simulator is intended to provide a platform and specific simulations for a variety of microscopes.

Currently, however, it is primarily focused on scanning transmission electron microscopy (STEM). A STEM instrument produces electrons which are transmitted through a sample, scattering, deflecting, or changing energy in the process, and then digitized in a detector.

A STEM instrument will include an electron source, electromagnetic lenses to form and control the electron beam, a scanning system to control the lenses, and multiple cameras to detect the resulting electrons. A typical configuration of detectors would include multiple annular dark field detectors, high-angle HAADF, medium-angle MAADF; a Ronchigram detector (an image of the convergent beam diffraction pattern, useful and important in aberration corrected instruments); often an EELS detector (electron energy loss spectrum) to measure energy loss; and video cameras for alignment and adjustment. Other detectors such as optical or x-ray detectors are also sometimes present.

In transmission electron microscopy, as an electron travels through a sample, it may interact with electrons or nuclei, scattering in the process. An ideal sample for transmission electron microscopy will be thin, to limit the number of scattering events. As it scatters, it may transfer some of its energy to the sample (inelastic) or simply be deflected (elastic). When it transfers energy to the sample (inelastic), the amount of energy that the electron loses will be characteristic (on average) of the atom or compound with which it interacts. This may show up in EELS data as phonons (interaction with nuclei), plasmons (interaction with surfaces), or edges (interactions with electrons of specific energies).

Features

The STEM microscope simulator can simulate a HAADF detector within a beam scan, a Ronchigram with lens aberrations, and a 2D EELS detector that can be summed in the zero dimension to produce a 1D EELS spectrum.

The EELS detector produces EELS spectra unique to each beam position within the simulated sample. The Ronchigram is not dependent on beam position.

The simulated sample can be basic elements/vacuum arranged in rectangular regions; or an amorphous sample.

The scan and Ronchigram or EELS detector can be combined to do spectrum imaging.

The simulator has been used to develop many acquisition algorithms and even some tuning and alignment algorithms for use on the Nion STEM instrument.

Acquisition Modes

There are several regularly used modes of acquisition on a STEM instrument.

To begin, an imaging mode formed by continuously scanning the beam in a rectangular pattern with a HAADF detector is often the mode used to find the beam and make rough adjustments. At each point of the scan, a single value is read from the HAADF detector and those values are assembled into an image. The scan size can be adjusted by changing the field of view (FOV), expressed in nm; and also rotated to align with a sample. The pixel time can also be adjusted to account for a weaker or stronger signal, with the tradeoff being the speed of imaging.

Once the beam is centered, the Ronchigram imaging mode is used to focus and correct aberrations in the electromagnetic lenses. The magnification on the Ronchigram can be adjusted using the defocus value, expressed in nm. When the beam has no defocus (0nm), it would appear as an image with little or no contrast, depending on the sample and other alignments. When the beam has a slight defocus (500nm), it forms an image of the sample and can be used for imaging. However, lens aberrations may contribute distortions to the resulting image. This simulator provides simulator aberrations up to 5th order. The default values produce a perfectly aligned instrument; but explicitly introducing aberrations can be useful for learning about aberrations or testing alignment/tuning software.

In a STEM instrument with a spectrometer, an electron energy loss spectrum (EELS) can also be observed. The spectrometer is a special set of electromagnetic lenses that bend the electrons in such a way that the energy of the electron is dispersed in a spatial axis, forming an image where the vertical axis is a non-dimensioned spread of the beam and the horizontal axis is an energy loss for the electron. The energy loss will be characteristic (statistically) of the atom or compound through which the electron travelled.

The simulator provides a 2D EELS spectrum that is calculated based on the beam position (also known as the probe position) on the sample. The 2D EELS spectrum can be summed along the vertical axis to produce a 1D EELS spectrum that can be displayed as a line plot. The probe position can be adjusted by starting a scan and then stopping it, enabling the beam position graphic, and adjusting it.

The scan and EELS spectrum can be combined into a spectrum image. The beam is scanned and at each beam position, an EELS spectrum is acquired. The results are assembled in a data item 2D x 1D where the first two dimensions represent the scan position and the last dimension represents the electron energy loss at that position. Since each EELS spectrum is dependent on the sample at the corresponding beam position, the spectrum image can be used to do things like elemental mapping, where the concentration of one or more elements are formed into images where the intensity represents their relative concentration within the sample.

  • 4D STEM: Scanning with Ronchigram detector, combined into 2D x 2D data item

  • 4D STEM virtual detectors: Scanning with Ronchigram detector, summed within areas to form one or more 2D images

  • Spectrum imaging, short exposure, aligned and summed

Samples

The simulator provides two types of samples: a crystal and an amorphous sample.

Tutorial

Starting with a new or existing project, create a new workspace (Workspace > New Workspace…) or clear the existing one. Then split the workspace into a 2x2 layout (Workspace > Display Panel Split > Split 2x2).

In the top left panel, right click and choose uSim Scan (HAADF). Press Scan at the lower left of that panel. Then press Stop.

Open the scan control panel if it is not already open (Window > uSim Scan Scan Control). In the scan control panel, click Positioned. This will put a probe marker on the scan image. This will only appear when the scan is stopped. You can drag it around.

In the top right panel, right click and choose uSim EELS Camera. This shows the 2D EELS detector. Make it display the 1D EELS by clicking the checkbox at the bottom of the panel. Then pres Play at the lower left of that panel.

Now drag the probe marker on the scan and the EELS data will change according to the probe position. Press Pause on the EELS data when finished.

Open the spectrum imaging panel if it is not already ope (Window > Spectrum Imaging / 4d Scan Acquisition). Choose uSim EELS Camera at the top left of that panel and choose Spectra as the acquisition type. Change the scan width to 24 and the camera exposure time to 50ms. Then click Acquire. This will acquire a spectrum image of the scan area and the EELS. You should see the scan from top to bottom and the resulting spectrum image. At the end, you will see the captured HAADF image.

Once the acquisition is finished, right click on the HAADF image which should be in the bottom right panel. Choose Delete Data Item “Spectrum Image (HAADF)”. We will not be using that data in this tutorial.

Click on the panel with the spectrum image named “Spectrum Image (uSim EELS Camera)”. Then press “p”. This will attach a pick region to the spectrum image and display the resulting sum of the spectra within the pick region in a new line plot display. You can drag the display interval to change the energy range displayed on the spectrum image. You can also zoom and otherwise examine the data in the EELS spectra.

Next right click on the spectrum image and choose Delete Data Item “Spectrum Image (uSim EELS Camera)”. This will delete the spectrum image and the associated pick line plot.

Now right click on an empty display panel and choose uSim Ronchigram Camera. Press Play.

Next open the simulator control panel Window > Simulator Control. In the simulator panel, you can change various parameters that will affect the Ronchigram. Try changing C23 X to 500 nm.

TODO:

  • 4D STEM (Spectrum Imaging using Ronchigram and Images)

  • Change sample type (top of Simulator Control)

  • Change EELS dispersion (set eV/ch to 10 in Simulator Control)

  • Find an edge in EELS data (look in 1200 - 1300 eV range)

  • Background removal (if EELS analysis installed)

  • Scan and subscan, rotation

  • Spectrum imaging with drift correction

  • Multiple shift EELS acquire

  • Multi Acquire

  • Multi Acquire SI

  • 4D STEM with masking

  • Line scan

More Information

Changelog (nionswift-usim)

5.1.1 (2023-10-23)

  • Minor updates for Python 3.12 and typing compatibility.

5.1.0 (2023-09-14)

  • Updates for nionswift-instrumentation 22.0 (sequence buffer).

  • Fix issue with data not being updated during synchronized scan.

  • Add Python 3.11 support. Drop 3.8.

0.5.0 (2022-12-07)

  • Updates for nionswift-instrumentation 0.21.

  • Register scan module (scan device and settings) rather than scan device directly.

0.4.5 (2022-10-03)

  • Add reference setting index and capability to remove controls.

0.4.4 (2022-09-13)

  • Minor bugs for testing in other packages.

0.4.3 (2022-05-28)

  • Add simulated CTS sample.

  • Fix issues in instrument panel.

  • Implement new axis manager.

0.4.2 (2022-02-18)

  • Improve simulated synchronization behavior for future work.

  • Fix minor issues with camera length.

0.4.1 (2021-12-13)

  • Change camera device to implement camera 3 (no prepare methods).

0.4.0 (2021-11-21)

  • Updates for nionswift-instrumentation 0.20 and nionswift 0.16.

  • Add support for axis descriptors.

  • Add support for camera masks.

  • Drop support for Python 3.7.

0.3.0 (2020-08-31)

  • Add support for partial synchronized acquisition.

  • Fix handling of probe position in sub-scans.

  • Add aperture that can be moved and “distorted” (i.e. dipole and quadrupole effect simulation).

  • Add functions to ‘Instrument’ that facilitate adding new inputs to existing controls.

  • Allow input weights for controls to be controls in addition to float.

  • Add option to attach a python expression as control input (only one expression per control can be set, but it can be arbitrarily complex, as long as it can be evaluated by ‘eval’).

  • Changed meaning of convergence angle to reflect its real meaning (in the simulator it only controls the size of the aperture on the Ronchigram camera, the effect on the scan is not simulated yet).

  • Add ‘Variable’ class to InstrumentDevice. ‘Variables’ differ from ‘Controls’ in that they do not have a local value.

0.2.1 (2019-11-27)

  • Minor changes to be compatible with nionswift-instrumentation.

  • Improve ‘inform’ functionality on Ronchigram controls.

0.2.0 (2019-06-27)

  • Fix some simulated aberration calculations.

  • Add option for flake sample (same as previous version) or amorphous sample.

  • Allow adding new controls to existing instrument instance.

  • Add support for 2D controls and AxisManager.

0.1.7 (2019-04-29)

  • Ensure noise gets added as float32 to ensure good display performance.

0.1.6 (2019-02-27)

  • Fix scaling of spectra to be consistent with beam current, sample thickness, and energy offset.

  • Improve performance for cameras.

  • Add support for ZLP tare control / inform.

  • Add controls used in 4D acquisition.

  • Change Ronchigram units to radians.

  • Improve/fix reliability with camera running faster than scan.

Contributors: @Brow71189 @cmeyer

0.1.5 (2018-10-04)

  • Fix issue with scan content position (introduced with rotated scans).

0.1.4 (2018-10-03)

  • Fix minor issue with EELS data.

0.1.3 (2018-10-03)

  • Update support for API.

  • Add support for rotated scans.

0.1.2 (2018-06-25)

  • Specify lower priorities for all simulator devices.

  • Add persistence of camera settings.

  • Restructure as a camera module to be parallel with physical camera modules.

  • Switch to using calibration controls instead of intrinsic calibrations.

0.1.1 (2018-05-13)

  • Initial version online.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nionswift-usim-5.1.1.tar.gz (65.0 kB view details)

Uploaded Source

Built Distribution

nionswift_usim-5.1.1-py3-none-any.whl (65.7 kB view details)

Uploaded Python 3

File details

Details for the file nionswift-usim-5.1.1.tar.gz.

File metadata

  • Download URL: nionswift-usim-5.1.1.tar.gz
  • Upload date:
  • Size: 65.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for nionswift-usim-5.1.1.tar.gz
Algorithm Hash digest
SHA256 04bb8537925ce3558186f47cd524b7254750ace1b5ba13281dc55be2ff7e5d9f
MD5 ce94127268d228d885f2d5267b831078
BLAKE2b-256 b13de839f15fcb810263f9591de7882ad5cfddd2dfbac18a4988564878a007f8

See more details on using hashes here.

File details

Details for the file nionswift_usim-5.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nionswift_usim-5.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12dfb07474ed9343c02d33ad27520e351437208a05995b3b6ad5fd0528e1ab52
MD5 15f984dbf605e5f7d87da9d600a9cc09
BLAKE2b-256 b57b456bbddc630a345f930e7d46710db750871b8022408e226178bf71607499

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page