Skip to content

Conversation

@ns-rse
Copy link
Collaborator

@ns-rse ns-rse commented Feb 6, 2026

Using class inheritance from topostats.filter.Filters() we introduce SlicingFilter class which takes as input a
TopoStats object and performs filtering/flattening on the image.

The following methods from TopoStats are used...

  • Median flattening.
  • Tilt removal.
  • Quadratic removal.
  • Nonlinear polynomial removal.
  • Scar removal (optional).
  • Zero average background.
  • Gaussian filtering.

Regression tests are in place that use syrupy and these have been setup as
parameterised tests so we can easily add in actual examples once we have some small files on which to base the tests.

This required a refactoring of some code because we want/need to instantiate an AFMSlicer object before we apply
Filter to it, which takes as input AFMSlicer child class which inherits from topostats.classes.TopoStats.

We can't therefore slice the image before we have done this which was the way AFMSlicer.__post_init__() performed.

With this pull request we split out setting attributes when creating the class and introduce another method that
performs the slicing of the class so that we can first filter/flatten the image.

Other things...

  • Remove masking parameters in default_config.yaml that are carried over from TopoStats.
  • .pylintrc > .pylint.toml and update .pre-commit-config.yaml

ns-rse and others added 4 commits February 6, 2026 10:04
Using class inheritance from `topostats.filter.Filters()` we introduce `SlicingFilter` class which takes as input a
`TopoStats` object and performs filtering/flattening on the image.

The following methods from TopoStats are used...

- Median flattening.
- Tilt removal.
- Quadratic removal.
- Nonlinear polynomial removal.
- Scar removal (optional).
- Zero average background.
- Gaussian filtering.

Regression tests are in place that use [syrupy](https://syrupy-project.github.io/syrupy/) and these have been setup as
parameterised tests so we can easily add in actual examples once we have some small files on which to base the tests.

Other things...

- Remove masking parameters in `default_config.yaml` that are carried over from `TopoStats`.
- `.pylintrc` > `.pylint.toml` and update `.pre-commit-config.yaml`
We want/need to instantiate an `AFMSlicer` object before we apply `Filter` to it, which takes as input `AFMSlicer` child
class which inherits from `topostats.classes.TopoStats`.

We can't therefore slice the image before we have done this which was the way `AFMSlicer.__post_init__()` performed.

With this pull request we split out setting attributes when creating the class and introduce another method that
performs the slicing of the class so that we can first filter/flatten the image.
With recent changes to TopoStats that have refactored and been merged we need to install from `main` branch (for now,
this will change when a new TopoStats version is released).
@ns-rse ns-rse merged commit f284c30 into main Feb 6, 2026
7 of 10 checks passed
@ns-rse ns-rse deleted the ns-rse/61-topostats-flattening branch February 6, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant