NIPY logo

Table Of Contents

Previous topic

interfaces.rest

Next topic

pipeline.engine

This Page

interfaces.spm

Module: interfaces.spm

Inheritance diagram for nipype.interfaces.spm:

digraph inheritance0d972fa64e { rankdir=LR; ratio=compress; fontsize=14; size="6.0, 8.0"; "spm.SpmInfo" [shape=ellipse,URL="#nipype.interfaces.spm.SpmInfo",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" [shape=ellipse,URL="#nipype.interfaces.spm.SpmMatlabCommandLine",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "matlab.MatlabCommandLine" -> "spm.SpmMatlabCommandLine" [arrowsize=0.5,style="setlinewidth(0.5)"]; "spm.EstimateContrast" [shape=ellipse,URL="#nipype.interfaces.spm.EstimateContrast",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" -> "spm.EstimateContrast" [arrowsize=0.5,style="setlinewidth(0.5)"]; "spm.EstimateModel" [shape=ellipse,URL="#nipype.interfaces.spm.EstimateModel",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" -> "spm.EstimateModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "spm.SpecifyModel" [shape=ellipse,URL="#nipype.interfaces.spm.SpecifyModel",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "base.Interface" -> "spm.SpecifyModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "spm.Segment" [shape=ellipse,URL="#nipype.interfaces.spm.Segment",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" -> "spm.Segment" [arrowsize=0.5,style="setlinewidth(0.5)"]; "matlab.MatlabCommandLine" [shape=ellipse,URL="nipype.interfaces.matlab.html#nipype.interfaces.matlab.MatlabCommandLine",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "base.CommandLine" -> "matlab.MatlabCommandLine" [arrowsize=0.5,style="setlinewidth(0.5)"]; "spm.Realign" [shape=ellipse,URL="#nipype.interfaces.spm.Realign",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" -> "spm.Realign" [arrowsize=0.5,style="setlinewidth(0.5)"]; "spm.Normalize" [shape=ellipse,URL="#nipype.interfaces.spm.Normalize",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" -> "spm.Normalize" [arrowsize=0.5,style="setlinewidth(0.5)"]; "spm.TwoSampleTTest" [shape=ellipse,URL="#nipype.interfaces.spm.TwoSampleTTest",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" -> "spm.TwoSampleTTest" [arrowsize=0.5,style="setlinewidth(0.5)"]; "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]; "spm.Level1Design" [shape=ellipse,URL="#nipype.interfaces.spm.Level1Design",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" -> "spm.Level1Design" [arrowsize=0.5,style="setlinewidth(0.5)"]; "spm.OneSampleTTest" [shape=ellipse,URL="#nipype.interfaces.spm.OneSampleTTest",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" -> "spm.OneSampleTTest" [arrowsize=0.5,style="setlinewidth(0.5)"]; "base.CommandLine" [shape=ellipse,URL="nipype.interfaces.base.html#nipype.interfaces.base.CommandLine",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "base.Interface" -> "base.CommandLine" [arrowsize=0.5,style="setlinewidth(0.5)"]; "spm.Coregister" [shape=ellipse,URL="#nipype.interfaces.spm.Coregister",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" -> "spm.Coregister" [arrowsize=0.5,style="setlinewidth(0.5)"]; "spm.Smooth" [shape=ellipse,URL="#nipype.interfaces.spm.Smooth",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "spm.SpmMatlabCommandLine" -> "spm.Smooth" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

The spm module provides basic functions for interfacing with matlab and spm to access spm tools.

These functions include:

  • Realign: within-modality registration
  • Coregister: between modality registration
  • Normalize: non-linear warping to standard space
  • Segment: bias correction, segmentation
  • Smooth: smooth with Gaussian kernel

Classes

Coregister

class nipype.interfaces.spm.Coregister(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.spm.SpmMatlabCommandLine

Use spm_coreg for estimating cross-modality rigid body alignment

See Coregister().spm_doc() for more information.

Parameters:

inputs : dict

key, value pairs that will update the Coregister.inputs attributes. See self.inputs_help() for a list of Coregister.inputs attributes

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_coreg via a job structure

cmdline : str

String used to call matlab/spm via SpmMatlabSpmMatlabCommandLine interface

__init__(matlab_cmd=None, **inputs)
aggregate_outputs()
cmd
cmdline
get_input_info()
Provides information about inputs as a dict info = [Bunch(key=string,copy=bool,ext=’.nii’),...]
inputs_help()
Parameters:

target : string

Filename of nifti image to coregister to. Also referred to as the reference image or the template image.

source : string

Filename of nifti image to coregister to the target image.

apply_to_files : list, optional

list of filenames to apply the estimated rigid body transform from source to target

write : bool, optional

if True updates headers and generates resliced files prepended with ‘r’ if False just updates header files (default == True, will reslice)

cost_function : string, optional

maximise or minimise some objective function. Valid options are Mutual Information (mi), Normalised Mutual Information (nmi), or Entropy Correlation Coefficient (ecc) and Normalised Cross Correlation (ncc). (spm default = nmi)

separation : float, optional

separation in mm used to sample images (spm default = 4.0)

tolerance : list of 12 floats

The acceptable tolerance for each of the 12 parameters.

fwhm : float, optional

full width half maximum gaussian kernel used to smooth images before coregistering (spm default = 5.0)

write_interp : int, optional

degree of b-spline used for interpolation when writing resliced images (0 - Nearest neighbor, 1 - Trilinear, 2-7 - degree of b-spline) (spm default = 0 - Nearest Neighbor)

write_wrap : list, optional

Check if interpolation should wrap in [x,y,z] (spm default [0,0,0])

write_mask : bool, optional

if True, mask output image, if False, do not mask. (spm default = False)

flags : USE AT OWN RISK

jobname
jobtype
outputs()
Parameters:

coregistered_source : :

coregistered source file

coregistered_files : :

coregistered files corresponding to inputs.infile

outputs_help()
Prints the help of outputs
run(target=None, source=None, **inputs)

Executes the SPM coregister function using MATLAB

Parameters:

target: string, list :

image file to coregister source to

source: string, list :

image file that will be coregistered to the template

set_matlabcmd(cmd)
reset the base matlab command
spm_doc()
Print out SPM documentation.

EstimateContrast

class nipype.interfaces.spm.EstimateContrast(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.spm.SpmMatlabCommandLine

use spm_contrasts to estimate contrasts of interest

Parameters:

inputs : dict

key, value pairs that will update the EstimateContrast.inputs attributes. See self.inputs_help() for a list of EstimateContrast.inputs attributes.

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_spm via a job structure

cmdline : str

String used to call matlab/spm via SpmMatlabCommandLine interface

__init__(matlab_cmd=None, **inputs)
aggregate_outputs()
cmd
cmdline
get_input_info()
Provides information about inputs as a dict info = [Bunch(key=string,copy=bool,ext=’.nii’),...]
inputs_help()
Parameters:

spm_mat_file : filename

Filename containing absolute path to SPM.mat

contrasts : list of dicts

List of contrasts with each contrast being a list of the form - [‘name’, ‘stat’, [condition list], [weight list], [session list]]. if session list is None or not provided, all sessions are used. For F contrasts, the condition list should contain previously defined T-contrasts.

beta_images: filenames :

Parameter estimates for each column of the design matrix

residual_image: filename :

Mean-squared image of the residuals from each time point

RPVimage: filename :

Resels per voxel image

ignore_derivs : boolean

Whether to ignore derivatives from contrast estimation. default : True

jobname
jobtype
outputs()
Parameters:

(all default to None) :

con_images: :

contrast images from a t-contrast

spmT_images: :

stat images from a t-contrast

ess_images: :

contrast images from an F-contrast

spmF_images: :

stat images from an F-contrast

outputs_help()
Prints the help of outputs
run(**inputs)
Executes the SPM function using MATLAB
set_matlabcmd(cmd)
reset the base matlab command

EstimateModel

class nipype.interfaces.spm.EstimateModel(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.spm.SpmMatlabCommandLine

Use spm_spm to estimate the parameters of a model

See EstimateModel().spm_doc() for more information.

Parameters:

inputs : dict

key, value pairs that will update the EstimateModel.inputs attributes. See self.inputs_help() for a list of attributes.

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_spm via a job structure

cmdline : string

string used to call matlab/spm via SpmMatlabCommandLine interface

__init__(matlab_cmd=None, **inputs)
aggregate_outputs()
cmd
cmdline
get_input_info()
Provides information about inputs as a dict info = [Bunch(key=string,copy=bool,ext=’.nii’),...]
inputs_help()
Parameters:

spm_design_file : filename

Filename containing absolute path to SPM.mat

estimation_method: dict :

Estimate the specified model using one of three different SPM options:

{'Classical' : 1}
{'Bayesian2' : 1}
{'Bayesian' : dict}
    USE IF YOU KNOW HOW TO SPECIFY PARAMETERS

flags : USE AT OWN RISK

#eg:’flags’:{‘eoptions’:{‘suboption’:value}}

jobname
jobtype
outputs()
Parameters:

(all default to None) :

mask_image: :

binary brain mask within which estimation was performed

beta_images: :

Parameter estimates for each column of the design matrix

residual_image: :

Mean-squared image of the residuals from each time point

RPVimage: :

Resels per voxel image

spm_mat_file: :

Updated SPM mat file

outputs_help()
Prints the help of outputs
run(**inputs)
Executes the SPM function using MATLAB
set_matlabcmd(cmd)
reset the base matlab command
spm_doc()
Print out SPM documentation.

Level1Design

class nipype.interfaces.spm.Level1Design(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.spm.SpmMatlabCommandLine

Generate an SPM design matrix

See Level1Design().spm_doc() for more information.

Parameters:

inputs : dict

key, value pairs that will update the Level1Design.inputs attributes. See self.inputs_help() for a list of Level1Design.inputs attributes.

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_smooth via a job structure

cmdline : str

String used to call matlab/spm via SpmMatlabCommandLine interface

__init__(matlab_cmd=None, **inputs)
aggregate_outputs()
cmd
cmdline
get_input_info()

Provides information about file inputs to copy or link to cwd.

Notes

see spm.Realign.get_input_info

inputs_help()
Parameters:

spmmat_dir : string

directory in which to store the SPM.mat file

timing_units : string

units for specification of onsets or blocks (scans or secs)

interscan_interval : float (in secs)

Interscan interval, TR.

microtime_resolution : float (in secs)

Specifies the number of time-bins per scan when building regressors. spm default = 16

microtime_onset : float (in secs)

Specifies the onset/time-bin to which the regressors are aligned.

session_info : list of dicts

Stores session specific information

Session parameters

nscan : int

Number of scans in a session

scans : list of filenames

A single 4D nifti file or a list of 3D nifti files

hpf : float

High pass filter cutoff SPM default = 128 secs

condition_info : mat filename or list of dicts

The output of SpecifyModel generates this information.

regressor_info : mat/txt filename or list of dicts

Stores regressor specific information The output of Specify>odel generates this information.

factor_info : list of dicts

Stores factor specific information

Factor parameters

name : string

Name of factor (use condition name)

levels: int

Number of levels for the factor

bases : dict {‘name’:{‘basesparam1’:val,...}}

name : string

Name of basis function (hrf, fourier, fourier_han, gamma, fir)

hrf :
derivs : 2-element list

Model HRF Derivatives. No derivatives: [0,0], Time derivatives : [1,0], Time and Dispersion derivatives: [1,1]

fourier, fourier_han, gamma, fir:
length : int

Post-stimulus window length (in seconds)

order : int

Number of basis functions

volterra_expansion_order : int

Do not model interactions (1) or model interactions (2) SPM default = 1

global_intensity_normalization : string

Global intensity normalization (scaling or none) SPM default = none

mask_image : filename

Specify an image for explicitly masking the analysis. NOTE: spm will still threshold within this mask.

mask_threshold : float

Option to modify SPM’s default thresholding for the mask.

model_serial_correlations : string

Option to model serial correlations using an autoregressive estimator. AR(1) or none SPM default = AR(1)

flags : USE AT OWN RISK

#eg:’flags’:{‘eoptions’:{‘suboption’:value}}

jobname
jobtype
outputs()
Parameters:

spm_mat_file : str

SPM mat file

outputs_help()
Prints the help of outputs
run(**inputs)
Executes the SPM function using MATLAB
set_matlabcmd(cmd)
reset the base matlab command
spm_doc()
Print out SPM documentation.

Normalize

class nipype.interfaces.spm.Normalize(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.spm.SpmMatlabCommandLine

use spm_normalise for warping an image to a template

See Normalize().spm_doc() for more information.

Parameters:

inputs : dict

key, value pairs that will update the Normalize.inputs attributes. See self.inputs_help() for a list of Normalize.inputs attributes.

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_normalise via a job structure

cmdline : str

String used to call matlab/spm via SpmMatlabCommandLine interface

__init__(matlab_cmd=None, **inputs)
aggregate_outputs()
cmd
cmdline
get_input_info()
Provides information about inputs as a dict info = [Bunch(key=string,copy=bool,ext=’.nii’),...]
inputs_help()
Parameters:

template : string

filename of nifti image to normalize to

source : string

filename of nifti image to normalize

apply_to_files : list, optional

list of filenames to apply the estimated normalization

write : bool, optional

if True updates headers and generates resliced files prepended with ‘r’ if False just updates header files (default == True, will reslice)

source_weight : string, optional

name of weighting image for source

template_weight : string, optional

name of weighting image for template

source_image_smoothing : float, optional

template_image_smoothing : float, optional

affine_regularization_type : string, optional

ICBM space template (mni), average sized template (size), no regularization (none)

DCT_period_cutoff : int, optional

Cutoff of for DCT bases. spm default = 25

num_nonlinear_iterations : int, optional

Number of iterations of nonlinear warping spm default = 16

nonlinear_regularization : float, optional

min = 0 max = 1 spm default = 1

write_preserve : boolean, optional

Indicates whether warped images are modulated. spm default = 0

write_bounding_box : 6-element list, optional

write_voxel_sizes : 3-element list, optional

write_interp : int, optional

degree of b-spline used for interpolation when writing resliced images (0 - Nearest neighbor, 1 - Trilinear, 2-7 - degree of b-spline) (spm default = 0 - Nearest Neighbor)

write_wrap : list, optional

Check if interpolation should wrap in [x,y,z] (spm default [0,0,0])

flags : USE AT OWN RISK, optional

#eg:’flags’:{‘eoptions’:{‘suboption’:value}}

jobname
jobtype
outputs()
Parameters:

(all default to None) :

normalization_parameters : :

MAT file containing the normalization parameters

normalized_source : :

normalized source file

normalized_files : :

normalized files corresponding to inputs.apply_to_files

outputs_help()
Prints the help of outputs
run(template=None, source=None, **inputs)

Executes the SPM normalize function using MATLAB

Parameters:

template: string, list containing 1 filename :

template image file to normalize to

source: source image file that is normalized :

to template.

set_matlabcmd(cmd)
reset the base matlab command
spm_doc()
Print out SPM documentation.

OneSampleTTest

class nipype.interfaces.spm.OneSampleTTest(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.spm.SpmMatlabCommandLine

use spm to perform a one-sample ttest on a set of images

Parameters:

inputs : dict

key, value pairs that will update the EstimateContrast.inputs attributes. See self.inputs_help() for a list of EstimateContrast.inputs attributes.

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_spm via a job structure

cmdline : str

String used to call matlab/spm via SpmMatlabCommandLine interface

__init__(matlab_cmd=None, **inputs)
aggregate_outputs()
cmd
cmdline
get_input_info()

Provides information about file inputs to copy or link to cwd.

Notes

see spm.Realign.get_input_info

inputs_help()
Parameters:con_images: list of filenames :
jobname
the jobname used by spm/matlab to specify the jobname to run jobs{1}.jobtype{1}.jobname
jobtype
outputs()
Parameters:

(all default to None) :

con_images: :

contrast images from a t-contrast

spmT_images: :

stat images from a t-contrast

outputs_help()
Prints the help of outputs
run(**inputs)
Executes the SPM function using MATLAB
set_matlabcmd(cmd)
reset the base matlab command

Realign

class nipype.interfaces.spm.Realign(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.spm.SpmMatlabCommandLine

Use spm_realign for estimating within modality rigid body alignment

See Realign().spm_doc() for more information.

Parameters:

inputs : dict

key, value pairs that will update the Realign.inputs attributes. See self.inputs_help() for a list of attributes

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_realign via a job structure

cmdline : str

String used to call matlab/spm via SpmMatlabCommandLine interface

Other Parameters :

————— :

To see optional arguments :

Realign().inputs_help() :

To see output fields :

Realign().outputs_help() :

Examples

>>> import nipype.interfaces.spm as spm
>>> realign = spm.Realign()
>>> realign.inputs.infile = 'a.nii'
>>> realign.run() # doctest: +SKIP
__init__(matlab_cmd=None, **inputs)
aggregate_outputs()
Initializes the output fields for this interface and then searches for and stores the data that go into those fields.
cmd
cmdline
get_input_info()
Provides information about inputs info = [Bunch(key=string,copy=bool,ext=’.nii’),...]
inputs_help()
Parameters:

infile: string, list :

list of filenames to realign

write : bool, optional

if True updates headers and generates resliced files prepended with ‘r’ if False just updates header files (default == True, will reslice)

quality : float, optional

0.1 = fastest, 1.0 = most precise (spm5 default = 0.9)

fwhm : float, optional

full width half maximum gaussian kernel used to smooth images before realigning (spm default = 5.0)

separation : float, optional

separation in mm used to sample images (spm default = 4.0)

register_to_mean: Bool, optional :

rtm if True uses a two pass method realign -> calc mean -> realign all to mean (spm default = False)

weight_img : file, optional

filename of weighting image if empty, no weighting (spm default = None)

wrap : list, optional

Check if interpolation should wrap in [x,y,z] (spm default [0,0,0])

interp : float, optional

degree of b-spline used for interpolation (spm default = 2.0)

write_which : list of len()==2, optional

if write is true, [inputimgs, mean] [2,0] reslices all images, but not mean [2,1] reslices all images, and mean [1,0] reslices imgs 2:end, but not mean [0,1] doesnt reslice any but generates resliced mean

write_interp : float, optional

degree of b-spline used for interpolation when writing resliced images (spm default = 4.0)

write_wrap : list, optional

Check if interpolation should wrap in [x,y,z] (spm default [0,0,0])

write_mask : bool, optional

if True, mask output image if False, do not mask

flags : USE AT OWN RISK, optional

#eg:’flags’:{‘eoptions’:{‘suboption’:value}}

jobname
jobtype
outputs()
Parameters:

realigned_files : :

list of realigned files

mean_image : :

mean image file from the realignment process

realignment_parameters : rp*.txt

files containing the estimated translation and rotation parameters

outputs_help()
Prints the help of outputs
run(infile=None, **inputs)

Executes the SPM realign function using MATLAB

Parameters:

infile: string, list :

list of filenames to realign

set_matlabcmd(cmd)
reset the base matlab command
spm_doc()
Print out SPM documentation.

Segment

class nipype.interfaces.spm.Segment(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.spm.SpmMatlabCommandLine

use spm_segment to separate structural images into different tissue classes.

See Segment().spm_doc() for more information.

Parameters:

inputs : dict

key, value pairs that will update the Segment.inputs attributes. See self.inputs_help() for a list of Segment.inputs attributes.

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_segment via a job structure

cmdline : str

String used to call matlab/spm via SpmMatlabCommandLine interface

__init__(matlab_cmd=None, **inputs)
aggregate_outputs()
cmd
cmdline
get_input_info()
Provides information about inputs as a dict info = [Bunch(key=string,copy=bool,ext=’.nii’),...]
inputs_help()
Parameters:

data : structural image file

One scan per subject

gm_output_type : 3-element list, optional

Options to produce grey matter images: c1*.img, wc1*.img and mwc1*.img. None: [0,0,0], Native Space: [0,0,1], Unmodulated Normalised: [0,1,0], Modulated Normalised: [1,0,0], Native + Unmodulated Normalised: [0,1,1], Native + Modulated Normalised: [1,0,1], Native + Modulated + Unmodulated: [1,1,1], Modulated + Unmodulated Normalised: [1,1,0]

wm_output_type : 3-element list, optional

Options to produce white matter images: c2*.img, wc2*.img and mwc2*.img. Same as GM options

csf_output_type : 3-element list, optional

Options to produce CSF images: c3*.img, wc3*.img and mwc3*.img. Same as GM options

save_bias_corrected : bool, optional

Option to produce a bias corrected image.

clean_masks : int, optional

Option to clean the gray and white matter masks using an estimated brain mask. Dont do cleanup (0), Light Clean (1), Thorough Clean (2)

tissue_prob_maps : list of filenames, optional

Provide maps of grey matter, white matter and cerebro-spinal fluid probability.

gaussians_per_class : 4-element list, optional

The number of Gaussians used to represent the intensity distribution for each tissue class.

affine_regularization : string, optional

No Affine Registration (‘’), ICBM space template - European brains (mni), ICBM space template - East Asian brains (eastern), Average sized template: (subj), No regularisation (none)

warping_regularization : float, optional

Controls balance between parameters and data. spm default = 1

warp_frequency_cutoff : int, optional

Cutoff of DCT bases.

bias_regularization : float, optional

no regularisation (0), extremely light regularisation (0.00001), very light regularisation (0.0001), light regularisation (0.001), medium regularisation (0.01), heavy regularisation (0.1), very heavy regularisation (1), extremely heavy regularisation (10).

bias_fwhm : int, optional

FWHM of Gaussian smoothness of bias. 30mm to 150mm cutoff: (30-150 in steps of 10), No correction (inf).

sampling_distance : float, optional

Sampling distance on data for parameter estimation.

mask_image : filename, optional

An binary image to restrict parameter estimation to certain parts of the brain.

flags : USE AT OWN RISK, optional

#eg:’flags’:{‘eoptions’:{‘suboption’:value}}

jobname
jobtype
outputs()
Parameters:

(all default to None) :

native_class_images : :

native space images for each of the three tissue types

normalized_class_images : :

normalized class images for each of the three tissue types

modulated_class_images : :

modulated, normalized class images for each of the three tissue types

modulated_input_images : :

modulated version of input image

transformation_mat : :

Transformation file for normalizing image

inverse_transformation_mat : :

Transformation file for inverse normalizing an image

outputs_help()
Prints the help of outputs
run(data=None, **inputs)

Executes the SPM segment function using MATLAB

Parameters:

data: string, list :

image file to segment

set_matlabcmd(cmd)
reset the base matlab command
spm_doc()
Print out SPM documentation.

Smooth

class nipype.interfaces.spm.Smooth(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.spm.SpmMatlabCommandLine

use spm_smooth for 3D Gaussian smoothing of image volumes.

See Smooth().spm_doc() for more information.

Parameters:

inputs : dict

key, value pairs that will update the Smooth.inputs attributes. See self.inputs_help() for a list of Smooth.inputs attributes.

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_smooth via a job structure

cmdline : str

String used to call matlab/spm via SpmMatlabCommandLine interface

__init__(matlab_cmd=None, **inputs)
aggregate_outputs()
cmd
cmdline
get_input_info()
Provides information about inputs as a dict info = [Bunch(key=string,copy=bool,ext=’.nii’),...]
inputs_help()
Parameters:

infile : list

list of filenames to apply smoothing

fwhm : 3-list, optional

list of fwhm for each dimension

data_type : int, optional

Data type of the output images. A value of 0 specifies to use the same data type as the original images. Integer values are based on the NIfTI-1 specification:

  2 = uint8
  4 = int16
  8 = int32
 16 = float32
 64 = float64
256 = int8
512 = uint16
768 = uint32

(spm default = 0, same data type as original image)

flags : USE AT OWN RISK, optional

#eg:’flags’:{‘eoptions’:{‘suboption’:value}}

jobname
jobtype
outputs()
Parameters:

(all default to None) :

smoothed_files : :

smooth files corresponding to inputs.infile

outputs_help()
Prints the help of outputs
run(infile=None, **inputs)

Executes the SPM smooth function using MATLAB

Parameters:

infile: string, list :

image file(s) to smooth

set_matlabcmd(cmd)
reset the base matlab command
spm_doc()
Print out SPM documentation.

SpecifyModel

class nipype.interfaces.spm.SpecifyModel(*args, **inputs)

Bases: nipype.interfaces.base.Interface

Makes a model specification SPM specific

See SpecifyModel().spm_doc() for more information.

Parameters:

inputs : dict

key, value pairs that will update the SpecifyModel.inputs attributes. See self.inputs_help() for a list attributes.

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_spm via a job structure

cmdline : str

String used to call matlab/spm via SpmMatlabCommandLine interface

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

subject_id : string or int

Subject identifier used as a parameter to the subject_info_func.

subject_info_func : function

Returns subject specific condition information. If all subjects had the same stimulus presentation schedule, then this function can return the same structure independent of the subject. This function must retun a list of dicts with the list length equal to the number of sessions. The dicts should contain the following information.

conditions : list of names

onsets : lists of onsets corresponding to each

condition

durations : lists of durations corresponding to each

condition. Should be left to a single 0 if all events are being modeled as impulses.

amplitudes : lists of amplitudes for each event. This

is ignored by SPM

tmod : lists of conditions that should be temporally

modulated. Should default to None if not being used.

pmod : list of dicts corresponding to conditions

name : name of parametric modulator

param : values of the modulator

poly : degree of modulation

regressors : list of dicts or matfile
names : list of names corresponding to each

column. Should be None if automatically assigned.

values : lists of values for each regressor

matfile : MAT-file containing names and a matrix

called R

realignment_parameters : list of files

Realignment parameters returned by some motion correction algorithm. Assumes that each file is a text file containing a row of translation and rotation parameters.

outlier_files : list of files

A list of files containing outliers that should be tossed. One file per session.

functional_runs : list of files

List of data files for model. One file per session

input_units : string

Units of event onsets and durations (secs or scans) as returned by the subject_info_func

output_units : string

Units of event onsets and durations (secs or scans) as sent to SPM design

high_pass_filter_cutoff : float, optional

High-pass filter cutoff in secs

polynomial_order : int, optional

Number of polynomial functions used to model high pass filter.

concatenate_runs : boolean, optional

Allows concatenating all runs to look like a single expermental session.

time_repetition : float

Time between the start of one volume to the start of the next image volume. If a clustered acquisition is used, then this should be the time between the start of acquisition of one cluster to the start of acquisition of the next cluster.

Sparse and clustered-sparse specific options :

time_acquisition : float

Time in seconds to acquire a single image volume

volumes_in_cluster : int

If number of volumes in a cluster is greater than one, then a sparse-clustered acquisition is being assumed.

model_hrf : boolean

Whether to model hrf for sparse clustered analysis

stimuli_as_impulses : boolean

Whether to treat each stimulus to be impulse like. If not, the stimuli are convolved with their respective durations.

scan_onset : float

Start of scanning relative to onset of run in secs. default = 0

outputs()
Parameters:

(all default to None) :

session_info: :

Python dict storing session info for input to spm.Level1Design.inputs.session_info

run(**inputs)
spm_doc()
Print out SPM documentation.

SpmInfo

class nipype.interfaces.spm.SpmInfo

Bases: object

Return the path to the spm directory in the matlab path If path not found, prints error asn returns None

__init__()
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
static spm_path()

SpmMatlabCommandLine

class nipype.interfaces.spm.SpmMatlabCommandLine(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.matlab.MatlabCommandLine

Extends the MatlabCommandLine class to handle SPM specific formatting of matlab scripts.

__init__(matlab_cmd=None, **inputs)
aggregate_outputs()

Collects all the outputs produced by an SPM function

Virtual function that needs to be implemented by the subclass to collate outputs created generated by the SPM functionality being wrapped.

cmdline
get_input_info()

Provides information about file inputs to copy or link to cwd.

Notes

see spm.Realign.get_input_info

inputs_help()
Parameters:

(all default to None and are unset) :

script_lines : string

matlab_script or function name or matlab code to run

cwd : string

working directory for command

jobname
the jobname used by spm/matlab to specify the jobname to run jobs{1}.jobtype{1}.jobname
jobtype
the jobtype used by spm/matlab to specify the jobtype to run jobs{1}.jobtype{1}.jobname
outputs()
outputs_help()
Prints the help of outputs
run(**inputs)
Executes the SPM function using MATLAB
set_matlabcmd(cmd)
reset the base matlab command

TwoSampleTTest

class nipype.interfaces.spm.TwoSampleTTest(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.spm.SpmMatlabCommandLine

use spm to perform a two-sample ttest on a set of images

Parameters:

inputs : dict

key, value pairs that will update the EstimateContrast.inputs attributes. See self.inputs_help() for a list of EstimateContrast.inputs attributes.

Attributes:

inputs : nipype.interfaces.base.Bunch

Options that can be passed to spm_spm via a job structure

cmdline : str

String used to call matlab/spm via SpmMatlabCommandLine interface

__init__(matlab_cmd=None, **inputs)
aggregate_outputs()
cmd
cmdline
get_input_info()

Provides information about file inputs to copy or link to cwd.

Notes

see spm.Realign.get_input_info

inputs_help()
Parameters:

images_group1: list of filenames :

images_group2: list of filenames :

dependent: bool, optional :

are the measurements independent between levels SPM default: False

unequal_variance: bool, optional :

are the variances equal or unequal between groups SPM default: True

jobname
the jobname used by spm/matlab to specify the jobname to run jobs{1}.jobtype{1}.jobname
jobtype
outputs()
Parameters:

(all default to None) :

con_images: :

contrast images from a t-contrast

spmT_images: :

stat images from a t-contrast

outputs_help()
Prints the help of outputs
run(**inputs)
Executes the SPM function using MATLAB
set_matlabcmd(cmd)
reset the base matlab command

Functions

nipype.interfaces.spm.scans_for_fname(fname)

Reads a nifti file and converts it to a numpy array storing individual nifti volumes

Opens images so will fail if they are not found

nipype.interfaces.spm.scans_for_fnames(fnames, keep4d=False, separate_sessions=False)

Converts a list of files to a concatenated numpy array for each volume.

keep4d : boolean
keeps the entries of the numpy array as 4d files instead of extracting the individual volumes.
separate_sessions: boolean
if 4d nifti files are being used, then separate_sessions ensures a cell array per session is created in the structure.