Excluders¶
Excluders are used to filter points in a generator based on a pair of coordinates and some attribute of the point, for example its position or duration.
ROIExcluders¶
ROIExcluders filter points that fall outside of a given a region of interest.
-
class
scanpointgenerator.
ROIExcluder
(rois, axes)[source]¶ A class to exclude points outside of regions of interest.
Parameters: - rois (list(ROI)) – List of regions of interest
- axes (list(str)) – Names of axes to exclude points from
-
create_mask
(*point_arrays)[source]¶ Create a boolean array specifying the points to exclude.
The resulting mask is created from the union of all ROIs.
Parameters: *point_arrays (numpy.array(float)) – Array of points for each axis Returns: Array of points to exclude Return type: np.array(int8)
-
classmethod
from_dict
(d)[source]¶ Create a ROIExcluder from a serialised dictionary.
Parameters: d (dict) – Dictionary of attributes Returns: New instance of ROIExcluder Return type: ROIExcluder
CircularROI Example¶
Here we use CircularROIs to filter the points of a snake scan
from scanpointgenerator import LineGenerator, CompoundGenerator, \
ROIExcluder, CircularROI
from scanpointgenerator.plotgenerator import plot_generator
x = LineGenerator("x", "mm", 0.0, 4.0, 5, alternate=True)
y = LineGenerator("y", "mm", 0.0, 3.0, 4)
circles = ROIExcluder([CircularROI([1.0, 2.0], 2.0),
CircularROI([2.0, 1.0], 2.0)], ["x", "y"])
gen = CompoundGenerator([y, x], [], [])
plot_generator(gen, circles)
(Source code, png, hires.png, pdf)
And with the excluder applied
from scanpointgenerator import LineGenerator, CompoundGenerator, \
ROIExcluder, CircularROI
from scanpointgenerator.plotgenerator import plot_generator
x = LineGenerator("x", "mm", 0.0, 4.0, 5, alternate=True)
y = LineGenerator("y", "mm", 0.0, 3.0, 4)
circles = ROIExcluder([CircularROI([1.0, 2.0], 2.0),
CircularROI([2.0, 1.0], 2.0)], ["x", "y"])
gen = CompoundGenerator([y, x], [circles], [])
plot_generator(gen, circles)
(Source code, png, hires.png, pdf)