qem.gui_classes

Functions

get_atom_selection_from_verts(...[, ...])

Get a subset of atom positions within region spanned to verticies.

get_atom_type()

get_unique_colors()

An iterator to generate unique colors by cycling through the HSV color space.

zoom_nd(input_array[, offsets, ...])

Zoom in on the center of a 1D or 2D array using Fourier upsampling.

Classes

GetAtomSelection(image, atom_positions[, ...])

GetRegionSelection(image, region_map[, ...])

InteractivePlot(image, peaks_locations[, ...])

ScaleBar(*args, **kwargs)

qem.gui_classes.get_atom_selection_from_verts(atom_positions, verts, invert_selection=False)[source]

Get a subset of atom positions within region spanned to verticies.

Parameters:
  • atom_positions (list or NumPy array) – In the form [[x0, y0]. [x1, y1], …]

  • verts (list of tuples) – List of positions, spanning an enclosed region. [(x0, y0), (x1, y1), …]. Need to have at least 3 positions.

  • invert_selection (bool, optional) – Get the atom positions outside the region, instead of the ones inside it. Default False.

Returns:

atom_positions_selected (NumPy array)

Examples

>>> from numpy.random import randint
>>> from atomap.tools import _get_atom_selection_from_verts
>>> atom_positions = randint(0, 200, size=(200, 2))
>>> verts = [(200, 400), (400, 600), (100, 100)]
>>> atom_positions_selected = _get_atom_selection_from_verts(
...        atom_positions=atom_positions, verts=verts)

Get atom positions inside the region

>>> atom_positions_selected = _get_atom_selection_from_verts(
...        atom_positions=atom_positions, verts=verts,
...        invert_selection=True)
qem.gui_classes.get_atom_type()[source]
class qem.gui_classes.GetRegionSelection(image, region_map, invert_selection=False)[source]
__init__(image, region_map, invert_selection=False)[source]
onselect(verts)[source]
get_region_mask()[source]
class qem.gui_classes.GetAtomSelection(image, atom_positions, invert_selection=False, size=1)[source]
__init__(image, atom_positions, invert_selection=False, size=1)[source]

Get a subset of atom positions using interactive tool.

Access the selected atom positions in the atom_positions_selected attribute.

Parameters:
  • image (2D HyperSpy signal or 2D NumPy array)

  • atom_positions (list of lists, NumPy array) – In the form [[x0, y0]. [x1, y1], …]

  • invert_selection (bool, optional) – Get the atom positions outside the region, instead of the ones inside it. Default False

Variables:

atom_positions_selected (NumPy array)

onselect(verts)[source]
get_mask_image(path, invert_selection=False)[source]
class qem.gui_classes.InteractivePlot(image: numpy.ndarray, peaks_locations: numpy.ndarray, atom_types: numpy.ndarray | None = None, tolerance: float = 10, dx: float = 1, units: str = 'A', dimension: str = 'si-length', zoom: float = 1)[source]
__init__(image: numpy.ndarray, peaks_locations: numpy.ndarray, atom_types: numpy.ndarray | None = None, tolerance: float = 10, dx: float = 1, units: str = 'A', dimension: str = 'si-length', zoom: float = 1)[source]
onclick_add_or_remove(event)[source]
on_key_press(event)[source]
property scalebar
update_plot(title)[source]
add_or_remove(tolerance: float = 10)[source]
onclick_select(event)[source]
select(tolerance: float = 10)[source]
onclick_select_vectors(event)[source]
draw_arrow(start, end, label)[source]
select_vectors(tolerance: float)[source]