Excluders

Excluders are used to filter points in a generator based on a pair of coordinates and a region of interest.

class scanpointgenerator.Excluder(roi, scannables)[source]

A class to remove points that lie outside of a given 2D region of interest

Parameters:
  • roi (ROI) – Region of interest to filter points by
  • scannables (list) – List of two scannables to filter points by
contains_point(d)[source]

Create a 2D sub-point from the ND point d and pass the sub_point to the roi to check if it contains it.

Parameters:d (dict) – Dictionary representation of point
Returns:Whether roi contains the given point
Return type:bool
to_dict()[source]

Convert object attributes into a dictionary

classmethod from_dict(d)[source]

Create a Excluder instance from a serialised dictionary

Parameters:d (dict) – Dictionary of attributes
Returns:New Excluder instance
Return type:Excluder

CircularROI Example

Here we use a CircularROI to filter the points of a snake scan

from scanpointgenerator import LineGenerator, CompoundGenerator, \
Excluder, plot_generator
from scanpointgenerator.circular_roi import CircularROI

x = LineGenerator("x", "mm", 0.0, 4.0, 5, alternate_direction=True)
y = LineGenerator("y", "mm", 0.0, 3.0, 4)
circle = Excluder(CircularROI([2.0, 1.0], 2.0), ["x", "y"])
gen = CompoundGenerator([y, x], [], [])
plot_generator(gen, circle)

(Source code)

And with the excluder applied

from scanpointgenerator import LineGenerator, CompoundGenerator, \
Excluder, plot_generator
from scanpointgenerator.circular_roi import CircularROI

x = LineGenerator("x", "mm", 0.0, 4.0, 5, alternate_direction=True)
y = LineGenerator("y", "mm", 0.0, 3.0, 4)
circle = Excluder(CircularROI([2.0, 1.0], 2.0), ["x", "y"])
excluder = Excluder(circle, ['x', 'y'])
gen = CompoundGenerator([y, x], [circle], [])
plot_generator(gen, circle)

(Source code)