afMLevel-data / README.md
derollins's picture
Update data sources table to match CSV files and make licencing agreement clearer.
fb78926 verified
|
Raw History Blame Contribute Delete
8.16 kB
---
pretty_name: afMLevel Training and Test Data
task_categories:
- image-to-image
- image-segmentation
tags:
- atomic-force-microscopy
- afm
- hs-afm
- microscopy
- image-levelling
- biophysics
size_categories:
- 1K<n<10K
license: cc-by-4.0
---
# afMLevel: AFM Image Levelling and Masking Dataset
Paired atomic force microscopy (AFM) height images used to train and evaluate
the U-Net models in [afMLevel](https://github.com/mayatek1/afMLevel): a deep
learning tool for AFM image levelling through automated background estimation
or foreground masking of AFM topography images.
Each sample consists of a **raw AFM height image** and its corresponding
**reference-levelled image**, produced by conventional manual levelling in
[NanoLocz](https://george-r-heath.github.io/NanoLocz/). Both
are stored as 32-bit float TIFFs. Binary foreground masks are stored as CSVs.
> **Note:** Do not load the TIFFs through a standard Python image pipeline (PIL,
> imagefolder, PNG conversion) as these will quantise the 32-bit float height
> data. Use `tifffile`.
## Dataset structure
```txt
train/
Image/ raw height TIFFs train_image_0000.tiff … train_image_2000.tiff
Levelled/ reference-levelled TIFFs train_levelled_0000.tiff … train_levelled_2000.tiff
Mask/ binary foreground masks train_mask_0000.csv … train_mask_2000.csv
test/
Image/ test_image_000.tiff … test_image_163.tiff
Levelled/ test_levelled_000.tiff … test_levelled_163.tiff
Mask/ test_mask_000.csv … test_mask_163.csv
training_data_sources.csv per-image provenance for train split
test_data_sources.csv per-image provenance for test split
README.md This datacard
```
Files are paired by numeric index: `train_image_0042.tiff`, `train_levelled_0042.tiff`,
and `train_mask_0042.csv` all correspond to the same acquisition frame.
| Split | Images |
| --- | --- |
| Train | 2001 |
| Test | 164 |
| **Total** | **2165** |
Images are 32-bit float, single-channel, and range from 128×128 to 1024×1024
pixels. Some images are non-square. Z-values are in nanometres.
Images are released in their **pre-augmentation** form. The models were trained
on augmented versions of these images (×3 for MLBackground, ×5 for MLMask);
users wishing to replicate training should apply augmentation as described in
the accompanying paper.
## Loading
```python
import tifffile
# Load a paired sample
raw = tifffile.imread("train/Image/train_image_0042.tiff") # float32, nm
levelled = tifffile.imread("train/Levelled/train_levelled_0042.tiff") # float32, nm
# Iterate all training pairs
import os
for fname in sorted(os.listdir("train/Image")):
if not fname.endswith(".tiff"):
continue
idx = fname.replace("train_image_", "").replace(".tiff", "")
raw = tifffile.imread(f"train/Image/{fname}")
lev = tifffile.imread(f"train/Levelled/train_levelled_{idx}.tiff")
```
## Derived targets used during training
The model ground-truth targets are **derived from the raw and levelled images
at load time** in the training scripts, not stored separately as image files.
Both are deterministic and fully reproducible from this data plus the training
code in the afMLevel repository.
**Background model target:** the normalised difference between raw and levelled,
sharing the raw image's z-scale:
```python
import numpy as np
def xyplanefit(im, px=1, py=1):
mc = np.mean(im, axis=0); x = np.arange(len(mc))
im = im - np.polyval(np.polyfit(x, mc, px), x)[np.newaxis, :]
mr = np.mean(im, axis=1); y = np.arange(len(mr))
return im - np.polyval(np.polyfit(y, mr, py), y)[:, np.newaxis]
def normalise(im):
im = im - im.min(); return im / (im.max() + 1e-8)
raw_fit = xyplanefit(raw)
imnorm = normalise(raw_fit)
levnorm = (levelled - raw_fit.min()) / (raw_fit.max() - raw_fit.min())
background_target = imnorm - levnorm # float32
```
**Mask model target:** binary foreground mask via sigmoid → Otsu:
```python
from scipy.ndimage import gaussian_filter
from skimage.filters import threshold_otsu
slev = 1 / (1 + np.exp(-(levelled - np.mean(levelled))))
slev8 = (slev * 255).astype(np.uint8)
blur = gaussian_filter(slev8, sigma=1)
mask_target = (blur > threshold_otsu(blur)).astype(np.uint8) # binary {0, 1}
```
Both pipelines resize to 256×256 (nearest-neighbour) and min-max normalise
before training. See the
[afMLevel repository](https://github.com/mayatek1/afMLevel) for the full
training scripts.
## Provenance
Per-image source information is in `training_data_sources.csv` and
`test_data_sources.csv` (columns: `new_name`, `Source`, `Link`, `Data Reference`,
`Paper Reference`).
Images were sourced from internal acquisitions, collaborating research groups,
and previously published datasets. Data taken from published sources was already
available under CC-BY-4.0; contributing authors of unpublished data have confirmed
their agreement to release under CC-BY-4.0.
Filenames are numeric; sample identities are not disclosed for unpublished
internal data. Where images originate from published datasets they carry full
citations in the source tables.
| Contributor | Train | Test | Total |
|---|---|---|---|
| University of Leeds AFM Facility | 1106 | 68 | 1174 |
| George Heath — Scheuring Lab — New York | 465 | 46 | 511 |
| Varun Gupta — Heath Lab, University of Leeds | 210 | 21 | 231 |
| Pyne Lab — University of Sheffield | 114 | 1 | 115 |
| Nanobiomaterials Group — Paderborn University | 58 | 4 | 62 |
| Daniel E. Rollins — Heath Lab, University of Leeds | 48 | 9 | 57 |
| Abimbola Olulana — Hobbs Lab, University of Sheffield | 0 | 8 | 8 |
| BioMed AFM Summer School — Sheffield | 0 | 7 | 7 |
| **Total** | **2001** | **164** | **2165** |
### Published source datasets — please cite when using these images
**Pyne Lab — DNA supercoiling:**
Pyne et al. (2021). figshare. https://doi.org/10.6084/m9.figshare.13116890.v1
Paper: Pyne, A.L.B. et al. *Nat Commun* 12, 1053 (2021). https://doi.org/10.1038/s41467-021-21243-y
**Pyne Lab — kinetoplast DNA:**
Whittle et al. (2024). University of Sheffield. https://doi.org/10.15131/shef.data.26869993.v1
Paper: Diggines, B. et al. *Phys. Chem. Chem. Phys.* 26, 25798–25807 (2024). https://doi.org/10.1039/D4CP01795A
**Nanobiomaterials Group Paderborn — DNA origami:**
Pothineni et al. (2024). Zenodo. https://doi.org/10.5281/zenodo.14275812
Paper: Pothineni, B.K. et al. *Discover Nano* 20, 77 (2025). https://doi.org/10.1186/s11671-025-04254-2
## Important notes
**Lateral scale is intentionally omitted.** Images are released without pixel
size or scan size metadata. The models are scale-agnostic by design (inputs are
resized to 256×256 and min-max normalised). Images were exported via MATLAB and
carry no embedded acquisition metadata.
**Images are not independent.** Where images originate from HS-AFM movies,
they were capped at a maximum of 20 frames per movie to reduce over-representation
of individual acquisitions. Multiple frames from the same movie may still appear
in the dataset.
**Train/test split.** The split is defined by directory membership and
corresponds exactly to the split used to produce the results in the
accompanying paper.
## Licence
This dataset is released under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/).
All contributing groups have confirmed their agreement to this licence.
Data from published third-party datasets (Pyne Lab, Nanobiomaterials Group Paderborn)
are also available under CC-BY-4.0 via their original repositories (see links above).
The afMLevel code is BSD-3-Clause, see the
[code repository](https://github.com/mayatek1/afMLevel).
## Citation
<!-- TODO: add citation once the paper is published -->
## Links
- Code and models: <https://github.com/mayatek1/afMLevel>
- Paper: <!-- TODO -->