# PC calibration: “moving-screen” technique#

The gnomonic projection (pattern) center (PC) of an EBSD detector can be estimated by the “moving-screen” technique , which we will test in this tutorial.

The technique relies on the assumption that the beam normal, shown in the top figure (d) in the reference frames tutorial, is normal to the detector screen as well as the incoming electron beam, and will therefore intersect the screen at a position independent of the detector distance (DD). To find this position, we need two EBSD patterns acquired with a stationary beam but with a known difference $$\Delta z$$ in DD, say 5 mm.

First, the goal is to find the pattern position which does not shift between the two camera positions, ($$PC_x$$, $$PC_y$$). This point can be estimated in fractions of screen width and height, respectively, by selecting the same pattern features in both patterns. The two points of each pattern feature can then be used to form a straight line, and two or more such lines should intersect at ($$PC_x$$, $$PC_y$$).

Second, the DD ($$PC_z$$) can be estimated from the same points. After finding the distances $$L_{in}$$ and $$L_{out}$$ between two points (features) in both patterns (in = operating position, out = 5 mm from operating position), the DD can be found from the relation

$\mathrm{DD} = \frac{\Delta z}{L_{out}/L_{in} - 1},$

where DD is given in the same unit as the known camera distance difference. If also the detector pixel size $$\delta$$ is known (e.g. 46 mm / 508 px), $$PC_z$$ can be given in the fraction of the detector screen height

$PC_z = \frac{\mathrm{DD}}{N_r \delta b},$

where $$N_r$$ is the number of detector rows and $$b$$ is the binning factor.

Let’s first import necessary libraries

:

# Exchange inline for notebook or qt5 (from pyqt) for interactive plotting
%matplotlib inline

import matplotlib.pyplot as plt
import numpy as np

from diffsims.crystallography import ReciprocalLatticeVector
from orix.crystal_map import PhaseList
import kikuchipy as kp


We will find an estimate of the PC from two single crystal Silicon EBSD patterns, which are included in the kikuchipy.data module

:

s_in = kp.data.si_ebsd_moving_screen(0, allow_download=True)
s_in.remove_static_background()
s_in.remove_dynamic_background()

s_out5mm.remove_static_background()
s_out5mm.remove_dynamic_background()

2023-05-29 09:04:40,494 - hyperspy.extensions - INFO - Enabling extension kikuchipy

[########################################] | 100% Completed | 105.87 ms
[########################################] | 100% Completed | 102.49 ms
[########################################] | 100% Completed | 104.88 ms
[########################################] | 100% Completed | 102.07 ms


As a first approximation, we can find the detector pixel positions of the same features in both patterns by plotting them and noting the coordinates in the upper right in the Matplotlib window when plotting with an interactive backend (e.g. qt5 or notebook) and hovering over image pixels

:

fig, axes = plt.subplots(ncols=2, sharex=True, sharey=True, figsize=(14, 7))
for ax, data in zip(axes, [s_in.data, s_out5mm.data]):
ax.imshow(data, cmap="gray") For this example we choose the positions of three zone axes. The PC calibration is performed by creating an instance of the PCCalibrationMovingScreen class

:

cal = kp.detectors.PCCalibrationMovingScreen(
pattern_in=s_in.data,
pattern_out=s_out5mm.data,
points_in=[(109, 131), (390, 139), (246, 232)],
points_out=[(77, 146), (424, 156), (246, 269)],
delta_z=5,
px_size=None,  # Default
convention="tsl",  # Default
)
cal

:

PCCalibrationMovingScreen: (PCx, PCy, PCz) = (0.5123, 0.8606, 21.6518)
3 points:
[[[109 131]
[390 139]
[246 232]]

[[ 77 146]
[424 156]
[246 269]]]


We see that ($$PC_x$$, $$PC_y$$) = (0.5123, 0.8606), while DD = 21.7 mm. To get $$PC_z$$ in fractions of detector height, we have to provide the detector pixel size $$\delta$$ upon initialization, or set it directly and recalculate the PC

:

cal.px_size = 90e-3  # mm/px
cal

:

PCCalibrationMovingScreen: (PCx, PCy, PCz) = (0.5123, 0.8606, 0.5012)
3 points:
[[[109 131]
[390 139]
[246 232]]

[[ 77 146]
[424 156]
[246 269]]]


We can visualize the estimation by using the convenience method PCCalibrationMovingScreen.plot()

:

cal.plot() As expected, the three lines in the right figure meet at approimately the same point. We can replot the three images and zoom in on the PC to see how close they are to each other

:

# PCy defined from top to bottom, otherwise "tsl", defined from bottom to top
cal.convention = "bruker"
pcx, pcy, _ = cal.pc

# Use two standard deviations of all $PC_x$ estimates as the axis limits
# (scaled with pattern shape)
two_std = 2 * np.std(cal.pcx_all, axis=0)

fig = cal.plot(return_figure=True)
ax2 = fig.axes
ax2.set_xlim([cal.ncols * (pcx - two_std), cal.ncols * (pcx + two_std)])
ax2.set_ylim([cal.nrows * (pcy - two_std), cal.nrows * (pcy + two_std)]) We can use this PC estimate as an initial guess when refining the PC using Hough indexing available from the PyEBSDIndex Python package. See the Hough indexing tutorial for details on the below commands.

Note

PyEBSDIndex is an optional dependency of kikuchipy, and can be installed with both pip and conda (from conda-forge). To install PyEBSDIndex, see their installation instructions.

PyEBSDIndex supports indexing face centered and body centered cubic (FCC and BCC) materials.

Create a detector with the correct shape and sample tilt, adding the PC estimate

:

det = kp.detectors.EBSDDetector(cal.shape, sample_tilt=70, pc=cal.pc)
det

:

EBSDDetector (480, 480), px_size 1 um, binning 1, tilt 0, azimuthal 0, pc (0.512, 0.139, 0.501)


Create an EBSDIndexer for use with PyEBSDIndex

:

phase_list = PhaseList(names="si", space_groups=227)
print(phase_list)

indexer = det.get_indexer(phase_list)
print(indexer.phaselist)

Id  Name  Space group  Point group  Proper point group     Color
0    si        Fd-3m         m-3m                 432  tab:blue
['FCC']


Optimize the PC via Hough indexing and plot the difference between the estimated and optimized PCs

:

det_ref = s_in.hough_indexing_optimize_pc(pc0=det.pc, indexer=indexer)

print(det.pc - det_ref.pc)

[[-0.00620566 -0.01507319  0.01644637]]


Index the pattern via Hough indexing

:

indexer.PC = det_ref.pc

xmap = s_in.hough_indexing(phase_list, indexer=indexer, verbose=0)

Hough indexing with PyEBSDIndex information:
PyOpenCL: False
Projection center (Bruker): (0.5185, 0.1544, 0.4848)
Indexing 1 pattern(s) in 1 chunk(s)
Indexing speed: 1.96709 patterns/s

:

xmap

:

Phase  Orientations  Name  Space group  Point group  Proper point group     Color
0    1 (100.0%)    si        Fd-3m         m-3m                 432  tab:blue
Properties: fit, cm, pq, nmatch
Scan unit: px


Create a simulator with the five $$\{hkl\}$$ families (reflectors) $$\{111\}$$, $$\{200\}$$, $$\{220\}$$, $$\{222\}$$, and $$\{311\}$$

:

rlv = ReciprocalLatticeVector(
phase=xmap.phases,
hkl=[[1, 1, 1], [2, 0, 0], [2, 2, 0], [2, 2, 2], [3, 1, 1]],
)
rlv = rlv.symmetrise()

simulator = kp.simulations.KikuchiPatternSimulator(rlv)

sim = simulator.on_detector(det_ref, xmap.rotations)

Finding bands that are in some pattern:
[########################################] | 100% Completed | 101.53 ms
Finding zone axes that are in some pattern:
[########################################] | 100% Completed | 101.85 ms
Calculating detector coordinates for bands and zone axes:
[########################################] | 100% Completed | 101.59 ms


Plot a geometrical simulation on top of the pattern using Kikuchi band centers

:

sim.plot(
coordinates="gnomonic",
pattern=s_in.data,
zone_axes_labels=False,
zone_axes=False,
) 