afmslicer.filter
¶
Filtering images for AFMSlicer processing.
SlicingFilter
¶
Bases: Filters
Filtering and flattening of images for AFMSlicer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topostats_object
|
AFMSlicer
|
An |
required |
row_alignment_quantile
|
float
|
Quantile on which to align values, default is |
None
|
gaussian_size
|
float
|
Amount of Gaussian blurring to perform. |
None
|
gaussian_mode
|
str
|
Method of Gaussian blurring to use. |
None
|
remove_scars
|
dict[str, bool | int | float]
|
Whether to remove scars or not. This is performed using TopoStats' scar removal method. |
None
|
Examples:
The final image after all stages is stored in the SlicingFilter.image dictionary with the key
gaussian_filtered.
>>> import numpy as np
>>> from topostats.classes import TopoStats
>>> from afmslicer.filter import SlicingFilter
>>> rng = np.random.default_rng(seed=32424308)
>>> small_array = rng.random((5, 5), dtype=np.float64)
>>> afmslicer_object = TopoStats(
>>> image_original=small_array,
>>> filename="small_array",
>>> pixel_to_nm_scaling=1.0,
>>> img_path="./")
>>> filter_config = {
>>> "row_alignment_quantile": 0.5,
>>> "gaussian_size": 1.012139,
>>> "gaussian_mode": nearest,
>>> "remove_scars": {
>>> "run": False,
>>> "removal_iterations": 2 # Number of times to run scar removal.
>>> "threshold_low": 0.250 # lower values make scar removal more sensitive
>>> "threshold_high": 0.666 # lower values make scar removal more sensitive
>>> "max_scar_width": 4 # Maximum thickness of scars in pixels.
>>> "min_scar_length": 16
>>> }
>>> }
>>> slicing_filter = SlicingFilter(
>>> topostats_object=afmslicer_object,
>>> **filter_config)
>>> slicing_filter.filter_image()
Source code in src/afmslicer/filter.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
__init__(topostats_object, row_alignment_quantile=None, gaussian_size=None, gaussian_mode=None, remove_scars=None)
¶
Initialise the class.
This class inherits from the topostats.Filters() class and methods are reused to filter and flatten the
image.
NB - Because this class inherits from topostats.classes.TopoStats() class the main attribute inherits that
name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topostats_object
|
AFMSlicer
|
A |
required |
row_alignment_quantile
|
float
|
Quantile on which to align values, default is |
None
|
gaussian_size
|
float
|
Amount of Gaussian blurring to perform. |
None
|
gaussian_mode
|
str
|
Method of Gaussian blurring to use. |
None
|
remove_scars
|
dict[str, bool | int | float]
|
Whether to remove scars or not. This is performed using TopoStats' scar removal method. |
None
|
Source code in src/afmslicer/filter.py
filter_image()
¶
Filter the image.
The following steps are performed to filter the image.
- Median flattening.
- Tilt removal.
- Quadratic removal.
- Nonlinear polynomial removal.
- Scar removal (optional).
- Zero average background.
- Gaussian filtering.
The methods used are inherited from TopoStats.Filters class.