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 SH basis legacy support #921

Merged
merged 20 commits into from
Mar 1, 2024

Conversation

karanphil
Copy link
Contributor

@karanphil karanphil commented Feb 23, 2024

Quick description

I added the legacy option for SH basis to all scripts, except scil_qball_metrics.py which do not have the legacy support from Dipy. I did a PR in Dipy, but in the meantime we could convert the SH basis on our end, or just not support anything else than legacy=True (the default in Dipy) for this script. In summary, the peaks_from_model function from dipy.direction.peaks does not have a legacy option for the moment, so we are stuck with the default legacy option (True) for scil_qball_metrics.py.

This resulted in the creation of an interpret_sh_basis function to io.utils, which extracts the SH basis name and the legacy option from the sh_basis argument. The scil_sh_convert.py script changed the most, as it now requires two choices from the sh_basis argument.

...

Type of change

Check the relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Provide data, screenshots, command line to test (if relevant)

...

Checklist

  • My code follows the style guidelines of this project (run autopep8)
  • I added relevant citations to scripts, modules and functions docstrings and descriptions
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I moved all functions from the script file (except the argparser and main) to scilpy modules
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@pep8speaks
Copy link

pep8speaks commented Feb 23, 2024

Hello @karanphil, Thank you for updating !

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-03-01 01:16:16 UTC

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Attention: Patch coverage is 96.15385% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 69.37%. Comparing base (1c3029a) to head (1bb9898).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #921      +/-   ##
==========================================
+ Coverage   69.27%   69.37%   +0.10%     
==========================================
  Files         389      389              
  Lines       20980    20997      +17     
  Branches     3239     3231       -8     
==========================================
+ Hits        14533    14566      +33     
+ Misses       5122     5115       -7     
+ Partials     1325     1316       -9     
Components Coverage Δ
Scripts 71.79% <97.22%> (+0.09%) ⬆️
Library 65.25% <95.23%> (+0.11%) ⬆️

Copy link
Contributor

@CHrlS98 CHrlS98 left a comment

Choose a reason for hiding this comment

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

I mostly focussed on the utilities, and quickly went through the scripts (did not go through everything). Here are my comments.

scilpy/io/utils.py Outdated Show resolved Hide resolved
scilpy/io/utils.py Outdated Show resolved Hide resolved
is_legacy : bool
Whether or not the SH basis is in its legacy form.
"""
if len(args.sh_basis) == 2:
Copy link
Contributor

Choose a reason for hiding this comment

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

it works but you could also simply do

 basis = 'descoteaux07' if 'descoteaux07' in sh_basis_name else 'tournier07'
 legacy = 'legacy' in sh_basis_name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes but I prefer the more "general" way, without assuming descoteaux07 or tournier07. @arnaudbore ? I think Charles refers to lines 313 to 316 and 319 to 320.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would agree with you if we were not using choices in add_sh_basis_args where we are already assuming descoteaux07 and tournier07. I would go for @CHrlS98 suggestion more elegant 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it better now?

Copy link
Contributor

Choose a reason for hiding this comment

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

cool

@@ -46,12 +46,14 @@ def _honor_authorsnames_sh_basis(sh_basis_type):
return sh_basis


def get_b_matrix(order, sphere, sh_basis_type, return_all=False):
def get_b_matrix(order, sphere, sh_basis_type, return_all=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think we actually need this function anymore, it just calls DIPY's method, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought the same thing... @arnaudbore ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you show me what it will look like ? It seems that get_b_matrix is doing a little bit more than one call to DIPY's method.

Copy link
Contributor

@arnaudbore arnaudbore left a comment

Choose a reason for hiding this comment

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

A couple of things to correct related to @CHrlS98 comments apart from that almost LGTM 😃

is_legacy : bool
Whether or not the SH basis is in its legacy form.
"""
if len(args.sh_basis) == 2:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would agree with you if we were not using choices in add_sh_basis_args where we are already assuming descoteaux07 and tournier07. I would go for @CHrlS98 suggestion more elegant 👍

@@ -46,12 +46,14 @@ def _honor_authorsnames_sh_basis(sh_basis_type):
return sh_basis


def get_b_matrix(order, sphere, sh_basis_type, return_all=False):
def get_b_matrix(order, sphere, sh_basis_type, return_all=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you show me what it will look like ? It seems that get_b_matrix is doing a little bit more than one call to DIPY's method.

scripts/scil_dwi_to_sh.py Outdated Show resolved Hide resolved
scripts/scil_sh_convert.py Show resolved Hide resolved
Copy link
Contributor

@arnaudbore arnaudbore left a comment

Choose a reason for hiding this comment

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

GTG

Copy link
Contributor

@CHrlS98 CHrlS98 left a comment

Choose a reason for hiding this comment

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

C'est bin beau

is_legacy : bool
Whether or not the SH basis is in its legacy form.
"""
if len(args.sh_basis) == 2:
Copy link
Contributor

Choose a reason for hiding this comment

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

cool

@arnaudbore arnaudbore merged commit d319ad2 into scilus:master Mar 1, 2024
2 checks passed
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.

4 participants