|
8 | 8 |
|
9 | 9 | from nipype.interfaces.io import add_traits
|
10 | 10 | from nipype.interfaces.base import (
|
11 |
| - traits, Str, DynamicTraitedSpec, BaseInterface, isdefined |
| 11 | + InputMultiObject, Str, DynamicTraitedSpec, BaseInterface, isdefined |
12 | 12 | )
|
13 | 13 |
|
14 | 14 |
|
15 | 15 | class KeySelectInputSpec(DynamicTraitedSpec):
|
16 | 16 | key = Str(mandatory=True, desc='selective key')
|
17 |
| - keys = traits.List(Str, mandatory=True, min=2, desc='index of keys') |
| 17 | + keys = InputMultiObject(Str, mandatory=True, min=1, desc='index of keys') |
18 | 18 |
|
19 | 19 |
|
20 | 20 | class KeySelectOutputSpec(DynamicTraitedSpec):
|
@@ -75,6 +75,20 @@ class KeySelect(BaseInterface):
|
75 | 75 | Traceback (most recent call last):
|
76 | 76 | ValueError: Selected key "MNINLin2009cAsym" not found in the index
|
77 | 77 |
|
| 78 | + >>> ks = KeySelect(fields=['field1', 'field2', 'field3']) |
| 79 | + >>> ks.inputs.keys=['MNI152NLin6Asym'] |
| 80 | + >>> ks.inputs.field1 = ['fsl'] |
| 81 | + >>> ks.inputs.field2 = ['volume'] |
| 82 | + >>> ks.inputs.field3 = [True] |
| 83 | + >>> ks.inputs.key = 'MNI152NLin6Asym' |
| 84 | + >>> ks.run().outputs |
| 85 | + <BLANKLINE> |
| 86 | + field1 = fsl |
| 87 | + field2 = volume |
| 88 | + field3 = True |
| 89 | + key = MNI152NLin6Asym |
| 90 | + <BLANKLINE> |
| 91 | +
|
78 | 92 | """
|
79 | 93 | input_spec = KeySelectInputSpec
|
80 | 94 | output_spec = KeySelectOutputSpec
|
@@ -120,7 +134,7 @@ def _check_len(self, name, new):
|
120 | 134 | raise ValueError('Selected key "%s" not found in the index' % new)
|
121 | 135 |
|
122 | 136 | if name in self._fields:
|
123 |
| - if isinstance(new, str) or len(new) <= 1: |
| 137 | + if isinstance(new, str) or len(new) < 1: |
124 | 138 | raise ValueError('Trying to set an invalid value (%s) for input "%s"' % (
|
125 | 139 | new, name))
|
126 | 140 |
|
|
0 commit comments