niworkflows.utils.connections module

Utilities for the creation of nipype workflows.

Because these functions are meant to be inlined in nipype’s connect invocations, all the imports MUST be done in each function’s context.

niworkflows.utils.connections.listify(value)[source]

Convert to a list (inspired by bids.utils.listify).

Examples

>>> listify('some/file.nii.gz')
['some/file.nii.gz']
>>> listify((0.1, 0.2))
[0.1, 0.2]
>>> listify(None) is None
True
niworkflows.utils.connections.pop_file(in_files)[source]

Select the first file from a list of filenames.

Used to grab the first echo’s file when processing multi-echo data through workflows that only accept a single file.

Examples

>>> pop_file('some/file.nii.gz')
'some/file.nii.gz'
>>> pop_file(['some/file1.nii.gz', 'some/file2.nii.gz'])
'some/file1.nii.gz'