Repository: nipy/nipype

Issue:
Unknown version string with Freesurfer 7
### Summary

After update to freesurfer 7 `import nipype.interfaces.freesurfer` returns `RuntimeError: Unknown version string` error.

### Actual behavior
```
$ python
Python 3.8.2 (default, May  7 2020, 20:00:49) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from nipype.interfaces.freesurfer import Info
200518-18:18:10,4 nipype.utils WARNING:
	 Could not check for version updates: 
Connection to server could not be made
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/anaconda3/envs/neuromet_dev/lib/python3.8/site-packages/nipype/interfaces/freesurfer/__init__.py", line 7, in <module>
    from .preprocess import (
  File "/opt/anaconda3/envs/neuromet_dev/lib/python3.8/site-packages/nipype/interfaces/freesurfer/preprocess.py", line 36, in <module>
    FSVersion = Info.looseversion().vstring
  File "/opt/anaconda3/envs/neuromet_dev/lib/python3.8/site-packages/nipype/interfaces/freesurfer/base.py", line 80, in looseversion
    raise RuntimeError("Unknown version string: " + ver)
RuntimeError: Unknown version string: freesurfer-linux-centos7_x86_64-7.1.0-20200511-813297b
```

### How to replicate the behavior

1. Install Freesurfer 7 as described [here](https://surfer.nmr.mgh.harvard.edu/fswiki//FS7_linux) with Freesurfer from [here](https://surfer.nmr.mgh.harvard.edu/fswiki/rel7downloads) (file: `freesurfer-linux-centos7_x86_64-7.1.0.tar.gz`.
2. create a fresh new conda environment with 
`conda create -n $name python=3.8 nipype`
3. open python and try to import 'nipype.interfaces.freesurfer`

### Platform details:
```
$cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS"
```

<!-- Please run the following code from your shell and place the output between the triple ticks, below.
python -c "import nipype; from pprint import pprint; pprint(nipype.get_info())"
-->

```
$python -c "import nipype; from pprint import pprint; pprint(nipype.get_info())"
200518-18:29:34,82 nipype.utils WARNING:
	 Could not check for version updates: 
Connection to server could not be made
{'commit_hash': '%h',
 'commit_source': 'archive substitution',
 'networkx_version': '2.4',
 'nibabel_version': '3.1.0',
 'nipype_version': '1.5.0-rc1',
 'numpy_version': '1.18.1',
 'pkg_path': '/opt/anaconda3/envs/neuromet_dev/lib/python3.8/site-packages/nipype',
 'scipy_version': '1.4.1',
 'sys_executable': '/opt/anaconda3/envs/neuromet_dev/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.8.2 (default, May  7 2020, 20:00:49) \n[GCC 7.3.0]',
 'traits_version': '5.2.0'}
```

### Execution environment

Choose one
- My python environment outside container



Discussion:
I can confirm this in my environment as well. My solution is to hold off on the Freesurfer update for now. 
As (naive :P) workaround to test Freesurfer 7, I've put on line 80 of `/opt/anaconda3/envs/neuromet_dev/lib/python3.8/site-packages/nipype/interfaces/freesurfer/base.py` in my _test environment_

`return LooseVersion("0.0.0")`

instead of

`raise RuntimeError("Unknown version string: " + ver)`

My recon-all routine failed by the hippocampal subfield module, because it is now in separates scripts.

```
ERROR: the hippocampal subfield module is now in separate scripts:
  segmentHA_T1.sh
  segmentHA_T2.sh
  segmentHA_T1_long.sh
```

Resolving patch:
diff --git a/nipype/interfaces/freesurfer/base.py b/nipype/interfaces/freesurfer/base.py
--- a/nipype/interfaces/freesurfer/base.py
+++ b/nipype/interfaces/freesurfer/base.py
@@ -76,6 +76,9 @@ def looseversion(cls):
                 vstr = "6.0.0-dev" + githash
             elif vinfo[5][0] == "v":
                 vstr = vinfo[5][1:]
+            elif len([1 for val in vinfo[3] if val == '.']) == 2:
+                "version string: freesurfer-linux-centos7_x86_64-7.1.0-20200511-813297b"
+                vstr = vinfo[3]
             else:
                 raise RuntimeError("Unknown version string: " + ver)
         # Retain pre-6.0.0 heuristics


Test patch: