This notebook showns a subset of the functionality which is used to analyze image data in HyperSpy.
Example data is annular bright field (ABF) high resolution scanning transmission electron microscopy (HRSTEM) data of SrTiO$_3$.
This notebook requires:
HyperSpy 1.3 or later
%matplotlib nbagg
import hyperspy.api as hs
s = hs.load("datasets/stem_abf_data.hspy")
s.plot()
The brightness and contrast can be set using
s._plot.signal_plot.gui_adjust_contrast()
Different color maps are set using the cmap
argument
s.plot(cmap='viridis')
Region of interests can be used to extract subsets of a signal
line_roi = hs.roi.Line2DROI(x1=0.5, y1=0.5, x2=1, y2=1, linewidth=0.5)
s.plot()
s_line = line_roi.interactive(s, color='red')
s_line.plot()
This can also be used to crop images
rectangular_roi = hs.roi.RectangularROI(left=0.3, right=1.5, top=0.2, bottom=1.6)
s.plot()
s_rectangular = rectangular_roi.interactive(s, color='red')
s_rectangular.plot()
There are also some basic drift alignment functionality, for correcting drift. It wasn't really designed for atomic resolution images like these, but still work fairly well. It was implemented for correcting drift when heating samples using a DENS heating holder.
s_stack = hs.load("datasets/stem_abf_data_imagestack.hspy")
s_stack.plot()
Since this is an image stack, we use the cascade
reference, which means the current image is compared to the previous one. For more information about the arguments, see the docstring for align2D
alignment_list = s_stack.align2D(roi=(250, 600, 250, 600), crop=True, reference='cascade', hanning=True, sobel=True, medfilter=True)
s_stack.plot()
We can now sum this stack, to produce an image with better signal-to-noise ratio
s_aligned = s_stack.mean(0)
s_aligned.plot()