Skip to content

[FIX] Define ANTSPATH for ants.BrainExtraction automatically #1986

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

Merged
merged 3 commits into from
May 3, 2017

Conversation

oesteban
Copy link
Contributor

@oesteban oesteban commented May 1, 2017

Only when it is not already defined. Also check if the interface failed for that reason nonetheless.

Fixes #1901

When it is not already defined. Also check if the interface failed
for that reason nonetheless.

Fixes nipy#1901
@oesteban oesteban requested a review from blakedewey May 1, 2017 02:36
@codecov-io
Copy link

codecov-io commented May 1, 2017

Codecov Report

Merging #1986 into master will decrease coverage by 0.02%.
The diff coverage is 10.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1986      +/-   ##
==========================================
- Coverage   72.29%   72.27%   -0.03%     
==========================================
  Files        1089     1089              
  Lines       55583    55601      +18     
  Branches     8009     8013       +4     
==========================================
+ Hits        40182    40183       +1     
- Misses      14137    14164      +27     
+ Partials     1264     1254      -10
Flag Coverage Δ
#smoketests 72.27% <10.52%> (-0.03%) ⬇️
#unittests 69.79% <10.52%> (-0.03%) ⬇️
Impacted Files Coverage Δ
nipype/interfaces/ants/segmentation.py 74.77% <10.52%> (-2.36%) ⬇️
nipype/interfaces/spm/preprocess.py 68.93% <0%> (ø) ⬆️
nipype/interfaces/spm/model.py 71.74% <0%> (ø) ⬆️
nipype/sphinxext/plot_workflow.py 13.29% <0%> (ø) ⬆️
nipype/workflows/dmri/fsl/artifacts.py 81.28% <0%> (ø) ⬆️
nipype/testing/decorators.py 66.66% <0%> (ø) ⬆️
nipype/workflows/fmri/fsl/preprocess.py 87.96% <0%> (ø) ⬆️
nipype/interfaces/fsl/base.py 84.04% <0%> (ø) ⬆️

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 d82a18f...3b78740. Read the comment docs.

@oesteban oesteban requested a review from satra May 1, 2017 17:20
(self.cmd.split()[0], runtime.hostname))

# Set the environment variable if found
runtime.environ.update({'ANTSPATH': os.path.dirname(cmd_path)})
Copy link
Member

Choose a reason for hiding this comment

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

i believe ANTSPATH requires a trailing /. could you confirm this and make sure we adjust for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the scripts don't need the trailing /. Particularly, the antsBrainExtraction.sh doesn't need it.

But I can add it anyways if you want.

Copy link
Member

Choose a reason for hiding this comment

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

then not necessary.

runtime = super(BrainExtraction, self)._run_interface(runtime)

# Still, double-check if it didn't found N4
if 'we cant find the N4 program' in runtime.stdout:
Copy link
Member

Choose a reason for hiding this comment

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

since the script can be in a different location than the N4 executable, can we not do this check before running in this particular case?

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 I'm lost here. Which check would you remove?

Copy link
Member

Choose a reason for hiding this comment

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

i meant to put the N4 check before calling _run_interface instead of checking the output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Judging from this: https://github.com/stnava/ANTs/blob/646459bf297a50cdf608ea7d39cb79b44906ad22/Scripts/antsBrainExtraction.sh#L5-L20, I think we just parse the output for "we cant find" and raise the message for the missing tool.

For next release we can decouple or, as @blakedewey suggested, replicate antsBrainExtraction in pure nipype.

@satra
Copy link
Member

satra commented May 2, 2017

in general, for next release, i would like to decouple these checks as requirements of interfaces and have a generic checker mechanism that spans local paths and container id/paths.

@oesteban
Copy link
Contributor Author

oesteban commented May 2, 2017

Sounds good. The problem here is a bit different, since it is the definition of ANTSPATH for the ANTs scripts. For next release we can have an ANTSScript to complement the ANTSCommand that takes care of the ANTSPATH with more generality.

@blakedewey
Copy link
Contributor

This looks good to me. It should cover the bases for when errors could occur. I agree that a more general solution in the future would be preferable, even recreating this script in Nipype would be a great addition as well.

Copy link
Contributor

@blakedewey blakedewey left a comment

Choose a reason for hiding this comment

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

LGTM, see my comment

@oesteban
Copy link
Contributor Author

oesteban commented May 2, 2017

+1 to adding a pure-nipype workflow for antsBrainExtraction

@oesteban
Copy link
Contributor Author

oesteban commented May 2, 2017

@satra I left a couple of questions, if you had a minute I can get this ready to merge :)

@satra satra merged commit e48c9c8 into nipy:master May 3, 2017
@oesteban oesteban deleted the fix/antsBrainExtraction-1901 branch May 3, 2017 23:17
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