stemtool.dpc package¶
Submodules¶
stemtool.dpc.atomic_dpc module¶
-
class
stemtool.dpc.atomic_dpc.atomic_dpc(Data_4D, Data_ADF, calib_pm, voltage, aperture)[source]¶ Bases:
objectAtomic Resolution DPC estimation
Parameters: - Data_4D (ndarray) – Four-dimensional dataset where the first two dimensions are real space scanning dimensions, while the last two dimenions are the Fourier space electron diffraction patterns
- Data_ADF (ndarray) – Simultaneously collected two-dimensional ADF-STEM image
- calib_pm (float) – Real space pixel calibration in picometers
- voltage (float) – Microscope accelerating voltage in kV
- aperture (float) – The probe forming condenser aperture in milliradians
Notes
This class function takes in a 4D-STEM image, and a simultaneously collected atomic resolution ADF-STEM image. Based on the accelerating voltage and the condenser aperture this calculates the center of mass (C.O.M.) shifts in the central undiffracted beam. Using the idea that the curl of the beam shift vectors, should be minimized at the correct Fourier rotation angles, this class also corrects for rotation of the collceted 4D-STEM data with respect to the optic axis. Using these, a correct potential accumulation and charge accumulation maps could be built. To prevent errors, we convert everything to SI units first.
Examples
Run as:
>>> DPC = st.dpc.atomic_dpc(Data_4D, DataADF, calibration, voltage, aper)
Once the data is loaded, the ADF-STEM and the BF-STEM images could be visualized as:
>>> DPC.show_ADF_BF()
Then the following call generates the mean CBED image, and if the show_image call is True, shows the mean image.
>>> DPC.get_cbed(show_image = True)
The initial uncorrected DPC shifts are generated as:
>>> DPC.initial_dpc()
The corrected DPC shifts are generated:
>>> DPC.correct_dpc()
The charge map is generated through:
>>> DPC.show_charge()
While the potential map is generated though:
>>> DPC.show_potential()
If a section of the image needs to be observed, to visualize the beam shifts, call the following:
>>> DPC.plot_color_dpc()
References
[1] Müller, K. et al. “Atomic electric fields revealed by a quantum mechanical approach to electron picodiffraction”. Nat. Commun. 5:565303 doi: 10.1038/ncomms6653 (2014) [2] Savitzky, Benjamin H., Lauren A. Hughes, Steven E. Zeltmann, Hamish G. Brown, Shiteng Zhao, Philipp M. Pelz, Edward S. Barnard et al. “py4DSTEM: a software package for multimodal analysis of four-dimensional scanning transmission electron microscopy datasets.” arXiv preprint arXiv:2003.09523 (2020). [3] Ishizuka, Akimitsu, Masaaki Oka, Takehito Seki, Naoya Shibata, and Kazuo Ishizuka. “Boundary-artifact-free determination of potential distribution from differential phase contrast signals.” Microscopy 66, no. 6 (2017): 397-405. Load the user defined values. It also calculates the wavelength based on the accelerating voltage This also loads several SI constants as the following attributes
planck: The Planck’s constant
epsilon0: The dielectric permittivity of free space
e_charge: The charge of an electron in Coulombs
-
correct_dpc(imsize=(30, 17))[source]¶ This corrects for the rotation angle of the pixellated detector with respect to the optic axis. Some pixellated detectors flip the image, and if there is an image flip, it corrects it too. The mechanism of this, we compare the gradient of both the flipped and the unflipped DPC data at multiple rotation angles, and the value that has the highest relative contrast with the ADF-STEM image is taken as 90 degrees from the correct angle.
-
get_cbed(imsize=(15, 15), show_image=False)[source]¶ We calculate the mean CBED pattern by averaging the Fourier data, to get the object attribute cbed. We fit this with a circle function to obtain the object attributes:
beam_x: x-coordinates of the circle
beam_y: y-coordinates of the circle
beam_r: radius of the circle
We use the calculated radius and the known aperture size to get the Fourier space calibration, which is stored as the inverse attribute
-
initial_dpc(imsize=(30, 17), normalize=True)[source]¶ This calculates the initial DPC center of mass shifts by measuring the center of mass of each image in the 4D-STEM dataset, and then comparing that center of mass with the average disk center of the entire dataset.
-
plot_color_dpc(start_frac=0, size_frac=1, skip=2, imsize=(20, 10))[source]¶ Use this to plot the corrected DPC center of mass shifts. If no variables are passed, the arrows are overlaid on the entire image.
Parameters: - start_frac (float, optional) – The starting fraction of the image, where you will cut from to show the overlaid arrows. Default is 0
- stop_frac (float, optional) – The ending fraction of the image, where you will cut from to show the overlaid arrows. Default is 1
-
show_ADF_BF(imsize=(20, 10))[source]¶ The ADF-STEM image is already loaded, while the data_bf attribute is obtained by summing up the 4D-STEM dataset along it’s Fourier dimensions. This is also a great checkpoint to see whether the ADF-STEM and the BF-STEM images are the inverse of each other.
-
show_charge(imsize=(15, 17))[source]¶ We calculate the charge from the corrected DPC center of mass datasets. This is done through Poisson’s equation.
-
show_potential(imsize=(15, 17))[source]¶ Calculate the projected potential from the DPC measurements. This is accomplished by calculating the phase shift iteratively from the normalized center of mass shifts. Normalization means calculating COM shifts in inverse length units and then multiplying them with the electron wavelength to get an electron independent mrad shift, which is used to generate the phase. This phase is proportional to the projected potential for weak phase object materials (with lots of assumptions)
stemtool.dpc.dpc_utils module¶
-
class
stemtool.dpc.atomic_dpc.atomic_dpc(Data_4D, Data_ADF, calib_pm, voltage, aperture)[source] Bases:
objectAtomic Resolution DPC estimation
Parameters: - Data_4D (ndarray) – Four-dimensional dataset where the first two dimensions are real space scanning dimensions, while the last two dimenions are the Fourier space electron diffraction patterns
- Data_ADF (ndarray) – Simultaneously collected two-dimensional ADF-STEM image
- calib_pm (float) – Real space pixel calibration in picometers
- voltage (float) – Microscope accelerating voltage in kV
- aperture (float) – The probe forming condenser aperture in milliradians
Notes
This class function takes in a 4D-STEM image, and a simultaneously collected atomic resolution ADF-STEM image. Based on the accelerating voltage and the condenser aperture this calculates the center of mass (C.O.M.) shifts in the central undiffracted beam. Using the idea that the curl of the beam shift vectors, should be minimized at the correct Fourier rotation angles, this class also corrects for rotation of the collceted 4D-STEM data with respect to the optic axis. Using these, a correct potential accumulation and charge accumulation maps could be built. To prevent errors, we convert everything to SI units first.
Examples
Run as:
>>> DPC = st.dpc.atomic_dpc(Data_4D, DataADF, calibration, voltage, aper)
Once the data is loaded, the ADF-STEM and the BF-STEM images could be visualized as:
>>> DPC.show_ADF_BF()
Then the following call generates the mean CBED image, and if the show_image call is True, shows the mean image.
>>> DPC.get_cbed(show_image = True)
The initial uncorrected DPC shifts are generated as:
>>> DPC.initial_dpc()
The corrected DPC shifts are generated:
>>> DPC.correct_dpc()
The charge map is generated through:
>>> DPC.show_charge()
While the potential map is generated though:
>>> DPC.show_potential()
If a section of the image needs to be observed, to visualize the beam shifts, call the following:
>>> DPC.plot_color_dpc()
References
[1] Müller, K. et al. “Atomic electric fields revealed by a quantum mechanical approach to electron picodiffraction”. Nat. Commun. 5:565303 doi: 10.1038/ncomms6653 (2014) [2] Savitzky, Benjamin H., Lauren A. Hughes, Steven E. Zeltmann, Hamish G. Brown, Shiteng Zhao, Philipp M. Pelz, Edward S. Barnard et al. “py4DSTEM: a software package for multimodal analysis of four-dimensional scanning transmission electron microscopy datasets.” arXiv preprint arXiv:2003.09523 (2020). [3] Ishizuka, Akimitsu, Masaaki Oka, Takehito Seki, Naoya Shibata, and Kazuo Ishizuka. “Boundary-artifact-free determination of potential distribution from differential phase contrast signals.” Microscopy 66, no. 6 (2017): 397-405. Load the user defined values. It also calculates the wavelength based on the accelerating voltage This also loads several SI constants as the following attributes
planck: The Planck’s constant
epsilon0: The dielectric permittivity of free space
e_charge: The charge of an electron in Coulombs
-
correct_dpc(imsize=(30, 17))[source] This corrects for the rotation angle of the pixellated detector with respect to the optic axis. Some pixellated detectors flip the image, and if there is an image flip, it corrects it too. The mechanism of this, we compare the gradient of both the flipped and the unflipped DPC data at multiple rotation angles, and the value that has the highest relative contrast with the ADF-STEM image is taken as 90 degrees from the correct angle.
-
get_cbed(imsize=(15, 15), show_image=False)[source] We calculate the mean CBED pattern by averaging the Fourier data, to get the object attribute cbed. We fit this with a circle function to obtain the object attributes:
beam_x: x-coordinates of the circle
beam_y: y-coordinates of the circle
beam_r: radius of the circle
We use the calculated radius and the known aperture size to get the Fourier space calibration, which is stored as the inverse attribute
-
initial_dpc(imsize=(30, 17), normalize=True)[source] This calculates the initial DPC center of mass shifts by measuring the center of mass of each image in the 4D-STEM dataset, and then comparing that center of mass with the average disk center of the entire dataset.
-
plot_color_dpc(start_frac=0, size_frac=1, skip=2, imsize=(20, 10))[source] Use this to plot the corrected DPC center of mass shifts. If no variables are passed, the arrows are overlaid on the entire image.
Parameters: - start_frac (float, optional) – The starting fraction of the image, where you will cut from to show the overlaid arrows. Default is 0
- stop_frac (float, optional) – The ending fraction of the image, where you will cut from to show the overlaid arrows. Default is 1
-
show_ADF_BF(imsize=(20, 10))[source] The ADF-STEM image is already loaded, while the data_bf attribute is obtained by summing up the 4D-STEM dataset along it’s Fourier dimensions. This is also a great checkpoint to see whether the ADF-STEM and the BF-STEM images are the inverse of each other.
-
show_charge(imsize=(15, 17))[source] We calculate the charge from the corrected DPC center of mass datasets. This is done through Poisson’s equation.
-
show_potential(imsize=(15, 17))[source] Calculate the projected potential from the DPC measurements. This is accomplished by calculating the phase shift iteratively from the normalized center of mass shifts. Normalization means calculating COM shifts in inverse length units and then multiplying them with the electron wavelength to get an electron independent mrad shift, which is used to generate the phase. This phase is proportional to the projected potential for weak phase object materials (with lots of assumptions)
stemtool.dpc.nbed_dpc module¶
-
stemtool.dpc.nbed_dpc.log_sobel(pattern, med_factor=30, gauss_val=3)[source]¶ Take the Log-Sobel of a pattern.
Parameters: - pattern (ndarray) – Image on which Log-Sobel is to be performed
- med_factor (float) – Due to detector noise, some stray pixels may often be brighter than the background. This is used for damping any such pixels. Default is 30
- gauss_val (float) – The standard deviation of the Gaussian filter applied to the logarithm of the CBED pattern. Default is 3
Returns: lsb_pattern – Log-Sobel Filtered pattern
Return type: ndarray
Notes
Generate the Sobel filtered pattern of the logarithm of a dataset. Compared to running the Sobel filter back on a log dataset, this takes care of somethings - notably a Gaussian blur is applied to the image, and Sobel spikes are removed when any values are too higher or lower than the median of the image. This is because real detector images often are very noisy.
See also
nbed.log_sobel4D()