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

[ENH] Added RUMBA-SD to data.py #1129

Merged
merged 11 commits into from
Apr 23, 2024
Merged

Conversation

@pep8speaks
Copy link

pep8speaks commented Apr 17, 2024

Hello @chiuhoward! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

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

Comment last updated at 2024-04-23 20:11:56 UTC

AFQ/tasks/data.py Outdated Show resolved Hide resolved
@36000
Copy link
Collaborator

36000 commented Apr 17, 2024

Maybe we could break this up into several tasks. One would be rumba_fit which returns rumba_fit. Another would be rumba_params and that can return the shm params (so this would involve running rumba_fit.odf then extract_odf). then more could be rumba_f_wm, rumba_f_gm, etc... and these functions are one-liners that accept the rumba_fit and return that tissue property. These functions would have a similar structure to dti_ga

AFQ/tasks/data.py Outdated Show resolved Hide resolved
AFQ/tasks/data.py Outdated Show resolved Hide resolved
@36000 36000 changed the title [WIP ENH] Added RUMBA-SD to data.py [ENH] Added RUMBA-SD to data.py Apr 22, 2024
@36000
Copy link
Collaborator

36000 commented Apr 23, 2024

@arokem this is ready for review/merge

Copy link
Collaborator

@arokem arokem left a comment

Choose a reason for hiding this comment

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

A few suggestions, mostly related to documentation, but also about BIDS file naming.

AFQ/tasks/data.py Show resolved Hide resolved
@as_file(suffix='_odfmodel-RUMBA_desc-diffmodel_dwi.nii.gz')
@as_img
def rumba_params(rumba_model, data, brain_mask):
"""RUMBA SHM Parameters"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"""RUMBA SHM Parameters"""
"""Fits the RUMBA SD model. """

Would be good to finish this docstring, including a "Parameters" and a "Returns" sections.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@36000 would this docstring work? I don’t think there’s much room for user configuration in this function, and I’m not too sure what meta does… took a stab at defining what the function returns by looking at QBallTP.py

"""
Takes the fitted RUMBA-SD model as input and returns the spherical harmonics coefficients (SHM).

 Parameters
 ----------
 rumba_fit: use output from rumba_fit as input for rumba_params

 Returns
 ----------
 rumba_shm: spherical harmonics coefficients from an ODF without the isotropic and anisotropic diffusion components

 """

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 a part of the task system so we typically only have parameters when theres user input via named arguments, as you point out Howard. We also typically don't have returns because we usually just describe it in the main docstring. These task functions are all only called by pimms. So I think we could do something like this is good:

Takes the fitted RUMBA-SD model as input and returns the spherical harmonics coefficients (SHM).



@pimms.calc("rumba_f_csf")
@as_file(suffix='_odfmodel-RUMBA_desc-CSF_dwi.nii.gz')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arokem if i’m understanding the docs correctly, each filename can only have one suffix after all of the keyword-value pairs, so the correct name would then be

@as_file(suffix='_odfmodel-RUMBA_desc-CSF_probseg.nii.gz’)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thats correct @chiuhoward !

Copy link
Collaborator

Choose a reason for hiding this comment

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

@36000 : How do you more generally feel about using probseg as a suffix here? Is it inconsistent with our usage elsewhere?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think its correct! I just use dwi when I don't have anything else to put.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So probseg is better here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry one last question @36000, probseg should be the suffix not just for @pimms.calc("rumba_f_gm”) but also for @pimms.calc("rumba_f_csf”), @pimms.calc("rumba_f_wm”) and @pimms.calc("rumba_params”)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

just for rumba_f_gm, rumba_f_csf, rumba_f_wm

AFQ/tasks/data.py Outdated Show resolved Hide resolved
@chiuhoward
Copy link
Contributor Author

I think I addressed all of the changes and did the new merge correctly? =s @36000 @arokem

@36000
Copy link
Collaborator

36000 commented Apr 23, 2024

LGTM, Ariel?

Copy link
Collaborator

@arokem arokem left a comment

Choose a reason for hiding this comment

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

I think some other code got pulled into this PR from other PRs. Could you try merging from master? Also, I spotted one more small thing:

@@ -4,6 4,8 @@

from dipy.io.gradients import read_bvals_bvecs
import dipy.core.gradients as dpg
from dipy.data import default_sphere
from dipy.data import default_sphere
Copy link
Collaborator

Choose a reason for hiding this comment

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

Duplicate import

Suggested change
from dipy.data import default_sphere

@36000
Copy link
Collaborator

36000 commented Apr 23, 2024

Actually, now that I look at this, this also removed the refactoring I did so that we could use the SHM from disk from previous runs. Let me see If I can do this merge

@36000
Copy link
Collaborator

36000 commented Apr 23, 2024

I think this should be good to go! @chiuhoward look it over and make sure i didnt delete any changes u made recently.

@chiuhoward
Copy link
Contributor Author

@36000 looks good! suffixes and docstrings were all that I changed and they’re there

@36000
Copy link
Collaborator

36000 commented Apr 23, 2024

OK, once the docs finish I will merge, unless @arokem has any more comments. overall, good work everyone!

@arokem
Copy link
Collaborator

arokem commented Apr 23, 2024

Yeah - looks great! When you get a chance, maybe you can write a PR that has an example? @36000 showed me some really impressive tissue type maps from this model using the Stanford HARDI dataset. Might be nice to show slices from these as part of that.

@36000 36000 merged commit be7b575 into yeatmanlab:master Apr 23, 2024
9 checks passed
@chiuhoward chiuhoward deleted the enh/rumba-sd branch April 23, 2024 22:59
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