niworkflows.interfaces.utility module#

Interfaces under evaluation before upstreaming to nipype.interfaces.utility.

class niworkflows.interfaces.utility.KeySelect(keys=None, fields=None, **inputs)[source]#

Bases: nipype.interfaces.base.core.BaseInterface

An interface that operates similarly to an OrderedDict.

>>> ks = KeySelect(keys=['MNI152NLin6Asym', 'MNI152Lin', 'fsaverage'],
...                fields=['field1', 'field2', 'field3'])
>>> ks.inputs.field1 = ['fsl', 'mni', 'freesurfer']
>>> ks.inputs.field2 = ['volume', 'volume', 'surface']
>>> ks.inputs.field3 = [True, False, False]
>>> ks.inputs.key = 'MNI152Lin'
>>> ks.run().outputs

field1 = mni
field2 = volume
field3 = False
key = MNI152Lin
>>> ks = KeySelect(fields=['field1', 'field2', 'field3'])
>>> ks.inputs.keys=['MNI152NLin6Asym', 'MNI152Lin', 'fsaverage']
>>> ks.inputs.field1 = ['fsl', 'mni', 'freesurfer']
>>> ks.inputs.field2 = ['volume', 'volume', 'surface']
>>> ks.inputs.field3 = [True, False, False]
>>> ks.inputs.key = 'MNI152Lin'
>>> ks.run().outputs

field1 = mni
field2 = volume
field3 = False
key = MNI152Lin
>>> ks.inputs.field1 = ['fsl', 'mni', 'freesurfer']
>>> ks.inputs.field2 = ['volume', 'volume', 'surface']
>>> ks.inputs.field3 = [True, False, False]
>>> ks.inputs.key = 'fsaverage'
>>> ks.run().outputs

field1 = freesurfer
field2 = surface
field3 = False
key = fsaverage
>>> ks.inputs.field1 = ['fsl', 'mni', 'freesurfer']
>>> ks.inputs.field2 = ['volume', 'volume', 'surface']
>>> ks.inputs.field3 = [True, False]  
Traceback (most recent call last):
ValueError: Trying to set an invalid value
>>> ks.inputs.key = 'MNINLin2009cAsym'
Traceback (most recent call last):
ValueError: Selected key "MNINLin2009cAsym" not found in the index
>>> ks = KeySelect(fields=['field1', 'field2', 'field3'])
>>> ks.inputs.keys=['MNI152NLin6Asym']
>>> ks.inputs.field1 = ['fsl']
>>> ks.inputs.field2 = ['volume']
>>> ks.inputs.field3 = [True]
>>> ks.inputs.key = 'MNI152NLin6Asym'
>>> ks.run().outputs

field1 = fsl
field2 = volume
field3 = True
key = MNI152NLin6Asym
Mandatory Inputs
  • key (a string) – Selective key.

  • keys (a list of items which are a string) – Index of keys.

Outputs

key (a string) – Propagates selected key.

input_spec#

alias of niworkflows.interfaces.utility._KeySelectInputSpec

output_spec#

alias of niworkflows.interfaces.utility._KeySelectOutputSpec