cmtklib.interfaces.misc module

ConcatOutputsAsTuple

Link to code

Bases: nipype.interfaces.base.core.BaseInterface

Concatenate 2 different output file as a Tuple of 2 files.

Examples

>>> from cmtklib.interfaces.misc import ConcatOutputsAsTuple
>>> concat_outputs = ConcatOutputsAsTuple()
>>> concat_outputs.inputs.input1  = 'output_interface1.nii.gz'
>>> concat_outputs.inputs.input2  = 'output_interface2.nii.gz'
>>> concat_outputs.run()  

input1 : a pathlike object or string representing an existing file input2 : a pathlike object or string representing an existing file

out_tuple : a tuple of the form: (a pathlike object or string representing an existing file, a pathlike object or string representing an existing file)

ExtractHeaderVoxel2WorldMatrix

Link to code

Bases: nipype.interfaces.base.core.BaseInterface

Write in a text file the voxel-to-world transform matrix from the heaer of a Nifti image.

Examples

>>> from cmtklib.interfaces.misc import ExtractHeaderVoxel2WorldMatrix
>>> extract_mat = ExtractHeaderVoxel2WorldMatrix()
>>> extract_mat.inputs.in_file = 'sub-01_T1w.nii.gz'
>>> extract_mat.run()  
in_filea pathlike object or string representing an existing file

Input image file.

out_matrixa pathlike object or string representing an existing file

Output voxel to world affine transform file.

ExtractImageVoxelSizes

Link to code

Bases: nipype.interfaces.base.core.BaseInterface

Returns a list of voxel sizes from an image.

Examples

>>> from cmtklib.interfaces.misc import ExtractImageVoxelSizes
>>> extract_voxel_sizes = ExtractImageVoxelSizes()
>>> extract_voxel_sizes.inputs.in_file = 'sub-01_T1w.nii.gz'
>>> extract_voxel_sizes.run()  

in_file : a pathlike object or string representing an existing file

voxel_sizes : a list of items which are any value

Rename001

Link to code

Bases: nipype.interfaces.utility.base.Rename

Change the name of a file based on a mapped format string.

To use additional inputs that will be defined at run-time, the class constructor must be called with the format template, and the fields identified will become inputs to the interface. Additionally, you may set the parse_string input, which will be run over the input filename with a regular expressions search, and will fill in additional input fields from matched groups. Fields set with inputs have precedence over fields filled in with the regexp match.

It corresponds to the nipype.interfaces.utility.base.Rename interface that has been modified to force hard link during copy

Examples

>>> from nipype.interfaces.utility import Rename
>>> rename1 = Rename()
>>> rename1.inputs.in_file = os.path.join(datadir, "zstat1.nii.gz") # datadir is a directory with exemplary files, defined in conftest.py
>>> rename1.inputs.format_string = "Faces-Scenes.nii.gz"
>>> res = rename1.run()          
>>> res.outputs.out_file         
'Faces-Scenes.nii.gz"            
>>> rename2 = Rename(format_string="%(subject_id)s_func_run%(run)02d")
>>> rename2.inputs.in_file = os.path.join(datadir, "functional.nii")
>>> rename2.inputs.keep_ext = True
>>> rename2.inputs.subject_id = "subj_201"
>>> rename2.inputs.run = 2
>>> res = rename2.run()          
>>> res.outputs.out_file         
'subj_201_func_run02.nii'        
>>> rename3 = Rename(format_string="%(subject_id)s_%(seq)s_run%(run)02d.nii")
>>> rename3.inputs.in_file = os.path.join(datadir, "func_epi_1_1.nii")
>>> rename3.inputs.parse_string = r"func_(?P<seq>\w*)_.*"
>>> rename3.inputs.subject_id = "subj_201"
>>> rename3.inputs.run = 2
>>> res = rename3.run()          
>>> res.outputs.out_file         
'subj_201_epi_run02.nii'         

References

Adapted from https://github.com/nipy/nipype/blob/cd4c34d935a43812d1756482fdc4034844e485b8/nipype/interfaces/utility/base.py#L232-L272

format_stringa string

Python formatting string for output template.

in_filea pathlike object or string representing an existing file

File to rename.

keep_exta boolean

Keep in_file extension, replace non-extension component of name.

parse_stringa string

Python regexp parse string to define replacement inputs.

use_fullpatha boolean

Use full path as input to regex parser. (Nipype default value: False)

out_filea pathlike object or string representing an existing file

Softlink to original file with new name.