Much faster atomic column integration implementation
In similar fashion to !47 (merged), I have sped up the atomic column integration implementation. Particularly so for the Voronoi cell integration method.
For a 512px by 512px, the old code took 124 seconds. The new version takes 3.6 seconds. The new version makes it reasonable to perform Voronoi integration on 1024px (45 sec) and 2048px images (half-an-hour ish) as well, where the old version took a LOT longer.
I have achieved the speed-boost partly by rewriting some code and moving things that did not need to be inside loops, outside loops. But the main speed-increase has come from implementing the numba jit (just-in-time) compilation decorator around the function that calculates the shortest distance between points for the point-record image.
In addition, I have added a function that removes any cells that are near the edges of the image/dataset. These are often annoying in that they get mess up the contrast of the displayed integrated_record image, and they are complicated to manually remove in order to calculate correct statistics (think, mean of the atomic column intensity).
Finally, I have updated a few things on watershed, including switching to the new location for watershed in the skimage toolkit (previous was being deprecated).
Attached is an example file and example result, showing the raw data, Voronoi integration and integration with removed border cells.
%matplotlib widget
import atomap.api as am
import hyperspy.api as hs
import matplotlib.pyplot as plt
s = hs.load("20181005_2006_STEM_HAADF_2.7_Mx.tif")
s2 = s.isig[:1024,:1024] # change to 256, 256 for speed
#nav = hs.signals.Signal2D([[1,2,3], [4,5,6]]).T
S = s2#nav*s2.T
points_x, points_y = am.get_atom_positions(s2).T
i, ir, pr = am.integrate(S, points_x, points_y, method='Voronoi', remove_edge_cells=True, edge_pixels=5)
# Or alternatively, with `remove_edge_cells=False` in previous line
# i, ir, pr = remove_integrated_edge_cells(i, ir, pr, pixels=5)
fig = plt.figure(dpi=200)
hs.plot.plot_images([s2, ir, pr], fig=fig, colorbar=False)