internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: nipy/nipype

Issue:
ants.Registration() inputs problem
having updated to the latest nipype, ants.Registration is no longer working for me. I get the following error:

> ValueError: Registration requires a value for input 'invert_initial_moving_transform' because one of 
> initial_moving_transform is set. For a list of required inputs, see Registration.help()

however, when I set ‘invert_initial_moving_transform=True I get:

> IOError: Input "invert_initial_moving_transform" is mutually exclusive with input
> "initial_moving_transform_com", which is already set

and if I set it to false, I get the same error as if it were not set at all



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/ants/registration.py b/nipype/interfaces/ants/registration.py
--- a/nipype/interfaces/ants/registration.py
+++ b/nipype/interfaces/ants/registration.py
@@ -234,8 +234,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
 
     initial_moving_transform = File(argstr='%s', exists=True, desc='',
                                     xor=['initial_moving_transform_com'])
-    invert_initial_moving_transform = traits.Bool(
-        default=False, requires=["initial_moving_transform"], usedefault=True,
+    invert_initial_moving_transform = traits.Bool(requires=["initial_moving_transform"],
         desc='', xor=['initial_moving_transform_com'])
 
     initial_moving_transform_com = traits.Enum(0, 1, 2, argstr='%s',


Test patch:
diff --git a/nipype/interfaces/ants/tests/test_auto_Registration.py b/nipype/interfaces/ants/tests/test_auto_Registration.py
--- a/nipype/interfaces/ants/tests/test_auto_Registration.py
+++ b/nipype/interfaces/ants/tests/test_auto_Registration.py
@@ -44,7 +44,6 @@ def test_Registration_inputs():
     ),
     interpolation_parameters=dict(),
     invert_initial_moving_transform=dict(requires=['initial_moving_transform'],
-    usedefault=True,
     xor=['initial_moving_transform_com'],
     ),
     metric=dict(mandatory=True,
Repository: nipy/nipype

Issue:
[BUG] Build documentation fails if dipy is not installed



Discussion:
it seems to be passing on readthedocs . can you tell us where it fails?


Resolving patch:
diff --git a/nipype/interfaces/dipy/base.py b/nipype/interfaces/dipy/base.py
--- a/nipype/interfaces/dipy/base.py
+++ b/nipype/interfaces/dipy/base.py
@@ -36,7 +36,7 @@ class DipyBaseInterface(BaseInterface):
     """
     def __init__(self, **inputs):
         if no_dipy():
-            IFLOGGER.error('dipy was not found')
+            IFLOGGER.warn('dipy was not found')
             # raise ImportError('dipy was not found')
         super(DipyBaseInterface, self).__init__(**inputs)
 


Test patch:
Repository: nipy/nipype

Issue:
'mm' option in cluster interface does not seem to work
Hi all,

I'm having an issue with the Cluster interface to output coordinates in mm instead of voxel coordinates.

```
# Running cluster to extract p-values:
cl = fsl.Cluster()
cl.inputs.threshold = .95
cl.inputs.in_file = curPFile
cl.inputs.out_localmax_txt_file = curContrName + '_p.txt'
cl.inputs.use_mm = True # this doesn't seem to work
res = cl.run()
```

The following is the output of **print cl.cmdline** command:

> cluster --in=/home/egor/Dropbox/Projects/md/dti/results_2016-08-13/tbss12-bal/tbss_FA_comp12_tfce_corrp_tstat3.nii.gz --olmax=tbss_FA_comp12_tstat3_p.txt --thresh=0.9500000000

Running an equivalent command (with the --mm option) from the Terminal does the trick.

Thanks!
--Egor



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py
--- a/nipype/interfaces/fsl/model.py
+++ b/nipype/interfaces/fsl/model.py
@@ -1603,15 +1603,17 @@ class ClusterInputSpec(FSLCommandInputSpec):
                         desc='number of voxels in the mask')
     dlh = traits.Float(argstr='--dlh=%.10f',
                        desc='smoothness estimate = sqrt(det(Lambda))')
-    fractional = traits.Bool('--fractional',
+    fractional = traits.Bool(False, usedefault=True, argstr='--fractional',
                              desc='interprets the threshold as a fraction of the robust range')
     connectivity = traits.Int(argstr='--connectivity=%d',
                               desc='the connectivity of voxels (default 26)')
-    use_mm = traits.Bool('--mm', desc='use mm, not voxel, coordinates')
-    find_min = traits.Bool('--min', desc='find minima instead of maxima')
-    no_table = traits.Bool(
-        '--no_table', desc='suppresses printing of the table info')
-    minclustersize = traits.Bool(argstr='--minclustersize',
+    use_mm = traits.Bool(False, usedefault=True, argstr='--mm',
+                         desc='use mm, not voxel, coordinates')
+    find_min = traits.Bool(False, usedefault=True, argstr='--min',
+                           desc='find minima instead of maxima')
+    no_table = traits.Bool(False, usedefault=True, argstr='--no_table',
+                           desc='suppresses printing of the table info')
+    minclustersize = traits.Bool(False, usedefault=True, argstr='--minclustersize',
                                  desc='prints out minimum significant cluster size')
     xfm_file = File(argstr='--xfm=%s',
                     desc='filename for Linear: input->standard-space transform. Non-linear: input->highres transform')
@@ -1644,8 +1646,9 @@ class Cluster(FSLCommand):
     >>> cl.inputs.threshold = 2.3
     >>> cl.inputs.in_file = 'zstat1.nii.gz'
     >>> cl.inputs.out_localmax_txt_file = 'stats.txt'
+    >>> cl.inputs.use_mm = True
     >>> cl.cmdline
-    'cluster --in=zstat1.nii.gz --olmax=stats.txt --thresh=2.3000000000'
+    'cluster --in=zstat1.nii.gz --olmax=stats.txt --thresh=2.3000000000 --mm'
 
     """
     input_spec = ClusterInputSpec


Test patch:
Repository: nipy/nipype

Issue:
Fixing freesurfer utils MRIsConvert
In nipype/interfaces/freesurfer/utils.py

line 854 should be fixed to actually include the .asc datatype, by substituting:

```
out_datatype = traits.Enum("ico", "tri", "stl", "vtk", "gii", "mgh", "mgz",
```

with:

```
out_datatype = traits.Enum("asc", "ico", "tri", "stl", "vtk", "gii", "mgh", "mgz",
```

Otherwise "asc" format is not supported.

Thank you!



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/freesurfer/utils.py b/nipype/interfaces/freesurfer/utils.py
--- a/nipype/interfaces/freesurfer/utils.py
+++ b/nipype/interfaces/freesurfer/utils.py
@@ -851,7 +851,7 @@ class MRIsConvertInputSpec(FSTraitedSpec):
                     xor=['out_datatype'], mandatory=True,
                     desc='output filename or True to generate one')
 
-    out_datatype = traits.Enum("ico", "tri", "stl", "vtk", "gii", "mgh", "mgz",
+    out_datatype = traits.Enum("asc", "ico", "tri", "stl", "vtk", "gii", "mgh", "mgz",
                                xor=['out_file'], mandatory=True,
                                desc="These file formats are supported:  ASCII:       .asc"
                                "ICO: .ico, .tri GEO: .geo STL: .stl VTK: .vtk GIFTI: .gii MGH surface-encoded 'volume': .mgh, .mgz")


Test patch:
diff --git a/nipype/interfaces/fsl/tests/test_auto_AvScale.py b/nipype/interfaces/fsl/tests/test_auto_AvScale.py
--- a/nipype/interfaces/fsl/tests/test_auto_AvScale.py
+++ b/nipype/interfaces/fsl/tests/test_auto_AvScale.py
@@ -17,7 +17,6 @@ def test_AvScale_inputs():
     mat_file=dict(argstr='%s',
     position=-2,
     ),
-    output_type=dict(),
     ref_file=dict(argstr='%s',
     position=-1,
     ),
diff --git a/nipype/interfaces/fsl/tests/test_auto_Cluster.py b/nipype/interfaces/fsl/tests/test_auto_Cluster.py
--- a/nipype/interfaces/fsl/tests/test_auto_Cluster.py
+++ b/nipype/interfaces/fsl/tests/test_auto_Cluster.py
@@ -15,8 +15,12 @@ def test_Cluster_inputs():
     environ=dict(nohash=True,
     usedefault=True,
     ),
-    find_min=dict(),
-    fractional=dict(),
+    find_min=dict(argstr='--min',
+    usedefault=True,
+    ),
+    fractional=dict(argstr='--fractional',
+    usedefault=True,
+    ),
     ignore_exception=dict(nohash=True,
     usedefault=True,
     ),
@@ -24,8 +28,11 @@ def test_Cluster_inputs():
     mandatory=True,
     ),
     minclustersize=dict(argstr='--minclustersize',
+    usedefault=True,
+    ),
+    no_table=dict(argstr='--no_table',
+    usedefault=True,
     ),
-    no_table=dict(),
     num_maxima=dict(argstr='--num=%d',
     ),
     out_index_file=dict(argstr='--oindex=%s',
@@ -65,7 +72,9 @@ def test_Cluster_inputs():
     threshold=dict(argstr='--thresh=%.10f',
     mandatory=True,
     ),
-    use_mm=dict(),
+    use_mm=dict(argstr='--mm',
+    usedefault=True,
+    ),
     volume=dict(argstr='--volume=%d',
     ),
     warpfield_file=dict(argstr='--warpvol=%s',
Repository: nipy/nipype

Issue:
EstimateResponseSH dipy interface can not change default 'auto' input to False
### Summary
I can't find a way to set response estimation to recursive
### Actual behavior
Only auto_response can be used 
### Expected behavior

### How to replicate the behavior
```Python
import nipype.interfaces.dipy as ndp

estimate = ndp.EstimateResponseSH
estimate.inputs.auto = False
```
throughs the following error
>IOError: Input "recursive" is mutually exclusive with input "auto", which is already set

and similarly with
```Python
estimate.inputs.recursive = True
```

### Platform details:
{'nibabel_version': '2.1.0', 'networkx_version': '1.11', 'numpy_version': '1.11.2', 'sys_platform': 'linux2', 'sys_version': '2.7.6 (default, Oct 26 2016, 20:30:19) \n[GCC 4.8.4]', 'commit_source': 'installation', 'commit_hash': 'a4d1e07', 'pkg_path': '/home/bougacha/.local/lib/python2.7/site-packages/nipype', 'sys_executable': '/usr/bin/python', 'traits_version': '4.6.0', 'scipy_version': '0.18.1'}
0.12.1




Discussion:

Resolving patch:
diff --git a/nipype/interfaces/dipy/reconstruction.py b/nipype/interfaces/dipy/reconstruction.py
--- a/nipype/interfaces/dipy/reconstruction.py
+++ b/nipype/interfaces/dipy/reconstruction.py
@@ -166,11 +166,9 @@ class EstimateResponseSHInputSpec(DipyBaseInterfaceInputSpec):
     roi_radius = traits.Int(
         10, usedefault=True, desc=('ROI radius to be used in auto_response'))
     auto = traits.Bool(
-        True, usedefault=True, xor=['recursive'],
-        desc='use the auto_response estimator from dipy')
+        xor=['recursive'], desc='use the auto_response estimator from dipy')
     recursive = traits.Bool(
-        False, usedefault=True, xor=['auto'],
-        desc='use the recursive response estimator from dipy')
+        xor=['auto'], desc='use the recursive response estimator from dipy')
     response = File(
         'response.txt', usedefault=True, desc=('the output response file'))
     out_mask = File('wm_mask.nii.gz', usedefault=True, desc='computed wm mask')


Test patch:
diff --git a/nipype/interfaces/dipy/tests/test_auto_EstimateResponseSH.py b/nipype/interfaces/dipy/tests/test_auto_EstimateResponseSH.py
--- a/nipype/interfaces/dipy/tests/test_auto_EstimateResponseSH.py
+++ b/nipype/interfaces/dipy/tests/test_auto_EstimateResponseSH.py
@@ -4,8 +4,7 @@
 
 
 def test_EstimateResponseSH_inputs():
-    input_map = dict(auto=dict(usedefault=True,
-    xor=['recursive'],
+    input_map = dict(auto=dict(xor=['recursive'],
     ),
     b0_thres=dict(usedefault=True,
     ),
@@ -26,8 +25,7 @@ def test_EstimateResponseSH_inputs():
     out_mask=dict(usedefault=True,
     ),
     out_prefix=dict(),
-    recursive=dict(usedefault=True,
-    xor=['auto'],
+    recursive=dict(xor=['auto'],
     ),
     response=dict(usedefault=True,
     ),
Repository: nipy/nipype

Issue:
dcm2niix 
### Summary
dcm2niix interface failed with FileNotFoundError exception with following flags:

        converter = Dcm2niix()
        converter.inputs.single_file = True
        converter.inputs.compress = 'n'
        converter.inputs.output_dir = '/some/directory/'
        converter.inputs.source_names = ['/some/input/file.dcm']
        converter.inputs.bids_format = False
        converter.inputs.out_filename = 'filename'
        converter.run()

Fails with: 
FileNotFoundError: File/Directory '[u'/some/directory/filename.nii.gz']' not found for Dcm2niix output 'converted_files'.

`_parse_stdout` is currently not taking into account compression arg and expected output file extension is .nii.gz.

### Actual behavior
Interface Dcm2niix failed to run. 

### Expected behavior
Dcm2niix run

### Platform details:
{'nibabel_version': '2.1.0', 'networkx_version': '1.11', 'numpy_version': '1.12.0', 'sys_platform': 'linux2', 'sys_version': '2.7.13 (default, Mar 20 2017, 09:17:50) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]', 'commit_source': u'(none found)', 'commit_hash': u'<not found>', 'pkg_path': '/usr/local/lib/python2.7/site-packages/nipype', 'sys_executable': '/usr/local/bin/python', 'traits_version': '4.6.0', 'scipy_version': '0.18.1'}
0.13.0-rc1




Discussion:

Resolving patch:
diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py
--- a/nipype/interfaces/dcm2nii.py
+++ b/nipype/interfaces/dcm2nii.py
@@ -309,7 +309,10 @@ def _parse_stdout(self, stdout):
                 else:
                     pass
                 if out_file:
-                    files.append(out_file + ".nii.gz")
+                    if self.inputs.compress == 'n':
+                        files.append(out_file + ".nii")
+                    else:
+                        files.append(out_file + ".nii.gz")
                     if self.inputs.bids_format:
                         bids.append(out_file + ".json")
                     continue


Test patch:
Repository: nipy/nipype

Issue:
nipypecli should have --version 
### Summary

```shell
$> nipypecli --version
Error: no such option: --version
```

### Actual behavior

```shell
$> nipypecli --version
Error: no such option: --version
```
### Expected behavior
```shell
$> nipypecli --version
0.13.1
```
### How to replicate the behavior

```shell
$> nipypecli --version
Error: no such option: --version
```
### Script/Workflow details

Please put URL to code or code here (if not too long).

http://www.onerussian.com/tmp/nipypecli

### Platform details:

Please paste the output of: `python -c "import nipype; print(nipype.get_info()); print(nipype.__version__)"`

```shell
$> python -c "import nipype; print(nipype.get_info()); print(nipype.__version__)" 
{'nibabel_version': '2.1.0', 'sys_executable': '/usr/bin/python', 'networkx_version': '1.11', 'numpy_version': '1.12.0', 'sys_platform': 'linux2', 'sys_version': '2.7.13 (default, Jan 19 2017, 14:48:08) \n[GCC 6.3.0 20170118]', 'commit_source': u'archive substitution', 'commit_hash': u'8946bcab9d0e2f24e5364e42d4a7766e00237cb8', 'pkg_path': '/usr/lib/python2.7/dist-packages/nipype', 'nipype_version': u'0.13.1', 'traits_version': '4.6.0', 'scipy_version': '0.18.1'}
0.13.1
```





Discussion:

Resolving patch:
diff --git a/nipype/scripts/cli.py b/nipype/scripts/cli.py
--- a/nipype/scripts/cli.py
+++ b/nipype/scripts/cli.py
@@ -15,6 +15,7 @@
                     PythonModule,
                     check_not_none,)
 
+from .. import __version__
 
 # declare the CLI group
 @click.group(context_settings=CONTEXT_SETTINGS)
@@ -151,6 +152,10 @@ def run(ctx, module, interface, list, help):
             args = iface_parser.parse_args(args=ctx.args)
             run_instance(node, args)
 
+@cli.command(context_settings=CONTEXT_SETTINGS)
+def version():
+    """Print current version of Nipype."""
+    click.echo(__version__)
 
 @cli.group()
 def convert():


Test patch:
Repository: nipy/nipype

Issue:
interfaces.camino.convert.FSL2Scheme does not show up in documentation

Diagram on front page of docs contains a typo
"Idiosynchratic" should be "Idiosyncratic"



Discussion:
just like in #1685, `FSL` is ignored - perhaps changing it to `FSLCommand` would be a good fix
ugh!


Resolving patch:
diff --git a/tools/build_interface_docs.py b/tools/build_interface_docs.py
--- a/tools/build_interface_docs.py
+++ b/tools/build_interface_docs.py
@@ -42,7 +42,7 @@
                                        ]
     docwriter.class_skip_patterns += ['AFNICommand',
                                       'ANTS',
-                                      'FSL',
+                                      'FSLCommand',
                                       'FS',
                                       'Info',
                                       '^SPM',


Test patch:
Repository: nipy/nipype

Issue:
ANTs interfaces crash when checking version
### Summary
ANTs interfaces crash if the version does not contain commit hash. E.g.:
```
antsRegistration --version
ANTs Version: 2.2.0
```

### Actual behavior

```
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/nipype/pipeline/plugins/multiproc.py", line 52, in run_node
    result['result'] = node.run(updatehash=updatehash)
  File "/usr/local/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 372, in run
    self._run_interface()
  File "/usr/local/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 482, in _run_interface
    self._result = self._run_command(execute)
  File "/usr/local/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 613, in _run_command
    result = self._interface.run()
  File "/usr/local/lib/python3.6/site-packages/nipype/interfaces/base.py", line 1081, in run
    version=self.version)
  File "/usr/local/lib/python3.6/site-packages/nipype/interfaces/ants/base.py", line 127, in version
    return Info().version
  File "/usr/local/lib/python3.6/site-packages/nipype/interfaces/ants/base.py", line 56, in version
    v_string, githash = self._version.split('-')
ValueError: not enough values to unpack (expected 2, got 1)
```

### Expected behavior
`githash` should not be mandatory

### How to replicate the behavior
Shadow the original `antsRegistration` with a mock that just prints the above command.

### Script/Workflow details
https://github.com/poldracklab/mriqc/issues/600

### Platform details:
Unavailable. Should not be relevant.

### Execution environment
Should not be relevant.


Discussion:
Ugh. Sorry. I actually hadn't run across a released ANTs version that didn't have the githash. I'll push a fix this morning.

Resolving patch:
diff --git a/nipype/interfaces/ants/base.py b/nipype/interfaces/ants/base.py
--- a/nipype/interfaces/ants/base.py
+++ b/nipype/interfaces/ants/base.py
@@ -53,7 +53,8 @@ def version(self):
             else:
                 return None
 
-        v_string, githash = self._version.split('-')
+        # -githash may or may not be appended
+        v_string = self._version.split('-')[0]
 
         # 2.2.0-equivalent version string
         if 'post' in v_string and LooseVersion(v_string) >= LooseVersion('2.1.0.post789'):


Test patch:
Repository: nipy/nipype

Issue:
iterfield in MapNode can't be range (py3)
### Summary
In py3 `range` is not a list, and if iterfield in `MapNode` is defined as `range` than entire range is send to the interface at once.  

### Script/Workflow details

```
from nipype import Function, MapNode

def square_func(x):
    print(x, type(x))
    return x ** 2

square = Function(["x"], ["f_x"], square_func)

square_node = MapNode(square, name="square", iterfield=["x"])

square_node.inputs.x = range(4)
res  = square_node.run()
```

### Actual behavior
print statement from `square_func` gives `range(0, 4) <class 'range'>`

### Expected behavior
print statement from `square_func` should give  `0 <class 'int'>`, etc.





Discussion:
@djarecka - in py3 range is a generator if you do `list(range(4))` it should work fine.
@satra - yes, I know, but my point was that it is misleading. `MapNode` doesn't give any warnings just sent the entire object to the function. It shouldn't be changed within the `MapNode` class?
yes, it should result in an exception in this case, since it's not doing the correct thing.

Resolving patch:
diff --git a/nipype/interfaces/base.py b/nipype/interfaces/base.py
--- a/nipype/interfaces/base.py
+++ b/nipype/interfaces/base.py
@@ -32,6 +32,7 @@
 import simplejson as json
 from dateutil.parser import parse as parseutc
 from packaging.version import Version
+import collections
 
 from .. import config, logging, LooseVersion, __version__
 from ..utils.provenance import write_provenance
@@ -2058,9 +2059,15 @@ class MultiPath(traits.List):
     """
 
     def validate(self, object, name, value):
+
+        # want to treat range and other sequences (except str) as list
+        if not isinstance(value, (str, bytes)) and isinstance(value, collections.Sequence):
+            value  = list(value)
+
         if not isdefined(value) or \
                 (isinstance(value, list) and len(value) == 0):
             return Undefined
+
         newvalue = value
 
         if not isinstance(value, list) \


Test patch:
diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py
--- a/nipype/pipeline/engine/tests/test_engine.py
+++ b/nipype/pipeline/engine/tests/test_engine.py
@@ -456,6 +456,24 @@ def test_mapnode_iterfield_check():
     with pytest.raises(ValueError): mod1._check_iterfield()
 
 
+@pytest.mark.parametrize("x_inp, f_exp", [
+        (3, [6]), ([2, 3], [4, 6]), ((2, 3), [4, 6]),
+        (range(3), [0, 2, 4]),
+         ("Str", ["StrStr"]), (["Str1", "Str2"], ["Str1Str1", "Str2Str2"])
+        ])
+def test_mapnode_iterfield_type(x_inp, f_exp):
+    from nipype import MapNode, Function
+    def double_func(x):
+        return 2 * x
+    double = Function(["x"], ["f_x"], double_func)
+
+    double_node = MapNode(double, name="double", iterfield=["x"])
+    double_node.inputs.x = x_inp
+
+    res  = double_node.run()
+    assert res.outputs.f_x == f_exp
+
+
 def test_mapnode_nested(tmpdir):
     os.chdir(str(tmpdir))
     from nipype import MapNode, Function