Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic curvature #974

Merged
merged 84 commits into from
Nov 21, 2024
Merged

Add basic curvature #974

merged 84 commits into from
Nov 21, 2024

Conversation

SylviaWhittle
Copy link
Collaborator

@SylviaWhittle SylviaWhittle commented Oct 20, 2024

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

@llwiggins
Copy link
Collaborator

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
Copy link
Collaborator Author

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
Copy link
Collaborator

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!

@MaxGamill-Sheffield MaxGamill-Sheffield linked an issue Nov 13, 2024 that may be closed by this pull request
@SylviaWhittle
Copy link
Collaborator Author

Will update regtest

@SylviaWhittle
Copy link
Collaborator Author

SylviaWhittle commented Nov 19, 2024

Only locally failing test now is the topology issue:

image

@ns-rse ns-rse added the v2.3.0 label Nov 19, 2024
False, # Nodestats
False, # Ordered tracing
False, # Splining
False, # Curvature
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should have a test that checks if the Curvature option is True which would require all prior steps?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this? (New commits)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b368847 checks everything upto Splining is disabled and Curvature is disabled and others tests check that output of curvature are produced if enabled.

Copy link
Collaborator

@ns-rse ns-rse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a couple of minor comments in-line.

I've added issues so I don't forget to include this and splinning into the entry points (#1009 and #1010) and have an issue to document how to do this when further modules are added.

Copy link
Collaborator

@llwiggins llwiggins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! I think the change to using the absolute value rather than directional works really well and emphasises areas of high curvature better for users, particularly in the curvature plot that is output where it is harder to see local curvature changes.

Happy for this to be merged 👍

…s is disabled and all preceding steps are enabled
@SylviaWhittle SylviaWhittle added this pull request to the merge queue Nov 21, 2024
Merged via the queue into main with commit 42a764e Nov 21, 2024
11 checks passed
@SylviaWhittle SylviaWhittle deleted the SylviaWhittle/curvature branch November 21, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Future Milestones Merge curvature calculations into dev
3 participants