We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `nipype/interfaces/ants/base.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
3 # vi: set ft=python sts=4 ts=4 sw=4 et:
4 """The ants module provides basic functions for interfacing with ANTS tools."""
5 from __future__ import print_function, division, unicode_literals, absolute_import
6 from builtins import str
7 
8 import os
9 import subprocess
10 
11 # Local imports
12 from ... import logging, LooseVersion
13 from ..base import CommandLine, CommandLineInputSpec, traits, isdefined
14 logger = logging.getLogger('interface')
15 
16 # -Using -1 gives primary responsibilty to ITKv4 to do the correct
17 #  thread limitings.
18 # -Using 1 takes a very conservative approach to avoid overloading
19 #  the computer (when running MultiProc) by forcing everything to
20 #  single threaded.  This can be a severe penalty for registration
21 #  performance.
22 LOCAL_DEFAULT_NUMBER_OF_THREADS = 1
23 # -Using NSLOTS has the same behavior as ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS
24 #  as long as ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS is not set.  Otherwise
25 #  ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS takes precidence.
26 #  This behavior states that you the user explicitly specifies
27 #  num_threads, then respect that no matter what SGE tries to limit.
28 PREFERED_ITKv4_THREAD_LIMIT_VARIABLE = 'NSLOTS'
29 ALT_ITKv4_THREAD_LIMIT_VARIABLE = 'ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS'
30 
31 
32 class Info(object):
33     _version = None
34 
35     @property
36     def version(self):
37         if self._version is None:
38             try:
39                 basedir = os.environ['ANTSPATH']
40             except KeyError:
41                 return None
42 
43             cmd = os.path.join(basedir, 'antsRegistration')
44             try:
45                 res = subprocess.check_output([cmd, '--version']).decode('utf-8')
46             except OSError:
47                 return None
48 
49             for line in res.splitlines():
50                 if line.startswith('ANTs Version: '):
51                     self._version = line.split()[2]
52                     break
53             else:
54                 return None
55 
56         v_string, githash = self._version.split('-')
57 
58         # 2.2.0-equivalent version string
59         if 'post' in v_string and LooseVersion(v_string) >= LooseVersion('2.1.0.post789'):
60             return '2.2.0'
61         else:
62             return '.'.join(v_string.split('.')[:3])
63 
64 
65 class ANTSCommandInputSpec(CommandLineInputSpec):
66     """Base Input Specification for all ANTS Commands
67     """
68 
69     num_threads = traits.Int(LOCAL_DEFAULT_NUMBER_OF_THREADS, usedefault=True,
70                              nohash=True, desc="Number of ITK threads to use")
71 
72 
73 class ANTSCommand(CommandLine):
74     """Base class for ANTS interfaces
75     """
76 
77     input_spec = ANTSCommandInputSpec
78     _num_threads = LOCAL_DEFAULT_NUMBER_OF_THREADS
79 
80     def __init__(self, **inputs):
81         super(ANTSCommand, self).__init__(**inputs)
82         self.inputs.on_trait_change(self._num_threads_update, 'num_threads')
83 
84         if not isdefined(self.inputs.num_threads):
85             self.inputs.num_threads = self._num_threads
86         else:
87             self._num_threads_update()
88 
89     def _num_threads_update(self):
90         self._num_threads = self.inputs.num_threads
91         # ONLY SET THE ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS if requested
92         # by the end user.  The default setting did not allow for
93         # overwriting the default values.
94         # In ITKv4 (the version used for all ANTS programs), ITK respects
95         # the SGE controlled $NSLOTS environmental variable.
96         # If user specifies -1, then that indicates that the system
97         # default behavior should be the one specified by ITKv4 rules
98         # (i.e. respect SGE $NSLOTS or environmental variables of threads, or
99         # user environmental settings)
100         if (self.inputs.num_threads == -1):
101             if (ALT_ITKv4_THREAD_LIMIT_VARIABLE in self.inputs.environ):
102                 del self.inputs.environ[ALT_ITKv4_THREAD_LIMIT_VARIABLE]
103             if (PREFERED_ITKv4_THREAD_LIMIT_VARIABLE in self.inputs.environ):
104                 del self.inputs.environ[PREFERED_ITKv4_THREAD_LIMIT_VARIABLE]
105         else:
106             self.inputs.environ.update({PREFERED_ITKv4_THREAD_LIMIT_VARIABLE:
107                                         '%s' % self.inputs.num_threads})
108 
109     @staticmethod
110     def _format_xarray(val):
111         """ Convenience method for converting input arrays [1,2,3] to commandline format '1x2x3' """
112         return 'x'.join([str(x) for x in val])
113 
114     @classmethod
115     def set_default_num_threads(cls, num_threads):
116         """Set the default number of threads for ITK calls
117 
118         This method is used to set the default number of ITK threads for all
119         the ANTS interfaces. However, setting this will not update the output
120         type for any existing instances.  For these, assign the
121         <instance>.inputs.num_threads
122         """
123         cls._num_threads = num_threads
124 
125     @property
126     def version(self):
127         return Info().version
128
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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 @@
             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'):

{"golden_diff": "diff --git a/nipype/interfaces/ants/base.py b/nipype/interfaces/ants/base.py\n--- a/nipype/interfaces/ants/base.py\n+++ b/nipype/interfaces/ants/base.py\n@@ -53,7 +53,8 @@\n             else:\n                 return None\n \n-        v_string, githash = self._version.split('-')\n+        # -githash may or may not be appended\n+        v_string = self._version.split('-')[0]\n \n         # 2.2.0-equivalent version string\n         if 'post' in v_string and LooseVersion(v_string) >= LooseVersion('2.1.0.post789'):\n", "issue": "ANTs interfaces crash when checking version\n### Summary\r\nANTs interfaces crash if the version does not contain commit hash. E.g.:\r\n```\r\nantsRegistration --version\r\nANTs Version: 2.2.0\r\n```\r\n\r\n### Actual behavior\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.6/site-packages/nipype/pipeline/plugins/multiproc.py\", line 52, in run_node\r\n    result['result'] = node.run(updatehash=updatehash)\r\n  File \"/usr/local/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py\", line 372, in run\r\n    self._run_interface()\r\n  File \"/usr/local/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py\", line 482, in _run_interface\r\n    self._result = self._run_command(execute)\r\n  File \"/usr/local/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py\", line 613, in _run_command\r\n    result = self._interface.run()\r\n  File \"/usr/local/lib/python3.6/site-packages/nipype/interfaces/base.py\", line 1081, in run\r\n    version=self.version)\r\n  File \"/usr/local/lib/python3.6/site-packages/nipype/interfaces/ants/base.py\", line 127, in version\r\n    return Info().version\r\n  File \"/usr/local/lib/python3.6/site-packages/nipype/interfaces/ants/base.py\", line 56, in version\r\n    v_string, githash = self._version.split('-')\r\nValueError: not enough values to unpack (expected 2, got 1)\r\n```\r\n\r\n### Expected behavior\r\n`githash` should not be mandatory\r\n\r\n### How to replicate the behavior\r\nShadow the original `antsRegistration` with a mock that just prints the above command.\r\n\r\n### Script/Workflow details\r\nhttps://github.com/poldracklab/mriqc/issues/600\r\n\r\n### Platform details:\r\nUnavailable. Should not be relevant.\r\n\r\n### Execution environment\r\nShould not be relevant.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-\n# vi: set ft=python sts=4 ts=4 sw=4 et:\n\"\"\"The ants module provides basic functions for interfacing with ANTS tools.\"\"\"\nfrom __future__ import print_function, division, unicode_literals, absolute_import\nfrom builtins import str\n\nimport os\nimport subprocess\n\n# Local imports\nfrom ... import logging, LooseVersion\nfrom ..base import CommandLine, CommandLineInputSpec, traits, isdefined\nlogger = logging.getLogger('interface')\n\n# -Using -1 gives primary responsibilty to ITKv4 to do the correct\n#  thread limitings.\n# -Using 1 takes a very conservative approach to avoid overloading\n#  the computer (when running MultiProc) by forcing everything to\n#  single threaded.  This can be a severe penalty for registration\n#  performance.\nLOCAL_DEFAULT_NUMBER_OF_THREADS = 1\n# -Using NSLOTS has the same behavior as ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS\n#  as long as ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS is not set.  Otherwise\n#  ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS takes precidence.\n#  This behavior states that you the user explicitly specifies\n#  num_threads, then respect that no matter what SGE tries to limit.\nPREFERED_ITKv4_THREAD_LIMIT_VARIABLE = 'NSLOTS'\nALT_ITKv4_THREAD_LIMIT_VARIABLE = 'ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS'\n\n\nclass Info(object):\n    _version = None\n\n    @property\n    def version(self):\n        if self._version is None:\n            try:\n                basedir = os.environ['ANTSPATH']\n            except KeyError:\n                return None\n\n            cmd = os.path.join(basedir, 'antsRegistration')\n            try:\n                res = subprocess.check_output([cmd, '--version']).decode('utf-8')\n            except OSError:\n                return None\n\n            for line in res.splitlines():\n                if line.startswith('ANTs Version: '):\n                    self._version = line.split()[2]\n                    break\n            else:\n                return None\n\n        v_string, githash = self._version.split('-')\n\n        # 2.2.0-equivalent version string\n        if 'post' in v_string and LooseVersion(v_string) >= LooseVersion('2.1.0.post789'):\n            return '2.2.0'\n        else:\n            return '.'.join(v_string.split('.')[:3])\n\n\nclass ANTSCommandInputSpec(CommandLineInputSpec):\n    \"\"\"Base Input Specification for all ANTS Commands\n    \"\"\"\n\n    num_threads = traits.Int(LOCAL_DEFAULT_NUMBER_OF_THREADS, usedefault=True,\n                             nohash=True, desc=\"Number of ITK threads to use\")\n\n\nclass ANTSCommand(CommandLine):\n    \"\"\"Base class for ANTS interfaces\n    \"\"\"\n\n    input_spec = ANTSCommandInputSpec\n    _num_threads = LOCAL_DEFAULT_NUMBER_OF_THREADS\n\n    def __init__(self, **inputs):\n        super(ANTSCommand, self).__init__(**inputs)\n        self.inputs.on_trait_change(self._num_threads_update, 'num_threads')\n\n        if not isdefined(self.inputs.num_threads):\n            self.inputs.num_threads = self._num_threads\n        else:\n            self._num_threads_update()\n\n    def _num_threads_update(self):\n        self._num_threads = self.inputs.num_threads\n        # ONLY SET THE ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS if requested\n        # by the end user.  The default setting did not allow for\n        # overwriting the default values.\n        # In ITKv4 (the version used for all ANTS programs), ITK respects\n        # the SGE controlled $NSLOTS environmental variable.\n        # If user specifies -1, then that indicates that the system\n        # default behavior should be the one specified by ITKv4 rules\n        # (i.e. respect SGE $NSLOTS or environmental variables of threads, or\n        # user environmental settings)\n        if (self.inputs.num_threads == -1):\n            if (ALT_ITKv4_THREAD_LIMIT_VARIABLE in self.inputs.environ):\n                del self.inputs.environ[ALT_ITKv4_THREAD_LIMIT_VARIABLE]\n            if (PREFERED_ITKv4_THREAD_LIMIT_VARIABLE in self.inputs.environ):\n                del self.inputs.environ[PREFERED_ITKv4_THREAD_LIMIT_VARIABLE]\n        else:\n            self.inputs.environ.update({PREFERED_ITKv4_THREAD_LIMIT_VARIABLE:\n                                        '%s' % self.inputs.num_threads})\n\n    @staticmethod\n    def _format_xarray(val):\n        \"\"\" Convenience method for converting input arrays [1,2,3] to commandline format '1x2x3' \"\"\"\n        return 'x'.join([str(x) for x in val])\n\n    @classmethod\n    def set_default_num_threads(cls, num_threads):\n        \"\"\"Set the default number of threads for ITK calls\n\n        This method is used to set the default number of ITK threads for all\n        the ANTS interfaces. However, setting this will not update the output\n        type for any existing instances.  For these, assign the\n        <instance>.inputs.num_threads\n        \"\"\"\n        cls._num_threads = num_threads\n\n    @property\n    def version(self):\n        return Info().version\n", "path": "nipype/interfaces/ants/base.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-\n# vi: set ft=python sts=4 ts=4 sw=4 et:\n\"\"\"The ants module provides basic functions for interfacing with ANTS tools.\"\"\"\nfrom __future__ import print_function, division, unicode_literals, absolute_import\nfrom builtins import str\n\nimport os\nimport subprocess\n\n# Local imports\nfrom ... import logging, LooseVersion\nfrom ..base import CommandLine, CommandLineInputSpec, traits, isdefined\nlogger = logging.getLogger('interface')\n\n# -Using -1 gives primary responsibilty to ITKv4 to do the correct\n#  thread limitings.\n# -Using 1 takes a very conservative approach to avoid overloading\n#  the computer (when running MultiProc) by forcing everything to\n#  single threaded.  This can be a severe penalty for registration\n#  performance.\nLOCAL_DEFAULT_NUMBER_OF_THREADS = 1\n# -Using NSLOTS has the same behavior as ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS\n#  as long as ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS is not set.  Otherwise\n#  ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS takes precidence.\n#  This behavior states that you the user explicitly specifies\n#  num_threads, then respect that no matter what SGE tries to limit.\nPREFERED_ITKv4_THREAD_LIMIT_VARIABLE = 'NSLOTS'\nALT_ITKv4_THREAD_LIMIT_VARIABLE = 'ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS'\n\n\nclass Info(object):\n    _version = None\n\n    @property\n    def version(self):\n        if self._version is None:\n            try:\n                basedir = os.environ['ANTSPATH']\n            except KeyError:\n                return None\n\n            cmd = os.path.join(basedir, 'antsRegistration')\n            try:\n                res = subprocess.check_output([cmd, '--version']).decode('utf-8')\n            except OSError:\n                return None\n\n            for line in res.splitlines():\n                if line.startswith('ANTs Version: '):\n                    self._version = line.split()[2]\n                    break\n            else:\n                return None\n\n        # -githash may or may not be appended\n        v_string = self._version.split('-')[0]\n\n        # 2.2.0-equivalent version string\n        if 'post' in v_string and LooseVersion(v_string) >= LooseVersion('2.1.0.post789'):\n            return '2.2.0'\n        else:\n            return '.'.join(v_string.split('.')[:3])\n\n\nclass ANTSCommandInputSpec(CommandLineInputSpec):\n    \"\"\"Base Input Specification for all ANTS Commands\n    \"\"\"\n\n    num_threads = traits.Int(LOCAL_DEFAULT_NUMBER_OF_THREADS, usedefault=True,\n                             nohash=True, desc=\"Number of ITK threads to use\")\n\n\nclass ANTSCommand(CommandLine):\n    \"\"\"Base class for ANTS interfaces\n    \"\"\"\n\n    input_spec = ANTSCommandInputSpec\n    _num_threads = LOCAL_DEFAULT_NUMBER_OF_THREADS\n\n    def __init__(self, **inputs):\n        super(ANTSCommand, self).__init__(**inputs)\n        self.inputs.on_trait_change(self._num_threads_update, 'num_threads')\n\n        if not isdefined(self.inputs.num_threads):\n            self.inputs.num_threads = self._num_threads\n        else:\n            self._num_threads_update()\n\n    def _num_threads_update(self):\n        self._num_threads = self.inputs.num_threads\n        # ONLY SET THE ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS if requested\n        # by the end user.  The default setting did not allow for\n        # overwriting the default values.\n        # In ITKv4 (the version used for all ANTS programs), ITK respects\n        # the SGE controlled $NSLOTS environmental variable.\n        # If user specifies -1, then that indicates that the system\n        # default behavior should be the one specified by ITKv4 rules\n        # (i.e. respect SGE $NSLOTS or environmental variables of threads, or\n        # user environmental settings)\n        if (self.inputs.num_threads == -1):\n            if (ALT_ITKv4_THREAD_LIMIT_VARIABLE in self.inputs.environ):\n                del self.inputs.environ[ALT_ITKv4_THREAD_LIMIT_VARIABLE]\n            if (PREFERED_ITKv4_THREAD_LIMIT_VARIABLE in self.inputs.environ):\n                del self.inputs.environ[PREFERED_ITKv4_THREAD_LIMIT_VARIABLE]\n        else:\n            self.inputs.environ.update({PREFERED_ITKv4_THREAD_LIMIT_VARIABLE:\n                                        '%s' % self.inputs.num_threads})\n\n    @staticmethod\n    def _format_xarray(val):\n        \"\"\" Convenience method for converting input arrays [1,2,3] to commandline format '1x2x3' \"\"\"\n        return 'x'.join([str(x) for x in val])\n\n    @classmethod\n    def set_default_num_threads(cls, num_threads):\n        \"\"\"Set the default number of threads for ITK calls\n\n        This method is used to set the default number of ITK threads for all\n        the ANTS interfaces. However, setting this will not update the output\n        type for any existing instances.  For these, assign the\n        <instance>.inputs.num_threads\n        \"\"\"\n        cls._num_threads = num_threads\n\n    @property\n    def version(self):\n        return Info().version\n", "path": "nipype/interfaces/ants/base.py"}]}