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 ClosedDiscreteCurvesStartingAtOrigin #1953

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MMalikT
Copy link
Collaborator

@MMalikT MMalikT commented Feb 13, 2024

Checklist

  • My pull request has a clear and explanatory title.
  • If necessary, my code is vectorized.
  • I added appropriate unit tests.
  • I made sure the code passes all unit tests. (refer to comment below)
  • My PR follows PEP8 guidelines. (refer to comment below)
  • My PR follows geomstats coding style and API.
  • My code is properly documented and I made sure the documentation renders properly. (Link)
  • I linked to issues and PRs that are relevant to this PR.

Description

We add the ClosedDiscreteCurves class back into the discrete_curves.py file. This led to some changes in the SRV transform. More precisely, considering a closed curve, there is an additional derivative vector at the last sampling point.

The goal will be to improve the data analysis in the cancer cell notebook, incoporating the geometry of the cell being closed. @luisfpereira @alebrigant @ninamiolane.

At the moment, the implimentation is not optimal since we won't need to implement a whole new class to distinguish between closed and open curves - probably an argument in form of a boolean will suffice.

Issue

Additional context

ete_curves.py file. This class is used to represent closed discrete curves.
@MMalikT
Copy link
Collaborator Author

MMalikT commented Feb 13, 2024

Unfortunately, my description wasn't included in the PR. Sorry about that. Let me add it down here: The main contribution is to add the class ClosedDscreteCurvesStartingAtOrigin to the discrete_curves.py file. In my understanding, inthe closed curves case, the SRV transform as an extra point of information and hence I changed a little bit the SRV transform part as well to take this into account. @luisfpereira @alebrigant @ninamiolane Please let me know what you think.

@luisfpereira luisfpereira marked this pull request as draft February 13, 2024 18:08
Copy link
Collaborator

@alebrigant alebrigant left a comment

Choose a reason for hiding this comment

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

Thanks for this PR ! I think the tests are not passing so these are just preliminary comments, waiting for other modifs to make the tests pass.

A general comment on the structure: maybe it would be best to have 3 classes: OpenDiscreteCurvesStartingAtOrigin and ClosedDiscreteCurvesStartingAtOrigin and DiscreteCurvesSartingAtOrigin would call one or the other depending on the attribute self.closed ? It also seems unnecessary to copy a big portion of the code of open curves into the class of closed curves, maybe there should be some inheritance there. What do you think @luisfpereira ? In any case, there is still some work to make the tests pass !

self._quotient_map = {
(SRVMetric, "rotations"): (
SRVRotationBundle,
SRVRotationQuotientMetric,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is no longer the right way to define the quotient maps, I believe we no longer have new classes for each quotient metric. See how it is defined for (open) discrete curves.

@@ -204,6 +223,7 @@ class DiscreteCurvesStartingAtOrigin(NFoldManifold):

def __init__(self, ambient_dim=2, k_sampling_points=10, equip=True):
ambient_manifold = Euclidean(ambient_dim)
self.closed = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be used to call ClosedDiscreteCurvesStartingAtOrigin if True ?

point = self._sphere.metric.geodesic(
initial_point, initial_tangent_vec=initial_tangent_vec
)(sampling_times)
return self.projection(point)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this really generate a curve that "looks" closed ? It seems like this is the same code as the one used for open curves.

if self.space.closed:
base_point_with_origin = insert_starting_point_at_end(
base_point_with_origin
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this increases the number of sampling points of one, you may need to change some normalizations constants that depend on this number of sampling points.


dt = 1 / (self.k_sampling_points - 1)
image_point_norm = self.space.ambient_manifold.metric.norm(image_point)
dt = 1 / (self.space.k_sampling_points - 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might need to be updated, see previous comment.

@luisfpereira luisfpereira changed the title Adding the ClosedDiscreteCurves class to the discr Add ClosedDiscreteCurvesStartingAtOrigin Mar 26, 2024
@luisfpereira
Copy link
Collaborator

@MMalikT, I've done some changes in the PR, to make everything consistent, though the results are disappointing (i.e. curves open when taking geodesics). In particular:

  • I've changed the representation of closed curves to be of shape (k_sampling_points - 2, ambient_dim). As I state in the docstrings, this is done because with this representation delta = 1 / (k_sampling_points - 1) is valid (both for open and closed curves)

  • I've fixed small things in SRV to ensure we recover the same points and tangent vectors after using e.g. inverse_diffeo after diffeo

Please let me know what you think.

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.

None yet

3 participants