Using the pixelated STEM class

The PixelatedSTEM class extends HyperSpy’s Signal2D class, and makes heavy use of the lazy loading and map method to do lazy processing.

Visualizing the data

If you have a small dataset, s.plot can be used directly:

>>> import pixstem.api as ps
>>> s = ps.dummy_data.get_holz_simple_test_signal()
>>> s.plot()

If the dataset is very large and loaded lazily, there are some tricks which makes it easier to visualizie the signal. Using s.plot() on a lazy signal makes the library calculate a navigation image, which can be time consuming. See HyperSpy’s big data documentation for more info. Some various ways of avoiding this issue:

>>> import pixstem.api as ps
>>> s = ps.dummy_data.get_holz_simple_test_signal(lazy=True)

Using the navigator slider:

>>> s.plot(navigator='slider')

Using another signal as navigator, generated using virtual_annular_dark_field() or virtual_bright_field():

>>> s_adf = s.virtual_annular_dark_field(25, 25, 5, 20, show_progressbar=False)
>>> s.plot(navigator=s_adf)
>>> s_bf = s.virtual_bright_field(25, 25, 5, show_progressbar=False)
>>> s.plot(navigator=s_bf)

Center of mass

center_of_mass()

>>> s_com = s.center_of_mass(threshold=2, show_progressbar=False)
>>> s_com.plot()

Radial integration

radial_integration()

>>> s.axes_manager.signal_axes[0].offset = -25
>>> s.axes_manager.signal_axes[1].offset = -25
>>> s_r = s.radial_integration(show_progressbar=False)
>>> s_r.plot()

Rotating the diffraction pattern

rotate_diffraction()

>>> s = ps.dummy_data.get_holz_simple_test_signal()
>>> s_rot = s.rotate_diffraction(30, show_progressbar=False)
>>> s_rot.plot()

Shifting the diffraction pattern

shift_diffraction()

>>> s = ps.dummy_data.get_disk_shift_simple_test_signal()
>>> s_com = s.center_of_mass(threshold=3., show_progressbar=False)
>>> s_com -= 25 # To shift the centre spot to (25, 25)
>>> s_shift = s.shift_diffraction(
...     shift_x=s_com.inav[0].data, shift_y=s_com.inav[1].data, show_progressbar=False)
>>> s_shift.plot()

Finding and removing bad pixels

find_dead_pixels() find_hot_pixels() correct_bad_pixels()

Removing dead pixels:

>>> s = ps.dummy_data.get_dead_pixel_signal()
>>> s_dead_pixels = s.find_dead_pixels(show_progressbar=False, lazy_result=True)
>>> s_corr = s.correct_bad_pixels(s_dead_pixels)

Removing hot pixels, or single-pixel cosmic rays:

>>> s = ps.dummy_data.get_hot_pixel_signal()
>>> s_hot_pixels = s.find_hot_pixels(show_progressbar=False, lazy_result=True)
>>> s_corr = s.correct_bad_pixels(s_hot_pixels)

Or both at the same time:

>>> s_corr = s.correct_bad_pixels(s_hot_pixels + s_dead_pixels)
>>> s_corr.compute(progressbar=False)  # To get a non-lazy signal

correct_bad_pixels() returns a lazy signal by default, to avoid large datasets using up excessive amount of memory.