aslprep.niworkflows.interfaces.utility module
Interfaces under evaluation before upstreaming to nipype.interfaces.utility.
- class KeySelect(keys=None, fields=None, **inputs)[source]
Bases:
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.
- __init__(keys=None, fields=None, **inputs)[source]
Instantiate a KeySelect utility interface.
Examples
>>> ks = KeySelect(fields='field1') >>> ks.inputs field1 = <undefined> key = <undefined> keys = <undefined>
>>> ks = KeySelect(fields='field1', field1=['a', 'b']) >>> ks.inputs field1 = ['a', 'b'] key = <undefined> keys = <undefined>
>>> ks = KeySelect() Traceback (most recent call last): ValueError: A list or multiplexed...
>>> ks = KeySelect(fields='key') Traceback (most recent call last): ValueError: Some fields are invalid...