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] Update mrtrix reconst.py EstimateFOD max_sh to be able to accept list #2990

Merged
merged 5 commits into from Aug 17, 2019

Conversation

lucindasisk
Copy link
Contributor

@lucindasisk lucindasisk commented Aug 6, 2019

Summary

Change max_sh in EstimateFOD to InputMultiObject, so that one can pass a list of lmax values when using a multishell model; followed format of lmax variable from ResponseSD.

Fixes # .

List of changes proposed in this PR (pull-request)

  • Import InputMultiObject from ..base
  • Change format of EstimateFOD to InputMultiObject so one can input a list of lmax values

Acknowledgment

  • (Mandatory) I acknowledge that this contribution will be available under the Apache 2 license.

Change max_sh  to InputMultiObject, so that one can pass a list of lmax values when using a multishell model.
@effigies
Copy link
Member

effigies commented Aug 7, 2019

Hi @lucindasisk, thanks for the contribution!

It looks like the tests are failing. If we check one, we see:

        for key, metadata in list(input_map.items()):
            for metakey, value in list(metadata.items()):
>               assert getattr(inputs.traits()[key], metakey) == value
E               AssertionError: assert '-lmax %s' == '-lmax %d'
E                 - -lmax %s
E                 ?        ^
E                 + -lmax %d
E                 ?        ^

/home/travis/build/nipy/nipype/nipype/interfaces/mrtrix3/tests/test_auto_EstimateFOD.py:95: AssertionError

This is an auto-test, which exists to make sure that the the specifications don't change unintentionally, and it's detected that you changed the argstr from '-lmax %d' to '-lmax %s'. These can be updated with make specs when the change is intentional.

But first, did you check whether it was okay to keep it as %d? I'm not positive of whether we need to switch to %s to handle lists.

Once you're satisfied that the argstr is correct, go ahead and run make specs, and that will fix the test failure.


Second, it might be useful for users to see the use of a multiple max_shs. Could you add a second example to the doctest demonstrating the use of multi-shell response? These examples are also tested, so it will make sure the command line looks as expected.

class EstimateFOD(MRTrix3Base):
"""
Estimate fibre orientation distributions from diffusion data using spherical deconvolution
Example
-------
>>> import nipype.interfaces.mrtrix3 as mrt
>>> fod = mrt.EstimateFOD()
>>> fod.inputs.algorithm = 'csd'
>>> fod.inputs.in_file = 'dwi.mif'
>>> fod.inputs.wm_txt = 'wm.txt'
>>> fod.inputs.grad_fsl = ('bvecs', 'bvals')
>>> fod.cmdline # doctest: +ELLIPSIS
'dwi2fod -fslgrad bvecs bvals -lmax 8 csd dwi.mif wm.txt wm.mif gm.mif csf.mif'
>>> fod.run() # doctest: +SKIP
"""

Thanks again for the contribution, and feel free to ask questions if anything's unclear.

@lucindasisk
Copy link
Contributor Author

lucindasisk commented Aug 12, 2019 via email

@effigies
Copy link
Member

Hi @lucindasisk. We can update this PR, rather than open a new one.

I assume you have your branch of nipype cloned, but if not:

git clone git@github.com:lucindasisk/nipype.git
cd nipype

From here, you can add commits to this branch:

git checkout patch-1
git fetch origin
git checkout origin/master nipype/interfaces/mrtrix3/reconst.py
git commit -m 'Revert argstr to use %d'

You will also need to run make specs to fix the test:

make specs
git commit -m 'make specs'

Then you can push back to this PR:

git push patch-1

@codecov
Copy link

codecov bot commented Aug 13, 2019

Codecov Report

Merging #2990 into master will decrease coverage by 0.53%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2990      +/-   ##
==========================================
- Coverage   67.59%   67.06%   -0.54%     
==========================================
  Files         344      343       -1     
  Lines       43796    43778      -18     
  Branches     5476     5473       -3     
==========================================
- Hits        29606    29360     -246     
- Misses      13473    13685     +212     
- Partials      717      733      +16
Flag Coverage Δ
#smoketests 50.19% <ø> (ø) ⬆️
#unittests 64.24% <100%> (-0.8%) ⬇️
Impacted Files Coverage Δ
nipype/interfaces/mrtrix3/reconst.py 79.59% <100%> (ø) ⬆️
nipype/interfaces/nilearn.py 40% <0%> (-56.67%) ⬇️
nipype/testing/fixtures.py 77.33% <0%> (-21.34%) ⬇️
nipype/interfaces/freesurfer/base.py 61.01% <0%> (-19.5%) ⬇️
nipype/workflows/smri/freesurfer/autorecon2.py 65.9% <0%> (-9.2%) ⬇️
nipype/interfaces/ants/base.py 63.82% <0%> (-8.52%) ⬇️
nipype/workflows/smri/freesurfer/ba_maps.py 91.66% <0%> (-8.34%) ⬇️
nipype/workflows/smri/freesurfer/recon.py 66.66% <0%> (-7.81%) ⬇️
nipype/workflows/smri/freesurfer/autorecon3.py 68.4% <0%> (-6.95%) ⬇️
nipype/workflows/smri/freesurfer/autorecon1.py 41.66% <0%> (-5.1%) ⬇️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01a2772...26bf3af. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 13, 2019

Codecov Report

Merging #2990 into master will decrease coverage by 0.78%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2990      +/-   ##
==========================================
- Coverage   67.59%   66.81%   -0.79%     
==========================================
  Files         344      343       -1     
  Lines       43796    44567     +771     
  Branches     5476     5551      +75     
==========================================
+ Hits        29606    29777     +171     
- Misses      13473    13995     +522     
- Partials      717      795      +78
Flag Coverage Δ
#smoketests 50.19% <ø> (ø) ⬆️
#unittests 64.16% <100%> (-0.88%) ⬇️
Impacted Files Coverage Δ
nipype/interfaces/mrtrix3/reconst.py 79.59% <100%> (ø) ⬆️
nipype/interfaces/nilearn.py 40% <0%> (-56.67%) ⬇️
nipype/testing/fixtures.py 77.33% <0%> (-21.34%) ⬇️
nipype/interfaces/freesurfer/base.py 61.01% <0%> (-19.5%) ⬇️
nipype/utils/nipype2boutiques.py 52.23% <0%> (-14.68%) ⬇️
nipype/interfaces/ants/base.py 61.7% <0%> (-10.64%) ⬇️
nipype/workflows/smri/freesurfer/autorecon2.py 65.9% <0%> (-9.2%) ⬇️
nipype/workflows/smri/freesurfer/ba_maps.py 91.66% <0%> (-8.34%) ⬇️
nipype/pipeline/engine/utils.py 72.14% <0%> (-8%) ⬇️
nipype/workflows/smri/freesurfer/recon.py 66.66% <0%> (-7.81%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01a2772...3b1b62a. Read the comment docs.

@lucindasisk
Copy link
Contributor Author

lucindasisk commented Aug 13, 2019 via email

@effigies
Copy link
Member

Hi @lucindasisk, sorry I gave you the wrong advice on make specs. Try:

make specs
git add nipype/interfaces/mrtrix3/tests/test_auto_EstimateFOD.py
git commit -m 'TEST: Update EstimateFOD autotest'
git push

That should be all we need to finish up this one.

Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

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

LGTM. Will merge when tests pass.

Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

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

From the tests:

TypeError: %d format: a number is required, not str

Looks like we do need %s after all. Sorry about all the run-around. You should be able to add these two suggestions to a batch and commit them in one go from your browser. See Applying suggested changes. Otherwise, feel free to make the changes locally (and make specs) and push.

nipype/interfaces/mrtrix3/reconst.py Outdated Show resolved Hide resolved
nipype/interfaces/mrtrix3/tests/test_auto_EstimateFOD.py Outdated Show resolved Hide resolved
@effigies
Copy link
Member

Hi @lucindasisk. Sorry to bug you again today, but just to let you know I'm targeting Monday for a release, and this would be good to get in if you have time.

@lucindasisk
Copy link
Contributor Author

lucindasisk commented Aug 17, 2019 via email

lucindasisk and others added 2 commits August 16, 2019 21:40
Co-Authored-By: Chris Markiewicz <effigies@gmail.com>
Co-Authored-By: Chris Markiewicz <effigies@gmail.com>
@effigies
Copy link
Member

Thanks! And please feel free to add yourself to the .zenodo.json file. This will list you as a contributor on our Zenodo releases.

@effigies
Copy link
Member

Thanks very much!

@effigies effigies merged commit ea2243c into nipy:master Aug 17, 2019
@effigies effigies added this to the 1.2.1 milestone Aug 17, 2019
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

2 participants