A Python module for 2D template matching
Project description
tm2d
A 2D template matcher written using the vkdispatch library.
Installation
You can install the application using the command:
pip3 install .
Imaging model
The projected potential $v_z(x,y)$ is modeled in one of two ways. It can be calculated from a slice through the Fourier transform of a density map (3D volume) or from a set of (3D) atomic coordinates. In the former case, different orientations are obtained by extracting different slices through the Fourier transform, while in the latter they are obtained by rotating the atomic coordinates, projecting along the $\hat{\mathbf{z}}$ (electron beam propagation) axis, and finally convolving the resulting 2D histogram of coordinates with a gaussian blur. The normalization of the gaussian kernel is set to approximately match a more rigorous calculation of the atomic projected potential in units of VÅ (Kirkland 2020).
From the projected potential, the phase $\phi(x,y)=\sigma_ev_z(x,y)$ that is imparted to the exit wave function is calculated by scaling the projected potential by the interaction parameter $\sigma_e$, which for 300 kV accelerating voltage is approximately 0.652 mrad/VÅ. More generally, it is equal to $me\lambda_e/2\pi\hbar^2$, where $m$ is the electron mass, $e$ is the elementary charge, $\lambda_e$ is the wavelength of the electron, and $\hbar$ is the reduced Planck constant.
It is assumed that the projected potential $\phi$ is real and non-negative, with its 2D Fourier transform corresponding to the structure factor, denoted by $\Phi$:
\Phi(s_x, s_y) = \mathcal{F}[\phi](s_x, s_y).
Here, the coordinates $(s_x, s_y)$ denote (non-angular) spatial frequency. A spatial frequency $\mathbf{s}=(s_x,s_y)$ intersects the back focal plane at the physical coordinate $(f_\mathrm{OL}\lambda_e s_x, f_\mathrm{OL}\lambda_e s_y)$, where $f_\mathrm{OL}$ is the effective focal length of the objective lens.
The calculation of an image from the projected potential requires a contrast transfer function (CTF), denoted $\mathcal{C}$. The key relationship that enables calculation of an image $\mathfrak{m}(x, y)$ from the structure factor $\Phi$ and the CTF $\mathcal{C}$ is
\mathfrak{m}(x, y) \propto \mathcal{F}^{-1} [\Phi \cdot \mathcal{C}](x, y).
The CTF is assumed to have the form
\mathcal{C}(\mathbf{s}) = E_\mathrm{TC}(\mathbf{s}) E_\mathrm{SC}(\mathbf{s}) E_\mathrm{JN}(\mathbf{s}) E_\mathrm{B}(\mathbf{s}) \sin[\chi(\mathbf{s}) - \chi(\mathbf{0}) - \kappa].
In the above, the terms $E_j$ are various envelope functions, $\chi$ is the wavefront aberration, and $\kappa$ is the amplitude contrast, taken to be a small constant such as 0.07.
The temporal coherence envelope function is given by
E_\mathrm{TC}(\mathbf{s}) = \exp \left(-\frac{1}{2}\sigma_f^2\pi^2\lambda_e ^2|\mathbf{s}|^4\right)
where $\sigma_f$ is the "defocus spread," which is given by
\sigma_f = C_c\sqrt{ \left(\epsilon \frac{\sigma_{V_0}}{V_0}\right)^2 + \left(\epsilon \frac{\sigma_{E_0}}{E_0}\right)^2 + \left(2\frac{\sigma_{I_0}}{I_0}\right)^2}
where $\Delta E_0 = 2\sqrt{2\ln 2}\sigma_{E_0}$ is the "energy spread" (typically quoted in FWHM, as opposed to the standard deviation $\sigma_{E_0}$), $C_c$ is the chromatic aberration coefficient, and $E_0$ is the electron energy. Relevant also are the objective lens current fluctuation $\sigma_{I_0}/I_0$ and accelerating voltage fluctation $\sigma_{V_0}/V_0$, which respectively have typical values of 0.1 ppm and 0.07 ppm. All the terms of the $\sigma_j$ denote standard deviations. The parameter $\epsilon$ is a relativistic correction factor given by
\epsilon = \frac{1 + \frac{E_0}{511 \text{ keV}}}{1 + \frac{E_0}{2\cdot 511 \text{ keV}}}
which is approximately 1.227 at 300 keV.
The spatial coherence envelope is given by
E_\mathrm{SC}(\mathbf{s}) = \exp\left[-2\sigma_\beta^2\pi^2|\mathbf{s}|^2\left( C_s\lambda_e ^2|\mathbf{s}|^2 - f_0 \right)^2 \right],
in which $C_s$ is the spherical aberration coefficient, $f_0$ is the mean defocus value, and $\sigma_\beta$ is the standard deviation of the distribution of beam angles (assumed to be gaussian, with a typical value of ~2.5 microradian) emerging from the gun.
The Johnson noise envelope is a gaussian envelope due to thermal magnetic field noise in the microscope column, with an associated variance $\sigma_\mathrm{J}^2$. This term is incorporated due to its potentially non-negligible values when using microscopes with relay optics (Axelrod et al., Ultramicroscopy 2023). The functional form of this envelope is
E_\mathrm{JN}(\mathbf{s}) = \exp \left( -2\pi^2\sigma_J^2 |\mathbf{s}|^2 \right).
A generic B-factor envelope is added for convenience. It has the functional form
E_\mathrm{B}(\mathbf{s}) = \exp\left(-\frac{1}{4}B|\mathbf{s}|^2\right).
The wavefront aberration is given by
\chi(\mathbf{s}) = \frac{2\pi}{\lambda_e}\left( \frac{1}{4}C_s\lambda_e^4|\mathbf{s}|^4 - \frac{1}{2}f_0\lambda_e^2|\mathbf{s}|^2 \right) + \eta(\mathbf{s}),
where $f_0>0$ denotes underfocus. The term $\eta(\mathbf{s})$ is the phase shift due to a phase plate. For instance, an ideal Zernike phase plate imparts the phase shift
\eta(\mathbf{s}) = \frac{\pi}{2}\delta(\mathbf{s})
where $\delta(\mathbf{s})$ is the Dirac delta function.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tm2d-0.2.0.tar.gz.
File metadata
- Download URL: tm2d-0.2.0.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b5f39f7e5be189f9b3c67aae05c25abb4353991f90d297d7027dba227722c75
|
|
| MD5 |
c442479b5f189e3b0b4dfb1c22268d23
|
|
| BLAKE2b-256 |
682696dbffb1ca984776acfbbfacfe98e5131afc84a72b12175780d4de384334
|
Provenance
The following attestation bundles were made for tm2d-0.2.0.tar.gz:
Publisher:
python-publish.yml on sharhar/tm2d
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tm2d-0.2.0.tar.gz -
Subject digest:
0b5f39f7e5be189f9b3c67aae05c25abb4353991f90d297d7027dba227722c75 - Sigstore transparency entry: 1403373402
- Sigstore integration time:
-
Permalink:
sharhar/tm2d@aa47356a7b4bb595fd0418739f3120c3f2cc883d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/sharhar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@aa47356a7b4bb595fd0418739f3120c3f2cc883d -
Trigger Event:
release
-
Statement type:
File details
Details for the file tm2d-0.2.0-py3-none-any.whl.
File metadata
- Download URL: tm2d-0.2.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5db582c79987d117c932f1cbf7e6d638459c45a5e818287e47c6f1f88259c80d
|
|
| MD5 |
4bb9b088df56531d070bbc8101d948fc
|
|
| BLAKE2b-256 |
3ecb62c97d7ab63910f0722e65a40540f7cf746aebe9935358256cb3d7a6db5e
|
Provenance
The following attestation bundles were made for tm2d-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on sharhar/tm2d
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tm2d-0.2.0-py3-none-any.whl -
Subject digest:
5db582c79987d117c932f1cbf7e6d638459c45a5e818287e47c6f1f88259c80d - Sigstore transparency entry: 1403373429
- Sigstore integration time:
-
Permalink:
sharhar/tm2d@aa47356a7b4bb595fd0418739f3120c3f2cc883d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/sharhar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@aa47356a7b4bb595fd0418739f3120c3f2cc883d -
Trigger Event:
release
-
Statement type: