NIPY logo

Table Of Contents

Previous topic

nipype.interfaces.freesurfer.model

Next topic

nipype.interfaces.fsl.base

This Page

nipype.interfaces.freesurfer.preprocess

ApplyVolTransform

Wraps command mri_vol2vol

Use FreeSurfer mri_vol2vol to apply a transform.

Examples

>>> from nipype.interfaces.freesurfer import ApplyVolTransform
>>> applyreg = ApplyVolTransform()
>>> applyreg.inputs.source_file = 'structural.nii'
>>> applyreg.inputs.reg_file = 'register.dat'
>>> applyreg.inputs.transformed_file = 'struct_warped.nii'
>>> applyreg.inputs.fs_target = True
>>> applyreg.cmdline
'mri_vol2vol --fstarg --reg register.dat --mov structural.nii --o struct_warped.nii'

Inputs:

[Mandatory]
fs_target : (a boolean)
        use orig.mgz from subject in regfile as target
        exclusive: target_file,tal,fs_target
        requires: reg_file
fsl_reg_file : (an existing file name)
        fslRAS-to-fslRAS matrix (FSL format)
        exclusive: reg_file,fsl_reg_file,xfm_reg_file,reg_header,subject
reg_file : (an existing file name)
        tkRAS-to-tkRAS matrix   (tkregister2 format)
        exclusive: reg_file,fsl_reg_file,xfm_reg_file,reg_header,subject
reg_header : (a boolean)
        ScannerRAS-to-ScannerRAS matrix = identity
        exclusive: reg_file,fsl_reg_file,xfm_reg_file,reg_header,subject
source_file : (an existing file name)
        Input volume you wish to transform
subject : (a string)
        set matrix = identity and use subject for any templates
        exclusive: reg_file,fsl_reg_file,xfm_reg_file,reg_header,subject
tal : (a boolean)
        map to a sub FOV of MNI305 (with --reg only)
        exclusive: target_file,tal,fs_target
target_file : (an existing file name)
        Output template volume
        exclusive: target_file,tal,fs_target
xfm_reg_file : (an existing file name)
        ScannerRAS-to-ScannerRAS matrix (MNI format)
        exclusive: reg_file,fsl_reg_file,xfm_reg_file,reg_header,subject

[Optional]
args : (a string)
        Additional parameters to the command
environ : (a dictionary with keys which are a value of type 'str' and with values which are a value of type 'str')
        Environment variables
interp : ('trilin' or 'nearest')
        Interpolation method (<trilin> or nearest)
inverse : (a boolean)
        sample from target to source
no_resample : (a boolean)
        Do not resample; just change vox2ras matrix
subjects_dir : (an existing directory name)
        subjects directory
transformed_file : (a file name)
        Output volume

Outputs:

transformed_file : (an existing file name)
        Path to output file if used normally

BBRegister

Wraps command bbregister

Use FreeSurfer bbregister to register a volume two a surface mesh

This program performs within-subject, cross-modal registration using a boundary-based cost function. The registration is constrained to be 6 DOF (rigid). It is required that you have an anatomical scan of the subject that has already been recon-all-ed using freesurfer.

Examples

>>> from nipype.interfaces.freesurfer import BBRegister
>>> bbreg = BBRegister(subject_id='me', source_file='structural.nii', init='header', contrast_type='t2')
>>> bbreg.cmdline
'bbregister --t2 --init-header --reg structural_bbreg_me.dat --mov structural.nii --s me'

Inputs:

[Mandatory]
contrast_type : ('t1' or 't2')
        contrast type of image
init_reg_file : (an existing file name)
        existing registration file
        exclusive: init
source_file : (a file name)
        source file to be registered
subject_id : (a string)
        freesurfer subject id

[Optional]
args : (a string)
        Additional parameters to the command
environ : (a dictionary with keys which are a value of type 'str' and with values which are a value of type 'str')
        Environment variables
init : ('spm' or 'fsl' or 'header')
        initialize registration spm, fsl, header
        exclusive: init_reg_file
out_reg_file : (a file name)
        output registration file
registered_file : (a boolean or a file name)
        output warped sourcefile either True or filename
subjects_dir : (an existing directory name)
        subjects directory

Outputs:

min_cost_file : (an existing file name)
        Output registration minimum cost file
out_reg_file : (an existing file name)
        Output registration file
registered_file : (a file name)
        Registered and resampled source file

DICOMConvert

Wraps command mri_convert

use fs mri_convert to convert dicom files

Examples

>>> from nipype.interfaces.freesurfer import DICOMConvert
>>> cvt = DICOMConvert()
>>> cvt.inputs.dicom_dir = 'dicomdir'
>>> cvt.inputs.file_mapping = [('nifti','*.nii'),('info','dicom*.txt'),('dti','*dti.bv*')]

Inputs:

[Mandatory]
base_output_dir : (a directory name)
        directory in which subject directories are created
dicom_dir : (an existing directory name)
        dicom directory from which to convert dicom files

[Optional]
args : (a string)
        Additional parameters to the command
dicom_info : (an existing file name)
        File containing summary information from mri_parse_sdcmdir
environ : (a dictionary with keys which are a value of type 'str' and with values which are a value of type 'str')
        Environment variables
file_mapping : (a list of items which are a tuple of the form: (a string, a string))
        defines the output fields of interface
ignore_single_slice : (a boolean)
        ignore volumes containing a single slice
        requires: dicom_info
out_type : ('cor' or 'mgh' or 'mgz' or 'minc' or 'analyze' or 'analyze4d' or 'spm' or 'afni' or 'brik' or 'bshort' or 'bfloat' or 'sdt' or 'outline' or 'otl' or 'gdf' or 'nifti1' or 'nii' or 'niigz')
        defines the type of output file produced
seq_list : (a list of items which are a string)
        list of pulse sequence names to be converted.
        requires: dicom_info
subject_dir_template : (a string)
        template for subject directory name
subject_id      subject identifier to insert into template
subjects_dir : (an existing directory name)
        subjects directory

MRIConvert

Wraps command mri_convert

use fs mri_convert to manipulate files

Note

Adds niigz as an output type option

Examples

>>> mc = MRIConvert()
>>> mc.inputs.in_file = 'structural.nii'
>>> mc.inputs.out_file = 'outfile.mgz'
>>> mc.inputs.out_type = 'mgz'
>>> mc.cmdline
'mri_convert --out_type mgz --input_volume structural.nii --output_volume outfile.mgz'

Inputs:

[Mandatory]
in_file : (an existing file name)
        File to read/convert

[Optional]
apply_inv_transform : (an existing file name)
        apply inverse transformation xfm file
apply_transform : (an existing file name)
        apply xfm file
args : (a string)
        Additional parameters to the command
ascii : (a boolean)
        save output as ascii col>row>slice>frame
autoalign_matrix : (an existing file name)
        text file with autoalign matrix
color_file : (an existing file name)
        color file
conform : (a boolean)
        conform to 256^3
conform_min : (a boolean)
        conform to smallest size
conform_size : (a float)
        conform to size_in_mm
crop_center : (a tuple of the form: (an integer, an integer, an integer))
        <x> <y> <z> crop to 256 around center (x,y,z)
crop_gdf : (a boolean)
        apply GDF cropping
crop_size : (a tuple of the form: (an integer, an integer, an integer))
        <dx> <dy> <dz> crop to size <dx, dy, dz>
cut_ends : (an integer)
        remove ncut slices from the ends
devolve_transform : (a string)
        subject id
drop_n : (an integer)
        drop the last n frames
environ : (a dictionary with keys which are a value of type 'str' and with values which are a value of type 'str')
        Environment variables
fill_parcellation : (a boolean)
        fill parcellation
force_ras : (a boolean)
        use default when orientation info absent
frame : (an integer)
        keep only 0-based frame number
frame_subsample : (a tuple of the form: (an integer, an integer, an integer))
        start delta end : frame subsampling (end = -1 for end)
fwhm : (a float)
        smooth input volume by fwhm mm
in_center : (a list of at most 3 items which are a float)
        <R coordinate> <A coordinate> <S coordinate>
in_i_dir : (a tuple of the form: (a float, a float, a float))
        <R direction> <A direction> <S direction>
in_i_size : (an integer)
        input i size
in_info : (a boolean)
        display input info
in_j_dir : (a tuple of the form: (a float, a float, a float))
        <R direction> <A direction> <S direction>
in_j_size : (an integer)
        input j size
in_k_dir : (a tuple of the form: (a float, a float, a float))
        <R direction> <A direction> <S direction>
in_k_size : (an integer)
        input k size
in_like : (an existing file name)
        input looks like
in_matrix : (a boolean)
        display input matrix
in_orientation : ('LAI' or 'LAS' or 'RAI' or 'RAS' or 'LPI' or 'LPS' or 'RPI' or 'RPS')
        specify the input orientation
in_scale : (a float)
        input intensity scale factor
in_stats : (a boolean)
        display input stats
in_type : ('cor' or 'mgh' or 'mgz' or 'minc' or 'analyze' or 'analyze4d' or 'spm' or 'afni' or 'brik' or 'bshort' or 'bfloat' or 'sdt' or 'outline' or 'otl' or 'gdf' or 'nifti1' or 'nii' or 'niigz' or 'ge' or 'gelx' or 'lx' or 'ximg' or 'siemens' or 'dicom' or 'siemens+dicom')
        input file type
invert_contrast : (a float)
        threshold for inversting contrast
midframe : (a boolean)
        keep only the middle frame
no_change : (a boolean)
        don't change type of input to that of template
no_scale : (a boolean)
        dont rescale values for COR
no_translate : (a boolean)
        ???
no_write : (a boolean)
        do not write output
out_center : (a tuple of the form: (a float, a float, a float))
        <R coordinate> <A coordinate> <S coordinate>
out_datatype : ('uchar' or 'short' or 'int' or 'float')
        Unknown
out_file : (a file name)
        output filename or True to generate one
out_i_count : (an integer)
        some count ?? in i direction
out_i_dir : (a tuple of the form: (a float, a float, a float))
        <R direction> <A direction> <S direction>
out_i_size : (an integer)
        output i size
out_info : (a boolean)
        display output info
out_j_count : (an integer)
        some count ?? in j direction
out_j_dir : (a tuple of the form: (a float, a float, a float))
        <R direction> <A direction> <S direction>
out_j_size : (an integer)
        output j size
out_k_count : (an integer)
        some count ?? in k direction
out_k_dir : (a tuple of the form: (a float, a float, a float))
        <R direction> <A direction> <S direction>
out_k_size : (an integer)
        output k size
out_matrix : (a boolean)
        display output matrix
out_orientation : ('LAI' or 'LAS' or 'RAI' or 'RAS' or 'LPI' or 'LPS' or 'RPI' or 'RPS')
        specify the output orientation
out_scale : (a float)
        output intensity scale factor
out_stats : (a boolean)
        display output stats
out_type : ('cor' or 'mgh' or 'mgz' or 'minc' or 'analyze' or 'analyze4d' or 'spm' or 'afni' or 'brik' or 'bshort' or 'bfloat' or 'sdt' or 'outline' or 'otl' or 'gdf' or 'nifti1' or 'nii' or 'niigz')
        output file type
parse_only : (a boolean)
        parse input only
read_only : (a boolean)
        read the input volume
reorder : (a tuple of the form: (an integer, an integer, an integer))
        olddim1 olddim2 olddim3
resample_type : ('interpolate' or 'weighted' or 'nearest' or 'sinc' or 'cubic')
        <interpolate|weighted|nearest|sinc|cubic> (default is interpolate)
reslice_like : (an existing file name)
        reslice output to match file
sdcm_list : (an existing file name)
        list of DICOM files for conversion
skip_n : (an integer)
        skip the first n frames
slice_bias : (a float)
        apply half-cosine bias field
slice_crop : (a tuple of the form: (an integer, an integer))
        s_start s_end : keep slices s_start to s_end
slice_reverse : (a boolean)
        reverse order of slices, update vox2ras
smooth_parcellation : (a boolean)
        smooth parcellation
sphinx : (a boolean)
        change orientation info to sphinx
split : (a boolean)
        split output frames into separate output files.
status_file : (a file name)
        status file for DICOM conversion
subject_name : (a string)
        subject name ???
subjects_dir : (an existing directory name)
        subjects directory
template_info : (a boolean)
        dump info about template
template_type : ('cor' or 'mgh' or 'mgz' or 'minc' or 'analyze' or 'analyze4d' or 'spm' or 'afni' or 'brik' or 'bshort' or 'bfloat' or 'sdt' or 'outline' or 'otl' or 'gdf' or 'nifti1' or 'nii' or 'niigz' or 'ge' or 'gelx' or 'lx' or 'ximg' or 'siemens' or 'dicom' or 'siemens+dicom')
        template file type
unwarp_gradient : (a boolean)
        unwarp gradient nonlinearity
vox_size : (a tuple of the form: (a float, a float, a float))
        <size_x> <size_y> <size_z> specify the size (mm) - useful for upsampling or downsampling
zero_ge_z_offset : (a boolean)
        zero ge z offset ???
zero_outlines : (a boolean)
        zero outlines

Outputs:

out_file : (an existing file name)
        converted output file

ParseDICOMDir

Wraps command mri_parse_sdcmdir

Uses mri_parse_sdcmdir to get information from dicom directories

Examples

>>> from nipype.interfaces.freesurfer import ParseDICOMDir
>>> dcminfo = ParseDICOMDir()
>>> dcminfo.inputs.dicom_dir = '.'
>>> dcminfo.inputs.sortbyrun = True
>>> dcminfo.inputs.summarize = True
>>> dcminfo.cmdline
'mri_parse_sdcmdir --d . --o dicominfo.txt --sortbyrun --summarize'

Inputs:

[Mandatory]
dicom_dir : (an existing directory name)
        path to siemens dicom directory

[Optional]
args : (a string)
        Additional parameters to the command
dicom_info_file : (a file name)
        file to which results are written
environ : (a dictionary with keys which are a value of type 'str' and with values which are a value of type 'str')
        Environment variables
sortbyrun : (a boolean)
        assign run numbers
subjects_dir : (an existing directory name)
        subjects directory
summarize : (a boolean)
        only print out info for run leaders

Outputs:

dicom_info_file : (an existing file name)
        text file containing dicom information

ReconAll

Wraps command recon-all

Uses recon-all to generate surfaces and parcellations of structural data from anatomical images of a subject.

Examples

>>> from nipype.interfaces.freesurfer import ReconAll
>>> reconall = ReconAll()
>>> reconall.inputs.subject_id = 'foo'
>>> reconall.inputs.directive = 'all'
>>> reconall.inputs.subjects_dir = '.'
>>> reconall.inputs.T1_files = 'structural.nii'
>>> reconall.cmdline
'recon-all -i structural.nii -all -subjid foo -sd .'

Inputs:

[Mandatory]
directive : ('all' or 'autorecon1' or 'autorecon2' or 'autorecon2-cp' or 'autorecon2-wm' or 'autorecon2-inflate1' or 'autorecon2-perhemi' or 'autorecon3')
        process directive
subject_id : (a string)
        subject name

[Optional]
T1_files : (an existing file name)
        name of T1 file to process
args : (a string)
        Additional parameters to the command
environ : (a dictionary with keys which are a value of type 'str' and with values which are a value of type 'str')
        Environment variables
flags : (a string)
        additional parameters
hemi : ('lh' or 'rh')
        hemisphere to process
subjects_dir : (an existing directory name)
        path to subjects directory

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

Resample

Wraps command mri_convert

Use FreeSurfer mri_convert to up or down-sample image files

Examples

>>> from nipype.interfaces import freesurfer
>>> resampler = freesurfer.Resample()
>>> resampler.inputs.in_file = 'structural.nii'
>>> resampler.inputs.resampled_file = 'resampled.nii'
>>> resampler.inputs.voxel_size = (2.1, 2.1, 2.1)
>>> resampler.cmdline
'mri_convert -vs 2.10 2.10 2.10 -i structural.nii -o resampled.nii'

Inputs:

[Mandatory]
in_file : (an existing file name)
        file to resample
voxel_size : (a tuple of the form: (a float, a float, a float))
        triplet of output voxel sizes

[Optional]
args : (a string)
        Additional parameters to the command
environ : (a dictionary with keys which are a value of type 'str' and with values which are a value of type 'str')
        Environment variables
resampled_file : (a file name)
        output filename
subjects_dir : (an existing directory name)
        subjects directory

Outputs:

resampled_file : (an existing file name)
        output filename

Smooth

Wraps command mris_volsmooth

Use FreeSurfer mris_volsmooth to smooth a volume

This function smoothes cortical regions on a surface and non-cortical regions in volume.

Note

Cortical voxels are mapped to the surface (3D->2D) and then the smoothed values from the surface are put back into the volume to fill the cortical ribbon. If data is smoothed with this algorithm, one has to be careful about how further processing is interpreted.

Examples

>>> from nipype.interfaces.freesurfer import Smooth
>>> smoothvol = Smooth(in_file='functional.nii', smoothed_file = 'foo_out.nii', reg_file='register.dat', surface_fwhm=10, vol_fwhm=6)
>>> smoothvol.cmdline
'mris_volsmooth --i functional.nii --reg register.dat --o foo_out.nii --fwhm 10 --vol-fwhm 6'

Inputs:

[Mandatory]
in_file : (an existing file name)
        source volume
num_iters : (an integer)
        number of iterations instead of fwhm
        exclusive: surface_fwhm
reg_file : (an existing file name)
        registers volume to surface anatomical
surface_fwhm : (a float)
        surface FWHM in mm
        exclusive: num_iters
        requires: reg_file

[Optional]
args : (a string)
        Additional parameters to the command
environ : (a dictionary with keys which are a value of type 'str' and with values which are a value of type 'str')
        Environment variables
proj_frac : (a float)
        project frac of thickness a long surface normal
        exclusive: proj_frac_avg
proj_frac_avg : (a tuple of the form: (a float, a float, a float))
        average a long normal min max delta
        exclusive: proj_frac
smoothed_file : (a file name)
        output volume
subjects_dir : (an existing directory name)
        subjects directory
vol_fwhm : (a float)
        volumesmoothing outside of surface

Outputs:

args : (a string)
        Additional parameters to the command
environ : (a dictionary with keys which are a value of type 'str' and with values which are a value of type 'str')
        Environment variables
smoothed_file : (a file name)
        smoothed input volume
subjects_dir : (an existing directory name)
        subjects directory

UnpackSDICOMDir

Wraps command unpacksdcmdir

Use unpacksdcmdir to convert dicom files

Call unpacksdcmdir -help from the command line to see more information on using this command.

Examples

>>> from nipype.interfaces.freesurfer import UnpackSDICOMDir
>>> unpack = UnpackSDICOMDir()
>>> unpack.inputs.source_dir = '.'
>>> unpack.inputs.output_dir = '.'
>>> unpack.inputs.run_info = (5, 'mprage', 'nii', 'struct')
>>> unpack.inputs.dir_structure = 'generic'
>>> unpack.cmdline
'unpacksdcmdir -generic -targ . -run 5 mprage nii struct -src .'

Inputs:

[Mandatory]
config : (an existing file name)
        specify unpacking rules in file
        exclusive: run_info,config,seq_config
run_info : (a tuple of the form: (an integer, a string, a string, a string))
        runno subdir format name : spec unpacking rules on cmdline
        exclusive: run_info,config,seq_config
seq_config : (an existing file name)
        specify unpacking rules based on sequence
        exclusive: run_info,config,seq_config
source_dir : (an existing directory name)
        directory with the DICOM files

[Optional]
args : (a string)
        Additional parameters to the command
dir_structure : ('fsfast' or 'generic')
        unpack to specified directory structures
environ : (a dictionary with keys which are a value of type 'str' and with values which are a value of type 'str')
        Environment variables
log_file : (an existing file name)
        explicilty set log file
no_info_dump : (a boolean)
        do not create infodump file
no_unpack_err : (a boolean)
        do not try to unpack runs with errors
output_dir : (a directory name)
        top directory into which the files will be unpacked
scan_only : (an existing file name)
        only scan the directory and put result in file
spm_zeropad : (an integer)
        set frame number zero padding width for SPM
subjects_dir : (an existing directory name)
        subjects directory