Skip to content

Conversation

@ns-rse
Copy link
Collaborator

@ns-rse ns-rse commented Jan 8, 2026

Introduces a new additional configuration option minimum_size (default 8000) of the minimum size in nanometres
squared. Objects below this are removed/excluded by using Numpy masking.

The region properties are calculated on the whole image and also the masked subset.

Tests are included, although some of the region comparisons fail due to NotImplemented errors for some of the
regionprops attributes.

In future may consider calculating just the metric(s) that are required (at the moment I think this is actually only the
area but things like feret distances may also be useful).

Closes #54

Adds functions to mask small regions.

This is done on a per layer basis and the three dimensional arrays are iterated over producing a `numpy.ma.MaskedArray`
which holds the original values in the `.data` attribute and the points to be masked in the `.mask` attribute.
- Switches populating `masked_array()` to be pre-assigned dimensions rather than using `np.ma.stack()` as this failed
after two layers were added as the dimensions have to match and single layers therefore don't match the two stacked
layers. Probably more efficient anyway.
- Configuration value for `minimum_size` which should be in nanometres-squared to the `default_config.yaml`
- Adds the attribute `AFMSlicer.sliced_segments_clean` which holds a masked array with objects `<= minimum_size` masked.
- Region properties are calculated for all and clean
- Tests the new attribute, loading masked arrays from `tests/resources/slicer`
- Tests for region properties, these are poor though as there are some `NotImplemented` errors raised and some other
issues

TODO...

- Plotting of masked regions.
@ns-rse ns-rse force-pushed the ns-rse/54-remove-small-artefacts branch from cba5b2c to 0ec467f Compare January 8, 2026 16:18
@ns-rse ns-rse merged commit 157cc24 into main Jan 8, 2026
3 of 11 checks passed
@ns-rse ns-rse deleted the ns-rse/54-remove-small-artefacts branch January 8, 2026 16:59
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.

Remove small artefacts

1 participant