Repository: nipy/nipype

Issue:
FreeSurferSource doesn't check subjects_dir
### Summary
`FreeSurferSource` doesn't check `subjects_dir` is an existing path.

### How to replicate the behavior

```
from nipype.interfaces.io import FreeSurferSource
fs = FreeSurferSource()
fs.inputs.subjects_dir = 'path/to/no/existing/directory'
fs.inputs.subject_id = 'sub-01'
res = fs.run()
```

### Actual behavior
Doesn't give an error.

### Expected behavior
Should check if directory exists (and possibly if there are files for `subject_id` ?).



Discussion:

Patch:
diff --git a/nipype/interfaces/io.py b/nipype/interfaces/io.py
index fc3617036..6bb9a943f 100644
--- a/nipype/interfaces/io.py
+++ b/nipype/interfaces/io.py
@@ -1555,16 +1555,12 @@ class DataFinder(IOBase):
 
 
 class FSSourceInputSpec(BaseInterfaceInputSpec):
-    subjects_dir = Directory(
-        mandatory=True, desc='Freesurfer subjects directory.')
-    subject_id = Str(
-        mandatory=True, desc='Subject name for whom to retrieve data')
-    hemi = traits.Enum(
-        'both',
-        'lh',
-        'rh',
-        usedefault=True,
-        desc='Selects hemisphere specific outputs')
+    subjects_dir = Directory(exists=True, mandatory=True,
+                             desc='Freesurfer subjects directory.')
+    subject_id = Str(mandatory=True,
+                     desc='Subject name for whom to retrieve data')
+    hemi = traits.Enum('both', 'lh', 'rh', usedefault=True,
+                       desc='Selects hemisphere specific outputs')
 
 
 class FSSourceOutputSpec(TraitedSpec):


Test patch:
diff --git a/nipype/interfaces/tests/test_io.py b/nipype/interfaces/tests/test_io.py
index a2103eadf..76fc9e257 100644
--- a/nipype/interfaces/tests/test_io.py
+++ b/nipype/interfaces/tests/test_io.py
@@ -16,7 +16,7 @@ from collections import namedtuple
 import pytest
 import nipype
 import nipype.interfaces.io as nio
-from nipype.interfaces.base import Undefined
+from nipype.interfaces.base import Undefined, TraitError
 
 # Check for boto
 noboto = False
@@ -498,6 +498,12 @@ def test_freesurfersource():
     assert fss.inputs.subjects_dir == Undefined
 
 
+def test_freesurfersource_incorrectdir():
+    fss = nio.FreeSurferSource()
+    with pytest.raises(TraitError) as err:
+        fss.inputs.subjects_dir = 'path/to/no/existing/directory'
+
+
 def test_jsonsink_input():
 
     ds = nio.JSONFileSink()