NIPY logo

Table Of Contents

Previous topic

nipype.interfaces.fsl.utils

Next topic

nipype.interfaces.nipy.model

This Page

nipype.interfaces.io

DataGrabber

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

Note

Doesn’t support directories currently

Examples

>>> from nipype.interfaces.io import DataGrabber

Pick all files from current directory

>>> dg = DataGrabber()
>>> dg.inputs.template = '*'

Pick file foo/foo.nii from current directory

>>> dg.inputs.template = '%s/%s.dcm'
>>> dg.inputs.template_args['outfiles']=[['dicomdir','123456-1-1.dcm']]

Same thing but with dynamically created fields

>>> dg = DataGrabber(infields=['arg1','arg2'])
>>> dg.inputs.template = '%s/%s.nii'
>>> dg.inputs.arg1 = 'foo'
>>> dg.inputs.arg2 = 'foo'

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

Dynamically created, user-defined input and output fields

>>> dg = DataGrabber(infields=['sid'], outfields=['func','struct','ref'])
>>> dg.inputs.base_directory = '.'
>>> dg.inputs.template = '%s/%s.nii'
>>> dg.inputs.template_args['func'] = [['sid',['f3','f5']]]
>>> dg.inputs.template_args['struct'] = [['sid',['struct']]]
>>> dg.inputs.template_args['ref'] = [['sid','ref']]
>>> dg.inputs.sid = 's1'

Change the template only for output field struct. The rest use the general template

>>> dg.inputs.field_template = dict(struct='%s/struct.nii')
>>> dg.inputs.template_args['struct'] = [['sid']]

Inputs:

[Mandatory]
template : (a string)
        Layout used to get files. relative to base directory if defined

[Optional]
base_directory : (an existing directory name)
        Path to the base directory consisting of subject data.
raise_on_empty : (a boolean)
        Generate exception if list is empty for a given field
sort_filelist : (a boolean)
        Sort the filelist that matches the template
template_args : (a dictionary with keys which are a string and with values which are a list of items which are a list of items which are any value)
        Information to plug into template

Outputs:

outfiles        Unknown

DataSink

Generic datasink module to store structured outputs

Primarily for use within a workflow. This interface all arbitrary creation of input attributes. The names of these attributes define the directory structure to create for storage of the files or directories.

The attributes take the following form:

string[[.[@]]string[[.[@]]string]] ...

where parts between [] are optional.

An attribute such as contrasts.@con will create a ‘contrasts’ directory to store the results linked to the attribute. If the @ is left out, such as in ‘contrasts.con’ a subdirectory ‘con’ will be created under ‘contrasts’.

Unlike most nipype-nodes this is not a thread-safe node because it can write to a common shared location. It will not complain when it overwrites a file.

Examples

>>> ds = DataSink()
>>> ds.inputs.base_directory = 'results_dir'
>>> ds.inputs.container = 'subject'
>>> ds.inputs.structural = 'structural.nii'
>>> setattr(ds.inputs, 'contrasts.@con', ['cont1.nii', 'cont2.nii'])
>>> setattr(ds.inputs, 'contrasts.alt', ['cont1a.nii', 'cont2a.nii'])
>>> ds.run() 

Inputs:

[Optional]
_outputs : (a dictionary with keys which are a string and with values which are any value)
        Unknown
base_directory : (a directory name)
        Path to the base directory for storing data.
container : (a string)
        Folder within base directory in which to store output
parameterization : (a boolean)
        store output in parameterized structure
remove_dest_dir : (a boolean)
        remove dest directory when copying dirs
strip_dir : (a directory name)
        path to strip out of filename
substitutions : (a tuple of the form: (a string, a string))
        List of 2-tuples reflecting stringto substitute and string to replaceit with

FreeSurferSource

Generates freesurfer subject info from their directories

Examples

>>> from nipype.interfaces.io import FreeSurferSource
>>> fs = FreeSurferSource()
>>> #fs.inputs.subjects_dir = '.'
>>> fs.inputs.subject_id = 'PWS04'
>>> res = fs.run() 
>>> fs.inputs.hemi = 'lh'
>>> res = fs.run() 

Inputs:

[Mandatory]
subject_id : (a string)
        Subject name for whom to retrieve data
subjects_dir : (a directory name)
        Freesurfer subjects directory.

[Optional]
hemi : ('both' or 'lh' or 'rh')
        Selects hemisphere specific outputs

Outputs:

T1 : (an existing file name)
        T1 image
annot : (an existing file name)
        surface annotation files
aparc_aseg : (an existing file name)
        aparc+aseg file
aseg : (an existing file name)
        Auto-seg image
brain : (an existing file name)
        brain only image
brainmask : (an existing file name)
        brain binary mask
curv : (an existing file name)
        surface curvature files
filled : (an existing file name)
        ?
inflated : (an existing file name)
        inflated surface meshes
label : (an existing file name)
        volume and surface label files
norm : (an existing file name)
        intensity normalized image
nu : (an existing file name)
        ?
orig : (an existing file name)
        original image conformed to FS space
pial : (an existing file name)
        pial surface meshes
rawavg : (an existing file name)
        averaged input images to recon-all
ribbon : (an existing file name)
        cortical ribbon
smoothwm : (an existing file name)
        smooth white-matter surface meshes
sphere : (an existing file name)
        spherical surface meshes
sphere_reg : (an existing file name)
        spherical registration file
sulc : (an existing file name)
        surface sulci files
thickness : (an existing file name)
        surface thickness files
volume : (an existing file name)
        surface volume files
white : (an existing file name)
        white matter surface meshes
wm : (an existing file name)
        white matter image
wmparc : (an existing file name)
        white matter parcellation

IOBase

XNATSink

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

Inputs:

[Mandatory]
experiment_id : (a string)
        Set to workflow name
project_id : (a string)
        Project in which to store the outputs
subject_id : (a string)
        Set to subject id
xnat_config : (a file name)
        Unknown
        exclusive: xnat_server
xnat_server : (a string)
        Unknown
        exclusive: xnat_config
        requires: xnat_user,xnat_pwd

[Optional]
_outputs : (a dictionary with keys which are a string and with values which are any value)
        Unknown
cache_dir : (a directory name)

cache_size : (a string)
        Unknown
xnat_pwd : (a string)
        Unknown
xnat_user : (a string)
        Unknown

XNATSource

Generic XNATSource module that wraps around glob in an intelligent way for neuroimaging tasks to grab files

Examples

>>> from nipype.interfaces.io import XNATSource

Pick all files from current directory

>>> dg = XNATSource()
>>> dg.inputs.template = '*'
>>> dg = XNATSource(infields=['project','subject','experiment','assessor','inout'])
>>> dg.inputs.query_template = '/projects/%s/subjects/%s/experiments/%s'                    '/assessors/%s/%s_resources/files'
>>> dg.inputs.project = 'IMAGEN'
>>> dg.inputs.subject = 'IMAGEN_000000001274'
>>> dg.inputs.experiment = '*SessionA*'
>>> dg.inputs.assessor = '*ADNI_MPRAGE_nii'
>>> dg.inputs.inout = 'out'
>>> dg = XNATSource(infields=['sid'],outfields=['struct','func'])
>>> dg.inputs.query_template = '/projects/IMAGEN/subjects/%s/experiments/*SessionA*'                    '/assessors/*%s_nii/out_resources/files'
>>> dg.inputs.query_template_args['struct'] = [['sid','ADNI_MPRAGE']]
>>> dg.inputs.query_template_args['func'] = [['sid','EPI_faces']]
>>> dg.inputs.sid = 'IMAGEN_000000001274'

Inputs:

[Mandatory]
query_template : (a string)
        Layout used to get files. relative to base directory if defined
xnat_config : (a file name)
        Unknown
        exclusive: xnat_server
xnat_server : (a string)
        Unknown
        exclusive: xnat_config
        requires: xnat_user,xnat_pwd

[Optional]
cache_dir : (a directory name)
        Cache directory
cache_size : (a string)
        Optional cache max size
query_template_args : (a dictionary with keys which are a string and with values which are a list of items which are a list of items which are any value)
        Information to plug into template
xnat_pwd : (a string)
        Unknown
xnat_user : (a string)
        Unknown

Outputs:

outfiles        Unknown