Table Of Contents

Previous topic

Spatially restricting analyses

Next topic

Building ROIs in MarsBaR

Viewing or changing SPM Defaults

The default values SPM uses for a number of routines are stored in a global variable called “defaults”, and set using spm_defaults.m. There are three basic ways to change the default value for something:

  1. Edit spm_defaults.m
  2. Create a custom version of spm_defaults.m
  3. Change the value using the Matlab command line

Editing spm_defaults.m

The defaults are stored in SPMDIR/spm_defaults.m. If you have permission to edit this file, you can simply change the values here, and that will affect all new SPM sessions. Note that if there are other people using the same SPM installation, this will also affect their analyses, so you may not want to do this without checking with them.

Creating a custom version of spm_defaults.m

SPM will use the spm_defaults.m that is first in the Matlab path. If you create your own copy of spm_defaults.m that occurs first in the path, SPM will use this. The current directory is always the first thing in Matlab’s path, so creating it in the current directory should always work. You can check which version of spm_defaults.m SPM is using by typing which spm_defaults from the command prompt:

>> pwd

ans =


>> which spm_defaults
>> !cp /usr/local/spm8/spm_defaults.m .
>> which spm_defaults

In the above example, you could then edit /home/peelle/spm_defaults.m to update any values you wanted (assuming you run SPM from this directory!).

Changing default values from the Matlab command line

If you have SPM running already, you can change defaults (for the current session only) from the command prompt. The first thing to do is tell Matlab that you want access to the global variable called “defaults”:

>> who
>> global defaults
>> who

Your variables are:



Now you have access to all of the defaults; each is stored in a field of defaults (which is a structure). Try typing “defaults” to see the top level:

>> defaults

defaults =

        cmdline: 0
             ui: [1x1 struct]
       renderer: 'zbuffer'
         images: [1x1 struct]
          dicom: [1x1 struct]
          stats: [1x1 struct]
           mask: [1x1 struct]
    slicetiming: [1x1 struct]
        realign: [1x1 struct]
          coreg: [1x1 struct]
         unwarp: [1x1 struct]
      normalise: [1x1 struct]
         smooth: [1x1 struct]
        preproc: [1x1 struct]
       modality: 'FMRI'


If you want to change something, you can do this from the command line. For example, if you wanted to change defaults.stats.topoFDR to be 0, you could type:

>> defaults.stats.topoFDR = 0;

And that value would be set until SPM defaults are updated (typically, it would last throughout this SPM session).


This “command line” method also works in scripts. The global defaults structure can be set using spm('Defaults', 'fMRI'). From a script, access the global variable and update its values as above.