-
Notifications
You must be signed in to change notification settings - Fork 6
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
[FEAT] Add coarse-to-fine barycenter estimation #45
[FEAT] Add coarse-to-fine barycenter estimation #45
Conversation
… into feat_coarse_to_fine_bary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but the test could be more informative.
fine_mapping_solver_params={"nits_bcd": 2, "nits_uot": 10}, | ||
device=device, | ||
verbose=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only a smoke test ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this solely for the purpose of testing that everything runs regardless the validity of the transport plan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need also a full test ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added new shape assertions + type checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good step forward.
But we may also want to test that the estimated barycenters are not crazy. Should we consider that in another PR for sparse and non-sparse baycenters altogether ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could test edge cases (although this may require using external libraries):
- one could test that
alpha=0
returns wasserstein barycenters similar to that of POT - similarly, one could test that
alpha=1
returns gromov barycenters similar to that of POT
Fixing tests once #48 is merged. |
Cna you take care of the failing tests ? LGTM otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise.
fine_mapping_solver_params={"nits_bcd": 2, "nits_uot": 10}, | ||
device=device, | ||
verbose=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need also a full test ?
New issue #52, sometimes features contain NaNs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the homogeneous API !
The docstrings can still be improved a little bit...
fine_mapping_solver_params={"nits_bcd": 2, "nits_uot": 10}, | ||
device=device, | ||
verbose=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good step forward.
But we may also want to test that the estimated barycenters are not crazy. Should we consider that in another PR for sparse and non-sparse baycenters altogether ?
Co-authored-by: bthirion <bertrand.thirion@inria.fr>
I agree that future issues should be resolved in a new PR. I'm currently confronting the new features to real data which will bring its own set of bugs, but let's keep that separate. |
Agreed. Can you look at the failing test ? |
All fixed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx.
@alexisthual do you want to take a look ? Best, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Here are a few general comments that I think could be addressed in different PRs:
- it would be nice to add docstrings to
mappings/{barycenter,sparse_barycenter}.py
(they would appear in the documentation) - it might never be useful, but the static method
update_barycenter_geometry()
is currently missing fromFUGWSparseBarycenter
(I'm totally fine with that, as we probably don't need to learn a matrix of anatomical distances between vertices at the moment -- I think it could be useful if someone were to compute FUGW barycenters using connectomes for anatomical distances for instance)
source_sample=mesh_sample, | ||
target_sample=mesh_sample, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be wrong, but I feel that you might need different values for mesh_sample
across individuals if their data lie on different meshes. The barycenter might need its own mesh_sample
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are definitely right. However we agreed with @bthirion to keep the same geometry/mesh as for now. Moreover I'm afraid of the large memory/speed slowdown that we could get if we individualize the geometry of each individual. Maybe a NotImplementedError
would be the best fit ? I'll open an issue...
@pytest.fixture(scope="session", autouse=True) | ||
def ignore_sparse_csr_warning(): | ||
"""Remove the warning for sparse CSR tensor support.""" | ||
warnings.filterwarnings( | ||
"ignore", ".*Sparse CSR tensor support is in beta state.*" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had never used this, nice trick! :)
mask: torch.Tensor or None | ||
Sparsity mask to use when fitting the fine mapping. | ||
If None, a mask will be computed from the coarse mapping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to ignore this comment, but would rather name this variable sparsity_mask
so that it's not confused with a nilearn masker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
fine_mapping_solver_params={"nits_bcd": 2, "nits_uot": 10}, | ||
device=device, | ||
verbose=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could test edge cases (although this may require using external libraries):
- one could test that
alpha=0
returns wasserstein barycenters similar to that of POT - similarly, one could test that
alpha=1
returns gromov barycenters similar to that of POT
Implements coarse-to-fine estimation of barycenters with sparse transport plans. Closes #52