Analysing differential phase contrast data

Differential phase contrast analysis (DPC) is done using using the DPCSignal classes: DPCSignal2D, DPCSignal1D and DPCBaseSignal.

Here, a test dataset is used to show the methods used to process this type of data. For information on how to load your own data, see :ref:load_dpc_data.

>>> import pixstem.api as ps
>>> s = ps.dummy_data.get_square_dpc_signal(add_ramp=True)
>>> s.plot()
_images/dpc_x_raw.jpg _images/dpc_y_raw.jpg

Correcting d-scan

correct_ramp()

The first step is the remove the effects of the d-scan:

>>> s = s.correct_ramp()
>>> s.plot()

Note that this method only does a plane correction, using the corners of the signal. For many datasets, this will not work very well. Possibly tweaks is to change the corner size.

_images/dpc_x_cor.jpg _images/dpc_y_cor.jpg

Plotting methods

Plotting DPC color image using: get_color_signal()

>>> s_color = s.get_color_signal()
>>> s_color.plot()
_images/dpc_color_image.jpg

Plotting DPC phase image: get_phase_signal()

>>> s_phase = s.get_phase_signal()
>>> s_phase.plot()
_images/dpc_phase_image.jpg

Plotting DPC magnitude image: get_magnitude_signal()

>>> s_magnitude = s.get_magnitude_signal()
>>> s_magnitude.plot()
_images/dpc_magnitude_image.jpg

Plotting bivariate histogram: get_bivariate_histogram()

>>> s_hist = s.get_bivariate_histogram()
>>> s_hist.plot(cmap='viridis')
_images/dpc_hist_image.jpg

Plotting color image with more customizability: get_color_image_with_indicator()

>>> fig = s.get_color_image_with_indicator()
>>> fig.show()
_images/dpc_color_image_indicator.jpg

Rotating the data

Rotating the probe axes: rotate_data(). Note, this will not rotate the beam shifts.

>>> s_rot_probe = s.rotate_data(10)
>>> s_rot_probe.get_color_signal().plot()
_images/dpc_rotate_probe_color.jpg

Rotating the beam shifts: rotate_beam_shifts().

>>> s_rot_shifts = s.rotate_beam_shifts(45)
>>> s_rot_shifts.get_color_signal().plot()
_images/dpc_rotate_shifts_color.jpg

Rotating both the probe dimensions and beam shifts by 90 degrees: flip_axis_90_degrees(). Note: in this dataset there will not be any difference compared to the original dataset. So we slightly alter the dataset.

>>> s1 = s.deepcopy()
>>> s1.data[0, 50:250, 145:155] += 5
>>> s1.get_color_signal().plot()
>>> s_flip_rot = s1.flip_axis_90_degrees()
>>> s_flip_rot.get_color_signal().plot()
_images/dpc_rotate_flip_color1.jpg _images/dpc_rotate_flip_color2.jpg

Blurring the data

The beam shifts can be blurred using gaussian_blur().

This is useful for suppressing the effects of variations in the crystal structure.

>>> s = ps.dummy_data.get_square_dpc_signal()
>>> s_blur = s.gaussian_blur()
>>> s.get_color_signal().plot()
>>> s_blur.get_color_signal().plot()
_images/dpc_gaussian_nonblur.jpg _images/dpc_gaussian_blur.jpg