derollins commited on
Commit
600f394
·
verified ·
1 Parent(s): 8b7909d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -18
README.md CHANGED
@@ -16,13 +16,14 @@ tags:
16
  # afMLevel-background-unet
17
 
18
  This U‑Net model predicts tilt, z scanner drift, and other large‑scale imaging artifacts present in Atomic Force Microscopy (AFM) height maps.
19
- It outputs a **background** image, the same size and scale as the raw AFM image, which can be subtracted (via the accompanying [afMLevel](https://github.com/mayatek1/afMLevel)
20
- code) to produce a levelled height map.
21
 
22
  > **Note:** afMLevel includes a second model, **afMLevel-mask-unet**,
23
  > that predicts a feature map that can be used in traditional auto-levelling routines where line and plane
24
  > fits are applied to the background (unmasked, featureless regions) rather than directly
25
- > generating the noise background. Both models will be described in the accompanying paper and the mask model is found
 
26
  > here: [https://huggingface.co/Heath-AFM-Lab/afMLevel-mask-unet](https://huggingface.co/Heath-AFM-Lab/afMLevel-mask-unet)
27
 
28
  ## Model Details
@@ -58,7 +59,8 @@ The afMLevel repository includes tools for:
58
  ### Model Sources
59
 
60
  - **Repository:** https://github.com/mayatek1/afMLevel
61
- - **Paper:** Tekchandani et al., *AFMLevel: Deep learning U-Net Models for levelling Atomic Force Microscopy Images and Movies* (in preparation, 2026)
 
62
  - **Demo:** [Demonstration notebooks](https://github.com/mayatek1/afMLevel/tree/main/notebooks)
63
 
64
  ## Uses
@@ -97,6 +99,12 @@ This model is **not** intended for:
97
 
98
  - Manually verify a subset of predicted backgrounds and levelled images.
99
  - Avoid applying the model to imaging modes it was not trained on without validation.
 
 
 
 
 
 
100
 
101
  ## How to Get Started with the Model
102
 
@@ -104,7 +112,7 @@ Use the model through the [afMLevel](https://github.com/mayatek1/afMLevel) repos
104
 
105
  ## Inference Speed
106
 
107
- Per-frame processing time scales with image resolution in discrete steps rather than continuously: processing time is dominated by the inference step, and the number of inference steps increases as the image resolution crosses 256-pixel thresholds and additional tiles are generated. For a range of resolutions that map to the same number of tiles, per-frame processing time remains approximately constant, producing plateaus. The background model is slower than classical non-ML levelling routines but is not prohibitive for research pipelines at typical AFM and HS-AFM resolutions. Full timing benchmarks are provided in the accompanying paper (in preparation, check the [GitHub](https://github.com/mayatek1/afMLevel) for updates).
108
 
109
  ## Training Details
110
 
@@ -119,7 +127,10 @@ To increase dataset size and improve generalization, images were augmented using
119
  - reflection along the y‑axis,
120
  - rotation by 180°.
121
 
122
- This produced **6,003 training images**. An **80:20 train‑validation split** was used.
 
 
 
123
 
124
  ### Training Procedure
125
 
@@ -133,20 +144,25 @@ This produced **6,003 training images**. An **80:20 train‑validation split** w
133
  - **Dropout:** none (p = 0.0)
134
  - **Batch size:** 32
135
  - **Hardware:** trained with GPU acceleration
136
- - **Training images:** 6,003
137
  - **Train/validation split:** 80:20 (random)
138
  - **Loss function:** Mean Squared Error (MSE)
139
  - Loss‑curve diagnostics were used to monitor convergence.
140
 
141
  #### Preprocessing
142
 
143
- Input images were preprocessed identically to the training data:
144
 
145
  1. An initial 1st-order plane fit applied in x and y.
146
  2. Min-max normalisation to [0, 1].
147
- 3. Images larger than 256 × 256 are pixel-split into 256 × 256 tiles for inference.
 
 
 
148
 
149
- For the **background model**, a pixel-split method was employed for tiling to preserve all pixel values. Multiple 256 × 256 images were generated by taking alternating pixels.
 
 
150
 
151
  #### Training Hyperparameters
152
 
@@ -155,7 +171,7 @@ For the **background model**, a pixel-split method was employed for tiling to pr
155
  #### Speeds, Sizes, Times
156
 
157
  - **Model file size:** 982 MiB
158
- - **Training epochs:** 59
159
 
160
  ## Evaluation
161
 
@@ -163,13 +179,13 @@ The performance of the ML‑generated predicted backgrounds was evaluated indire
163
  The core quantitative metric used for assessment was the **Mean Squared Error** (MSE) between the afMLevel predicted-background-subtracted
164
  output and a manually levelled ground‑truth image. The results were also assessed visually by the developers.
165
 
166
- Full details are in the paper: in preparation (check the [GitHub](https://github.com/mayatek1/afMLevel) for updates).
167
 
168
  ### Testing Data & Metrics
169
 
170
  #### Testing Data
171
 
172
- Evaluation was performed on a held‑out set of real AFM height maps spanning a wide range of:
173
 
174
  - biological sample types,
175
  - imaging conditions,
@@ -186,9 +202,9 @@ Evaluation was performed on a held‑out set of real AFM height maps spanning a
186
 
187
  ### Results
188
 
189
- Initial internal testing indicates that the ML‑generated predicted backgrounds enable reliable automated levelling across a broad range of AFM images,
190
- including scans with varied noise levels and multiple height planes. Quantitative results and statistical analyses will be provided in the accompanying
191
- paper (in preparation, check the [GitHub](https://github.com/mayatek1/afMLevel) for updates).
192
 
193
  ## Citation
194
 
@@ -196,7 +212,7 @@ If you use this model in your work, please cite:
196
 
197
  ```bibtex
198
  @article{tekchandani2026afmlevel,
199
- title = {AFMLevel: Deep Learning U-Net Models for Levelling Atomic Force Microscopy Images and Movies},
200
  author = {Tekchandani, Maya and Rollins, Daniel E. and Westerell, Megan and Evans, Stephen D. and Adams, Peter G. and Heath, George R.},
201
  year = {2026},
202
  journal = {bioRxiv},
@@ -205,7 +221,7 @@ If you use this model in your work, please cite:
205
  ```
206
 
207
  Tekchandani M, Rollins DE, Westerell M, Evans SD, Adams PG, Heath GR.
208
- *AFMLevel: Deep Learning U-Net Models for Levelling Atomic Force Microscopy Images and Movies*.
209
  bioRxiv (2026).
210
  https://doi.org/10.64898/2026.10.19.760138
211
 
 
16
  # afMLevel-background-unet
17
 
18
  This U‑Net model predicts tilt, z scanner drift, and other large‑scale imaging artifacts present in Atomic Force Microscopy (AFM) height maps.
19
+ It outputs a 256 × 256 **background** image for each input tile; the accompanying [afMLevel](https://github.com/mayatek1/afMLevel)
20
+ code stitches these into a background the same size and scale as the raw AFM image, which is subtracted to produce a levelled height map.
21
 
22
  > **Note:** afMLevel includes a second model, **afMLevel-mask-unet**,
23
  > that predicts a feature map that can be used in traditional auto-levelling routines where line and plane
24
  > fits are applied to the background (unmasked, featureless regions) rather than directly
25
+ > generating the noise background. Both models are described in the accompanying preprint ([Tekchandani *et al.*, 2026](https://doi.org/10.64898/2026.10.19.760138))
26
+ > and the mask model is found
27
  > here: [https://huggingface.co/Heath-AFM-Lab/afMLevel-mask-unet](https://huggingface.co/Heath-AFM-Lab/afMLevel-mask-unet)
28
 
29
  ## Model Details
 
59
  ### Model Sources
60
 
61
  - **Repository:** https://github.com/mayatek1/afMLevel
62
+ - **Training and evaluation code:** [afmlevel-paper branch](https://github.com/mayatek1/afMLevel/tree/afmlevel-paper)
63
+ - **Paper:** [Tekchandani *et al.*, 2026](https://doi.org/10.64898/2026.10.19.760138)
64
  - **Demo:** [Demonstration notebooks](https://github.com/mayatek1/afMLevel/tree/main/notebooks)
65
 
66
  ## Uses
 
99
 
100
  - Manually verify a subset of predicted backgrounds and levelled images.
101
  - Avoid applying the model to imaging modes it was not trained on without validation.
102
+ - In the accompanying benchmark, two passes gave the lowest mean MSE and three the
103
+ highest visual score. To apply multiple passes, use the output of one pass as the
104
+ input to the next.
105
+ - For images with strong line noise, very large height ranges, or fibres aligned with the
106
+ scan axis, consider using the mask model
107
+ ([`MLMask`](https://huggingface.co/Heath-AFM-Lab/afMLevel-mask-unet)) as an alternative or complement.
108
 
109
  ## How to Get Started with the Model
110
 
 
112
 
113
  ## Inference Speed
114
 
115
+ Per-frame processing time scales with image resolution in discrete steps rather than continuously: processing time is dominated by the inference step, and the number of inference steps increases as the image resolution crosses 256-pixel thresholds and additional tiles are generated. For a range of resolutions that map to the same number of tiles, per-frame processing time remains approximately constant, producing plateaus. The background model is slower than classical non-ML levelling routines but is not prohibitive for research pipelines at typical AFM and HS-AFM resolutions. Full timing benchmarks are provided in the accompanying preprint ([Tekchandani *et al.*, 2026](https://doi.org/10.64898/2026.10.19.760138)).
116
 
117
  ## Training Details
118
 
 
127
  - reflection along the y‑axis,
128
  - rotation by 180°.
129
 
130
+ This produced **6,003 augmented images** (4,800 training, 1,203 validation). An **80:20 train‑validation split** was used.
131
+
132
+ Ground-truth backgrounds were the normalised, plane-fitted raw image minus the manually levelled image, scaled using the
133
+ minimum and maximum of the raw image.
134
 
135
  ### Training Procedure
136
 
 
144
  - **Dropout:** none (p = 0.0)
145
  - **Batch size:** 32
146
  - **Hardware:** trained with GPU acceleration
147
+ - **Training images:** 4,800 (plus 1,203 validation images)
148
  - **Train/validation split:** 80:20 (random)
149
  - **Loss function:** Mean Squared Error (MSE)
150
  - Loss‑curve diagnostics were used to monitor convergence.
151
 
152
  #### Preprocessing
153
 
154
+ Inference preprocessing:
155
 
156
  1. An initial 1st-order plane fit applied in x and y.
157
  2. Min-max normalisation to [0, 1].
158
+ 3. Images larger than 256 × 256 are pixel-split into 256 × 256 tiles.
159
+
160
+ Training used the same plane fit and normalisation, but images were first resized to
161
+ 256 × 256 with nearest-neighbour interpolation; pixel-splitting was not used in training.
162
 
163
+ The pixel-split method preserves all pixel values by generating multiple 256 × 256 images
164
+ from alternating pixels. Images whose dimensions are not multiples of 256 are first
165
+ mirror-padded up to the next multiple.
166
 
167
  #### Training Hyperparameters
168
 
 
171
  #### Speeds, Sizes, Times
172
 
173
  - **Model file size:** 982 MiB
174
+ - **Training epochs:** 60 (published checkpoint: epoch 59, lowest validation loss among the final epochs)
175
 
176
  ## Evaluation
177
 
 
179
  The core quantitative metric used for assessment was the **Mean Squared Error** (MSE) between the afMLevel predicted-background-subtracted
180
  output and a manually levelled ground‑truth image. The results were also assessed visually by the developers.
181
 
182
+ Full details are in [Tekchandani *et al.*, 2026](https://doi.org/10.64898/2026.10.19.760138).
183
 
184
  ### Testing Data & Metrics
185
 
186
  #### Testing Data
187
 
188
+ Evaluation was performed on a held‑out set of 164 real AFM height maps spanning a wide range of:
189
 
190
  - biological sample types,
191
  - imaging conditions,
 
202
 
203
  ### Results
204
 
205
+ On a 164-image held-out test set, MLBackground routines performed comparably to MLMask and
206
+ significantly better than all fourteen classical routines tested (MLBackground 2×, p < 0.01). See
207
+ [Tekchandani *et al.*, 2026](https://doi.org/10.64898/2026.10.19.760138) for per-routine results.
208
 
209
  ## Citation
210
 
 
212
 
213
  ```bibtex
214
  @article{tekchandani2026afmlevel,
215
+ title = {afMLevel: Deep Learning U-Net Models for Levelling Atomic Force Microscopy Images and Movies},
216
  author = {Tekchandani, Maya and Rollins, Daniel E. and Westerell, Megan and Evans, Stephen D. and Adams, Peter G. and Heath, George R.},
217
  year = {2026},
218
  journal = {bioRxiv},
 
221
  ```
222
 
223
  Tekchandani M, Rollins DE, Westerell M, Evans SD, Adams PG, Heath GR.
224
+ *afMLevel: Deep Learning U-Net Models for Levelling Atomic Force Microscopy Images and Movies*.
225
  bioRxiv (2026).
226
  https://doi.org/10.64898/2026.10.19.760138
227