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

nipype_cmd - run any Interface from a command line #795

Merged
merged 21 commits into from
Mar 19, 2015

Conversation

chrisgorgo
Copy link
Member

nipype_cmd --help

usage: nipype_cmd [-h] module interface

Nipype interface runner

positional arguments:
  module      Module name
  interface   Interface name

optional arguments:
  -h, --help  show this help message and exit

nipype_cmd nipype.interfaces.nipy

Available Interfaces:
    SpaceTimeRealigner
    Similarity
    ComputeMask
    FitGLM
    EstimateContrast
    FmriRealign4d

nipype_cmd nipype.interfaces.nipy ComputeMask --help

usage: nipype_cmd nipype.interfaces.nipy ComputeMask [-h] [--M M] [--cc CC]
                                                     [--ignore_exception IGNORE_EXCEPTION]
                                                     [--m M]
                                                     [--reference_volume REFERENCE_VOLUME]
                                                     mean_volume

Run ComputeMask

positional arguments:
  mean_volume           mean EPI image, used to compute the threshold for the
                        mask

optional arguments:
  -h, --help            show this help message and exit
  --M M                 upper fraction of the histogram to be discarded
  --cc CC               Keep only the largest connected component
  --ignore_exception IGNORE_EXCEPTION
                        Print an error message instead of throwing an
                        exception in case the interface fails to run
  --m M                 lower fraction of the histogram to be discarded
  --reference_volume REFERENCE_VOLUME
                        reference volume used to compute the mask. If none is
                        give, the mean volume is used.

nipype_cmd nipype.interfaces.nipy ComputeMask /tmp/mean_volume.nii

brain_mask = /tmp/mean_mask.nii.gz

@chrisgorgo
Copy link
Member Author

@Garyfallidis @MrBago @oesteban This is just a proof of concept, but it should give you a general idea.

@oesteban
Copy link
Contributor

This is great :). Thanks!

@Garyfallidis
Copy link
Member

Cool, a dipy example is needed. Let us know how we can help.

@chrisgorgo
Copy link
Member Author

Cool! Pick a simple (few inputs and outputs) DWI processing step that one
can do with Dipy and try writing a Nipype interface for it.

On Tue, Feb 18, 2014 at 4:57 PM, Eleftherios Garyfallidis <
notifications@github.com> wrote:

Cool, a dipy example is needed. Let us know how we can help.


Reply to this email directly or view it on GitHubhttps://github.com//pull/795#issuecomment-35398437
.

@Garyfallidis
Copy link
Member

Hi guys, sorry for not having responded to this PR. This happened because we had to prioritize other algorithmic PRs. We need more people reviewing the Dipy PRs. There are too many and quite large often. I hope that we will start looking to this again soon.

@chrisgorgo
Copy link
Member Author

@Garyfallidis I'm gonna clean this up today. Any comments/requests?

@chrisgorgo
Copy link
Member Author

@Garyfallidis here's a dipy example:

$ bin/nipype_cmd nipype.interfaces.dipy TensorMode --help
usage: nipype_cmd nipype.interfaces.dipy TensorMode [-h]
                                                    [--out_filename OUT_FILENAME]
                                                    bvals bvecs in_file

Run TensorMode

positional arguments:
  bvals                 The input b-value text file
  bvecs                 The input b-vector text file
  in_file               The input 4D diffusion-weighted image file

optional arguments:
  -h, --help            show this help message and exit
  --out_filename OUT_FILENAME
                        The output filename for the Tensor mode image

@Garyfallidis
Copy link
Member

Hi @chrisfilo. How can I help? If I remember correctly the idea was to have a common interface in Dipy and Nipype so we can write scripts in Dipy and have them available in Nipype without having the dependency of Nipype in Dipy. Am I correct?

@chrisgorgo
Copy link
Member Author

nipype_cmd is written in a very generic way right now - it can turn any Nipype Interface into a command line script. Interfaces it operates on do not have to eve nbe part of nipype package. You could do:

nipype_cmd nipype.interfaces.dipy TensorMode

but also:

nipype_cmd dipy.interfaces TensorMode

if dipy was installed and provided Nipype Interfaces. Does this functionality help you in your use cases?

@chrisgorgo
Copy link
Member Author

Ready for review. Tests fail only on python 2.6. They will start passing after #1069 will be merged ;)

@chrisgorgo chrisgorgo changed the title WIP: nipype_cmd - run any Interface from a command line nipype_cmd - run any Interface from a command line Mar 18, 2015
@@ -37,6 +37,7 @@
saving_workflows
spmmcr
mipav
nipypecmd
Copy link
Member

Choose a reason for hiding this comment

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

this file is missing.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

On Wed, Mar 18, 2015 at 3:49 PM, Satrajit Ghosh notifications@github.com
wrote:

In doc/users/index.rst
#795 (comment):

@@ -37,6 +37,7 @@
saving_workflows
spmmcr
mipav

  • nipypecmd

this file is missing.


Reply to this email directly or view it on GitHub
https://github.com/nipy/nipype/pull/795/files#r26715700.

if hasattr(v, "mandatory") and v.mandatory:
parser.add_argument(k, help=v.desc)
else:
parser.add_argument("--%s"%k, dest=k,
Copy link
Member

Choose a reason for hiding this comment

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

do you want to add type information here from traits? then that will help reduce the code in run_instance

@satra
Copy link
Member

satra commented Mar 18, 2015

also see here:

https://github.com/nipy/nipype/blob/master/examples/fmri_ants_openfmri.py#L1042

how to add default values and types

@satra
Copy link
Member

satra commented Mar 18, 2015

it would also be sweet to add nipype memcache options to this! perhaps that's a sprint item.

chrisgorgo added a commit that referenced this pull request Mar 19, 2015
nipype_cmd - run any Interface from a command line
@chrisgorgo chrisgorgo merged commit 5e05ffe into nipy:master Mar 19, 2015
@chrisgorgo chrisgorgo deleted the enh/nipypecmd branch March 19, 2015 07:03
@chrisgorgo chrisgorgo restored the enh/nipypecmd branch April 16, 2015 22:19
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