nipype.interfaces.spm.base module

The spm module provides basic functions for interfacing with SPM tools.

In order to use the standalone MCR version of spm, you need to ensure that the following commands are executed at the beginning of your script:

from nipype.interfaces import spm
matlab_cmd = '/path/to/run_spm8.sh /path/to/Compiler_Runtime/v713/ script'
spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True)

you can test by calling:

spm.SPMCommand().version
class nipype.interfaces.spm.base.ImageFileSPM(value=<traits.trait_type._NoDefaultSpecifiedType object>, exists=False, resolve=False, **metadata)

Bases: nipype.interfaces.base.traits_extension.ImageFile

Defines a trait whose value must be a NIfTI file.

class nipype.interfaces.spm.base.Info

Bases: nipype.interfaces.base.core.PackageInfo

Handles SPM version information

If you use SPMCommand.set_mlab_paths to set alternate entries for matlab_cmd, paths, and use_mcr, then you will need to use the same entries to any call in the Info class to maintain memoization. Otherwise, it will default to the parameters in the getinfo function below.

classmethod getinfo(matlab_cmd=None, paths=None, use_mcr=None)

Returns the path to the SPM directory in the Matlab path If path not found, returns None.

Parameters
  • matlab_cmd (str) – Sets the default matlab command. If None, the value of the environment variable SPMMCRCMD will be used if set and use_mcr is True or the environment variable FORCE_SPMMCR is set. If one of FORCE_SPMMCR or SPMMCRCMD is not set, the existence of the environment variable MATLABCMD is checked and its value is used as the matlab command if possible. If none of the above was successful, the fallback value of ‘matlab -nodesktop -nosplash’ will be used.

  • paths (str) – Add paths to matlab session

  • use_mcr (bool) – Whether to use the MATLAB Common Runtime. In this case, the matlab_cmd is expected to be a valid MCR call.

Returns

spm_path – returns None of path not found

Return type

string representing path to SPM directory

classmethod name(matlab_cmd=None, paths=None, use_mcr=None)
classmethod path(matlab_cmd=None, paths=None, use_mcr=None)
classmethod version(matlab_cmd=None, paths=None, use_mcr=None)

SPMCommand

Link to code

Bases: BaseInterface

Extends BaseInterface class to implement SPM specific interfaces.

WARNING: Pseudo prototype class, meant to be subclassed

Optional Inputs
  • matlab_cmd (a string) – Matlab command to use.

  • mfile (a boolean) – Run m-code using m-file. (Nipype default value: True)

  • paths (a list of items which are a pathlike object or string representing a directory) – Paths to add to matlabpath.

  • use_mcr (a boolean) – Run m-code using SPM MCR.

  • use_v8struct (a boolean) – Generate SPM8 and higher compatible jobs. (Nipype default value: True)

property SPMCommand.jobname
property SPMCommand.jobtype
classmethod SPMCommand.set_mlab_paths(matlab_cmd=None, paths=None, use_mcr=None)
property SPMCommand.version

interfaces should implement a version property

nipype.interfaces.spm.base.func_is_3d(in_file)

Checks if input functional files are 3d.

nipype.interfaces.spm.base.get_first_3dfile(in_files)
nipype.interfaces.spm.base.no_spm()

Checks if SPM is NOT installed used with pytest.mark.skipif decorator to skip tests that will fail if spm is not installed

nipype.interfaces.spm.base.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.base.scans_for_fnames(fnames, keep4d=False, separate_sessions=False)

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

keep4dboolean

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.