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

orthogonalize AP/PD src/sink edges #377

Open
wants to merge 4 commits into
base: dev-v2.0.0
Choose a base branch
from
Open

Conversation

jordandekraker
Copy link
Collaborator

This approach continues with the distance transform logic introduced by #371, and closes #373.

We want to ensure that all edge vertices are assigned to an AP or PD source or sink (4 possible labels), without overlapping or missing any vertices (I will call this orthogonal edge conditions). Otherwise we can end up with "corners" that are entire missing from the unfolded space, or other funny distortions in the unfolding.

Here, we introduce a new script to fix this up:

  • we move the application of signed distance transforms out of the laplace-beltrami solver rule and into its own rule, where we jointly solve AP and PD edges
  • instead of iteratively increasing distances to add vertices, we treat the distances as probabilities for one of these 4 labels and take the maxprob
  • in some cases we will still not have min_terminal_vertices>5. In these cases, we gradually increase the distance scaling factor from that label until min_terminal_vertices is reached.
  • we get to keep parallelization of laplace-betrami. AP and PD edges do have to be processed jointly though, to ensure they are orthogonal. We also get to toss out a bunch of complicated functions

we also now apply largest connected component to finding boundary vertices to prevent issues with holes

TODO:

  • we could still ensure conncomp in addition to min_terminal_vertices, but i don't think its necessary
  • parameter to adjust distance scaling factor stepsize?

@jordandekraker jordandekraker changed the title orthogonalize AP/PD srs/cink edges orthogonalize AP/PD src/sink edges Feb 18, 2025
@akhanf
Copy link
Member

akhanf commented Feb 19, 2025

nice, will give it a try!

@jordandekraker
Copy link
Collaborator Author

sorry still WIP - some formatting bugs to fix! hopefully push an update in a few hours

@jordandekraker
Copy link
Collaborator Author

should be working now, and I also managed to speed up the laplace-beltrami solver by replacing a for loop with a vectorized approach (I noticed from the logger that just setting the boundary conditions was taking a while)

Adds a check and raises an exception if any of src/sink is zero.
Also writes a proper label gifti (was missing the label table), and
refactored that in a write function. NOTE: still need to set the
structure label..
@akhanf
Copy link
Member

akhanf commented Feb 22, 2025

might need a bit more tweaks for robustness to ensure the counts are at least 1 vertex, as this fails now for the ds002168 dataset that I had working correctly before.. Haven't had a chance to look at that fix yet, but made some cosmetic changes just now..

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.

2 participants