NIPY logo

Table Of Contents

Previous topic

interfaces.fsl

Next topic

interfaces.matlab

This Page

interfaces.io

Module: interfaces.io

Inheritance diagram for nipype.interfaces.io:

digraph inheritance38993eeb35 { rankdir=LR; ratio=compress; fontsize=14; size="6.0, 8.0"; "base.Interface" [shape=ellipse,URL="nipype.interfaces.base.html#nipype.interfaces.base.Interface",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "io.DataSource" [shape=ellipse,URL="#nipype.interfaces.io.DataSource",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "base.Interface" -> "io.DataSource" [arrowsize=0.5,style="setlinewidth(0.5)"]; "io.DataSink" [shape=ellipse,URL="#nipype.interfaces.io.DataSink",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "base.Interface" -> "io.DataSink" [arrowsize=0.5,style="setlinewidth(0.5)"]; "io.DataGrabber" [shape=ellipse,URL="#nipype.interfaces.io.DataGrabber",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "base.Interface" -> "io.DataGrabber" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Set of interfaces that allow interaction with data. Currently available interfaces are:

DataSource: Generic nifti to named Nifti interface DataSink: Generic named output from interfaces to data store

To come : XNATSource, XNATSink

Classes

DataGrabber

class nipype.interfaces.io.DataGrabber(*args, **inputs)

Bases: nipype.interfaces.base.Interface

Generic datagrabber module that wraps around glob in an intelligent way for neuroimaging tasks

__init__(*args, **inputs)
aggregate_outputs()
inputs_help()
Parameters:

(all default to None) :

file_template : string

template for filename

template_argtuple: tuple of arguments :

arguments that fit into file_template

template_argnames: list of strings :

provides names of inputs that will be used as arguments to the template. For example,

dg.file_template = ‘%s/%s.nii’

dg.template_argtuple = (‘foo’,’foo’)

is equivalent to

dg.inputs.arg1 = ‘foo’ dg.inputs.arg2 = ‘foo’ dg.inputs.template_argnames = [‘arg1’,’arg2’]

however this latter form can be used with iterables and iterfield in a pipeline.

outputs_help()
Parameters:

(all default to None) :

file_list : list

list of files picked up by the grabber

run(cwd=None)
Execute this module.

DataSink

class nipype.interfaces.io.DataSink(*args, **inputs)

Bases: nipype.interfaces.base.Interface

Generic datasink module that takes a directory containing a list of nifti files and provides a set of structured output fields.

__init__(*args, **inputs)
aggregate_outputs()
inputs_help()
Parameters:

(all default to None) :

base_directory : /path/to/dir

Basedirectory consisting of subject data

subject_id: string or int :

Subject identifier

subject_directory : /path/to/dir

Path to subject directory

Any fields that are set as lists will be copied to a :

directory under subject_directory with the fieldname as a :

new directory. :

outputs_help()
No outputs
run(cwd=None)

Execute this module.

cwd is just there to make things work for now

DataSource

class nipype.interfaces.io.DataSource(*args, **inputs)

Bases: nipype.interfaces.base.Interface

Generic datasource module that takes a directory containing a list of nifti files and provides a set of structured output fields.

__init__(*args, **inputs)
aggregate_outputs()
inputs_help()
Parameters:

base_directory : str

Path to the base directory consisting of subject data.

subject_template : str

Template encoding the subject directory name, indexed by subject id.

file_template : str

Template used for matching filenames. Default = ‘-%d-.nii’

subject_id: str or int :

The subject identifier.

subject_directory : str

Path to the subject directory.

subject_info : dict

Provides information about how to map subject run numbers to the output fields.

subject_id are keys and the values are a list of tuples. info[subject_id] = [([run_identifiers], output_fieldname), ...]

Examples

Here our experiment data is stored in our home directory under ‘data/exp001’. In the exp001 directory we have a subdirectory for our subject named ‘s1’. In the ‘s1’ directory we have four functional images, ‘f3’, ‘f5’, ‘f7’, ‘f10’. In the info dictionary we create an entry where the key is the subject identifier ‘s1’, and the value is a list of one element, a tuple containing a list of the functional image names and a field name ‘func’. The ‘func’ field name is the output field name for this datasource object. So for instance, if we were doing motion correction using SPM realign, the datasource output ‘func’ would map to the realign input ‘infile’ in the pipeline.

>>> from nipype.interfaces.io import DataSource
>>> info = {}
>>> info['s1'] = [(['f3', 'f5', 'f7', 'f10'], 'func')]
>>> datasource = DataSource()
>>> data_dir = os.path.expanduser('~/data/exp001')
>>> datasource.inputs.base_directory = data_dir
>>> datasource.inputs.subject_template = '%s'
>>> datasource.inputs.file_template = '%s.nii'
>>> datasource.inputs.subject_info = info
>>> datasource.inputs.subject_id = 's1'
outputs_help()
Parameters:

(all default to None) :

subject_id : string

Subject identifier

subject_directory: /path/to/dir :

Location of subject directory containing nifti files

remaining fields are defined by user. See subject_info in :

inputs_help() for description of how to specify output :

fields :

run(cwd=None)

Execute this module.

cwd is just there to make things “work” for now