AFM-SPM / TopoStats

An AFM image analysis program to batch process data and obtain statistics from images
https://afm-spm.github.io/TopoStats/
GNU Lesser General Public License v3.0
60 stars 11 forks source link

Add basic curvature #974

Closed SylviaWhittle closed 1 day ago

SylviaWhittle commented 1 month ago

This PR adds just a basic angle-turn-per-nm metric, calculated for each molecule of each grain, linear and circular. It is super simple but extensible to meet future needs (I hope).

It will likely need tuning and maybe adding a configurable 1D gaussian filter (since curvature really changes depending on the length scale you're looking for. I've defaulted to angle per nm but maybe in future for different projects, we will want this configurable. Not adding it here yet though as I want feedback from different projects first.

Works best on high-res data!

Closes #168

SylviaWhittle commented 1 month ago

Oh also before merging, we need to discuss & solve the issue of the custom plots I've made. @MaxGamill-Sheffield will likely have a way to do this but currently it dumbly saves the images in the current directory and is just for experimentation.

The reason is that it does non-standard plotting things (multiple coloured lines etc) so can't currently be invoked using the Images class (and therefore is not part of the plotting pipeline yet).

SylviaWhittle commented 4 weeks ago

Not completely completed but would like high-level feedback before putting effort towards finalising if that's okay 😄

llwiggins commented 1 week ago

I'm wondering how much the sign of the angle difference matters, and whether it would be better to just consider the absolute magnitude for most applications? See example below, first plot is with the signed angle difference and the second is using the absolute value of the angle difference. To me, the absolute value makes it more intuitive e.g. dark red regions are highly curved, light regions are not.

Perhaps this could even be configurable if we anticipate different applications where one approach would be better than the other? 32-individual_grain_curvature_grain_19 32-individual_grain_curvature_grain_19

SylviaWhittle commented 1 week ago

I'm wondering how much the sign of the angle difference matters, and whether it would be better to just consider the absolute magnitude for most applications? See example below, first plot is with the signed angle difference and the second is using the absolute value of the angle difference. To me, the absolute value makes it more intuitive e.g. dark red regions are highly curved, light regions are not.

Perhaps this could even be configurable if we anticipate different applications where one approach would be better than the other? 32-individual_grain_curvature_grain_19 32-individual_grain_curvature_grain_19

Just asked Tom, Libby and Kinga, and they say there is no use in directional curvature. I'd be happy with adding a np.abs() for now and removing it in future if we need! I'll add that on Monday 😄

llwiggins commented 1 week ago

That sounds good to me. I really like your approach to this, and although the method itself is simple I think it will be really valuable for future projects! I agree with your comment about making the angle per nm part configurable, as I think it may show regions of high/low curvature better if we consider larger neighbourhoods around each point?? 1D gaussian would also be a neat solution for this!

SylviaWhittle commented 3 days ago

Will update regtest

SylviaWhittle commented 3 days ago

Only locally failing test now is the topology issue:

image