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

New feature: aspect ratio #1010

Closed
lidakanari opened this issue Mar 23, 2022 · 2 comments
Closed

New feature: aspect ratio #1010

lidakanari opened this issue Mar 23, 2022 · 2 comments
Assignees

Comments

@lidakanari
Copy link
Contributor

lidakanari commented Mar 23, 2022

This feature needs to be implemented on the 2D projection of a morphology and it will describe the minimum over the maximum dimension in the projected plane i.e. x-y. We will therefore need to compute this in all three projections at the morphology level.

To extract the projection points from a morphology:

def get_points_projection(neurite, projection1='X', projection2='Y'):
    proj1 = neurite.points[:, getattr(nm.COLS, projection1)]
    proj2 = neurite.points[:, getattr(nm.COLS, projection2)]
    return np.transpose([proj1, proj2])

Please find some sample code for this feature:

def aspect_ratio(pts):
    """Computes min dimension / max dimension"""
    max_dim = np.max(nm.morphmath.principal_direction_extent(pts))
    min_dim = np.min(nm.morphmath.principal_direction_extent(pts))
    return min_dim / max_dim
@lidakanari
Copy link
Contributor Author

For testing purposes here are a few shapes:

TestData.zip

The expected results for these shapes:

aspect_ratio(circle) == 0.9838348383830106
aspect_ratio(square) == 0.9799193845949096
aspect_ratio(rectangle) == 0.33658158126782983
aspect_ratio(oval) == 0.49083100011838016

@eleftherioszisis eleftherioszisis self-assigned this Mar 23, 2022
@eleftherioszisis
Copy link
Contributor

Using the convex hull points to avoid the point distribution to affect the principal directions, I get the following results:

In [4]: aspect_ratio(circle)
Out[4]: 0.9975026440270615

In [5]: aspect_ratio(square)
Out[5]: 0.9829836870510568

In [6]: aspect_ratio(rectangle)
Out[6]: 0.4130280313071019

In [7]: aspect_ratio(oval)
Out[7]: 0.493502615108013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants