SwE: Manual

Sandwich Estimator Toolbox for Longitudinal & Repeated Measures Data

A toolbox for SPM

By Bryan Guillaume & Thomas Nichols

 



This page...
News
Introduction
Manual
FMRI worked example
Download
References
Contact
 

The goal of this manual is to explain how to use the SwE toolbox. If something is unclear or if you think more explanations are needed, please do not hesitate to contact Bryan Guillaume or Tom Nichols. The manual will be updated accordingly. Note that an example of the use of the toolbox on a real dataset can be found here. Note that this manual does not account for the new features of the last release of the toolbox. It will be updated soon.

Toolbox overview

The SwE toolbox implements the Sandwich Estimator (SwE) method described in Guillaume et al. (in submission) allowing the analysis of longitudinal and repeated measures data in neuroimaging. An analysis with the SwE toolbox can be decomposed into three stages:

  1. Data & design setup (swe_design)
  2. Computation of the model parameters (swe_cp)
  3. Post-processing & display of results (swe_result_ui)

Each stage is handled by a separate function, callable either from the command line or the SwE GUI, as described below. Interim communication between the stages is done via SwE.mat files, similar to SPM.mat files. The setup stage (swe_design) launches the batch system and saves the configuration information in a SwE.mat. Note that the filenames of the input and created images are coded into the SwE.mat file, so moving or deleting the images may cause issues. The computation stage (swe_cp) asks you to locate a SwE.mat file, computes the model parameters and updates the SwE.mat file. Finally the post-processing & results stage (swe_result_ui) asks you to locate a SwE.mat file and launch an interface allowing you to make inferences and display the results.


Getting started

Prior to using the SwE toolbox, a version of SPM12 must be previously installed and launched at least once. To install and launch the SwE toolbox:

  1. Unzip the SwE.zip file into the SPM toolboxes folder (i.e. {path to spm}/toolbox/).
  2. Start Matlab and run SPM.
  3. In SPM navigate click on the "Batch" menu and select "SPM" from the Toolbar at the top of the Batch window. Under "Tools" In the drop down menu the 3 menu items for SwE should now be available.

spm_usage.png

Alternatively, to run the SwE toolbox in standalone mode, do the following:

  1. Unzip the SwE.zip file into the SPM toolboxes folder (i.e. {path to spm}/toolbox/).
  2. Add the folder "SwE" into your path, either using:
    • For old MATLAB versions, File > Set Path > Add Folder
    • For recent MATLAB versions, HOME > ENVIRONMENT > Set Path > Add Folder
    • MATLAB command pathtool > Add Folder
    • MATLAB command addpath …/whatever/SwE
  3. Launch the SwE toolbox by typing swe in the command window and the following GUI should appear:

    swegui.png

    This SwE GUI has three buttons allowing to launch the three stages of an SwE analysis. Each of these stages is detailed below.

Data & design setup

To start specifying the data and design, press the button "Specify model" in the SwE GUI. This will call the SPM batch system, add the SwE tab to it and load the SwE module "Specify Model" (see image below).

SwE batch

This module contains several fields that have to be filled in:

Once the model is specified, the SwE job can be run by pressing the green "Run Batch" button. The toolbox will then create a SwE.mat file containing all the configuration information needed for the estimation of the model parameters.


Computation of the model parameters

To start estimating the parameters of a specified model, press the button "Run model" of the SwE GUI and select the appropriate SwE.mat file. The toolbox should then compute all the estimates needed for the analysis. This may take several minutes.


Post-processing & display of results

Once the computation is done, press the "Results" button of the SwE GUI and select the appropriate SwE.mat file. For a parametric analysis, the toolbox should then open a SwE contrast manager allowing the test of several contrasts. For a wild bootstrap analysis, the toolbox will display the positive contrast which was computed.

Note that the SwE interface is very similar to the interface of a classic SPM analysis and can be used in a similar way. Nevertheless, there are some differences important to note. First, as the degrees of freedom with the SwE method may vary across voxels, for each contrast, the equivalent Z-score or 1-degree-of-freedom chi-squared image are displayed instead of the traditional t-score or F-score image (note that, for each parametric contrast, the t- or F-score image is saved in the working directory alongside the degrees of freedom image). Second, as Random Field Theory inferences have not been yet validated with the SwE method, only False Discovery Rate and uncorrected inferences are currently available in the SwE toolbox for parametric inference.

A full list of files output files, alongside a brief description of each file are given in the tables below:


Parametric Voxelwise analyses

For parametric voxelwise analyses run on input given as '.mat' files, the below files are output.

Filename Description
swe_vox_mask.mat This is the mask used during the analysis. (In previous versions of the toolbox this map was known as mask.mat.)
swe_vox_beta_bb.mat This the the beta map for this analyis.
(In previous versions of the toolbox this map was known as beta.mat.)
swe_vox_cov.mat This is the covariance map for the beta values given in swe_vox_beta_bb.mat. (In previous versions of the toolbox this map was known as cov_beta.mat.)
swe_vox_cov_vv.mat This is the covariance map for between visits. (In previous versions of the toolbox this map was known as cov_vis.mat.)
swe_vox_cov_g_bb.mat This contains the between beta covariance maps for each group. (In previous versions of the toolbox this map was known as cov_beta_g.mat.)
swe_vox_{T|F}stat_c{c#}.mat This is the voxelwise parametric statistic map (T or F) for contrast {c#}. (In previous versions of the toolbox this map was not recorded.)
swe_vox_{zT|xF}stat_c{c#}.mat This is the voxelwise parametric equivalent statistic map (Z or 1-DF Chi-squared) for contrast {c#}. (In previous versions of the toolbox this map was known as score.mat.)
swe_vox_{T|F}stat_lp_c{c#} This is the log10 map of the voxelwise uncorrected P values for contrast {c#}. (In previous versions of the toolbox this map was known as spmUncP_{#}.mat.)
swe_vox_edf_c{c#}.mat This is the error degrees of freedom map for contrast {c#}. (In previous versions of the toolbox this map was known as edf_{c#}.mat.)
swe_vox_beta_c{c#}.mat This is the beta map for contrast {c#}. (In previous versions of the toolbox this map was known as con_{c#}.mat.)

For parametric analyses run on input given as '.img' or '.nii' files, the below files are output.

Filename Description
swe_vox_mask.nii This is the mask used during the analysis. (In previous versions of the toolbox this map was known as mask.nii.)
swe_vox_beta_b{b#}.nii This the the {b#}th beta map for this analyis. (In previous versions of the toolbox this map was known as beta_{b#}.nii.)
swe_vox_resid_y{y#}.nii This is the parametric residual map calculated for scan {y#}. (In previous versions of the toolbox this map was known as ResI_{y#}.nii.)
swe_vox_cov_b{b1#}_b{b2#}.nii This is the covariance map between beta {b1#} and beta {b2#}. (In previous versions of the toolbox this map was known as cov_beta_{b1#}_{b2#}.nii.)
swe_vox_cov_g{g#}_b{b1#}_b{b2#}.nii This is the covariance map for group {#g} between beta {#b1} and beta {#b2}. (In previous versions of the toolbox this map was known as cov_beta_g_{g#}_{b1#}_{b2#}.nii.)
swe_vox_cov_g{g#}_v{v1#}_v{v2#}.nii This is the covariance map for group {#g} between visit {#v1} and visit {#v2}. (In previous versions of the toolbox this map was known as cov_vis_{g#}_{v1#}_{v2#}.nii.)
swe_vox_edf_c{c#}.nii This is the error degrees of freedom map for contrast {c#}. (In previous versions of the toolbox this map was known as edf_{c#}.nii.)
swe_vox_{T|F}stat_lp_c{c#}.nii This is the log10 map of the voxelwise uncorrected P values for contrast {c#}. (In previous versions of the toolbox this map was known as spmUncP_{c#}.nii.)
swe_vox_{T|F}stat_c{c#}.nii This is the voxelwise parametric statistic map (T or F) for contrast {c#}. (In previous versions of the toolbox this map was known as spm?_{c#}.nii.)
swe_vox_{zT|xF}stat_c{c#}.nii This is the voxelwise parametric equivalent statistic map (Z or 1-DF Chi-Squared) for contrast {c#}. (In previous versions of the toolbox this map was known as score.nii.)
swe_vox_beta_c{c#}.nii This is the beta map for contrast {c#}. (In previous versions of the toolbox this map was known as con_{c#}.nii.)


Non-Parametric Clusterwise analyses


For non-parametric clusterwise analyses run on input given as '.mat' files, the below files are output.

Filename Description
swe_vox_mask.mat This is the mask used during the analysis. (In previous versions of the toolbox this map was known as mask.mat.)
swe_vox_beta_bb.mat This is the beta map. (In previous versions of the toolbox this map was known as beta.mat.)
swe_vox_{T|F}stat_c{c#}.mat This is the voxelwise parametric statistic map (T or F) for contrast {c#}. (In previous versions of the toolbox this map was not recorded.)
swe_vox_{zT|xF}stat_c{c#}.mat This is the voxelwise parametric equivalent statistic map (Z or 1-DF Chi-Squared) for contrast {c#}. (In previous versions of the toolbox this map was known as score.mat for {c#}=001.)
swe_vox_{zT|xF}stat-WB_c{c#}.mat This is the voxelwise non-parametric equivalent statistic map (Z or 1-DF Chi-Squared) for contrast {c#}, derived from the non-parametric uncorrected P values in swe_vox_{T|F}stat_lp-WB_c{c#}.mat. (In previous versions of the toolbox this map was not recorded.)
swe_vox_{T|F}stat_lp-WB_c{c#}.mat This is the log10 map of the voxelwise uncorrected P values for contrast {c#}. (In previous versions of the toolbox this map was known as luncP_{pn}.mat*.)
swe_vox_{T|F}stat_lpFWE-WB_c{c#}.mat This is the log10 map of the voxelwise bootstrap-calculated FWE P values for contrast {c#}. (In previous versions of the toolbox this map was known as lfwerP_{pn}.mat*.)
swe_vox_{T|F}stat_lpFDR-WB_c{c#}.mat This is the log10 map of the voxelwise bootstrap-calculated FDR P values for contrast {c#}. (In previous versions of the toolbox this map was known as lfdrP_{pn}.mat*.)
swe_clustere_{T|F}stat_lpFWE-WB_c{c#}.mat This is the log10 map of the clusterwise bootstrap-calculated FWE P values for contrast {c#}. (In previous versions of the toolbox this map was known as lclusterFwerP_{pn}_perElement.mat.)
swe_vox_resid_y{y#}.mat These are the wild-bootstrap generated residuals obtained for scan {y#}. (In previous versions of the toolbox this map was known as ResWB_{y#}.mat.)
swe_vox_fit_y{y#}.mat These are the fitted values obtained for scan {y#} calculated using the wild-bootstrap generated residuals given in swe_vox_resid_y{y#}.mat. (In previous versions of the toolbox this map was known as YfittedWB_{y#}.mat.)

For non-parametric clusterwise analyses run on input given as '.img' or '.nii' files, the below files are output.

Filename Description
swe_vox_mask.nii This is the mask used during the analysis. (In previous versions of the toolbox this map was known as mask.nii.)
swe_vox_{T|F}stat_c{c#}.nii This is the voxelwise parametric statistic map (T or F) for contrast {c#}. (In previous versions of the toolbox this map was not recorded.)
swe_vox_{zT|xF}stat_c{c#}.nii This is the voxelwise parametric equivalent statistic map (Z or 1-DF Chi-Squared) for contrast {c#}. (In previous versions of the toolbox this map was known as score.nii for {c#}=001.)
swe_vox_{zT|xF}stat-WB_c{c#}.nii This is the voxelwise non-parametric equivalent statistic map (Z or 1-DF Chi-Squared) for contrast {c#}, derived from the non-parametric uncorrected P values in swe_vox_{T|F}stat_lp-WB_c{c#}.nii. (In previous versions of the toolbox this map was not recorded.)
swe_vox_{T|F}stat_lp-WB_c{c#}.nii This is the log10 map of the voxelwise uncorrected P values for contrast {c#}. (In previous versions of the toolbox this map was known as lP{+-}.nii*.)
swe_vox_{T|F}stat_lpFWE-WB_c{c#}.nii This is the log10 map of the voxelwise bootstrap-calculated FWE P values for contrast {c#}. (In previous versions of the toolbox this map was known as lP_FWE{+-}.nii*.)
swe_vox_{T|F}stat_lpFDR-WB_c{c#}.nii This is the log10 map of the voxelwise bootstrap-calculated FDR P values for contrast {c#}. (In previous versions of the toolbox this map was known as lP_FDR{+-}.nii*.)
swe_clustere_{T|F}stat_lpFWE-WB_c{c#}.nii This is the log10 map of the clusterwise bootstrap-calculated FWE P values for contrast {c#}. (In previous versions of the toolbox this map was known as lP_clusterFWE{+-}.nii*.)
swe_vox_resid_y{y#}.nii These are the wild-bootstrap generated residuals obtained for scan {y#}. (In previous versions of the toolbox this map was known as ResWB_{y#}.nii.)
swe_vox_fit_y{y#}.nii These are the fitted values obtained for scan {y#} calculated using the wild-bootstrap generated residuals given in swe_vox_resid_y{y#}.nii. (In previous versions of the toolbox this map was known as YfittedWB_{y#}.nii.)

Non-Parametric TFCE analyses


For non-parametric TFCE analyses run on input given as '.img' or '.nii' files, the below files are output.

Filename Description
swe_vox_mask.nii This is the mask used during the analysis. (In previous versions of the toolbox this map was known as mask.nii.)
swe_vox_{T|F}stat_c{c#}.nii This is the voxelwise parametric statistic map (T or F) for contrast {c#}. (In previous versions of the toolbox this map was not recorded.)
swe_vox_{zT|xF}stat_c{c#}.nii This is the voxelwise parametric equivalent statistic map (Z or 1-DF Chi-Squared) for contrast {c#}. (In previous versions of the toolbox this map was known as score.nii for {c#}=001.)
swe_vox_{zT|xF}stat-WB_c{c#}.nii This is the voxelwise non-parametric equivalent statistic map (Z or 1-DF Chi-Squared) for contrast {c#}, derived from the non-parametric uncorrected P values in swe_vox_{T|F}stat_lp-WB_c{c#}.nii. (In previous versions of the toolbox this map was not recorded.)
swe_vox_{T|F}stat_lp-WB_c{c#}.nii This is the log10 map of the voxelwise uncorrected P values for contrast {c#}. (In previous versions of the toolbox this map was known as lP{+-}.nii*.)
swe_vox_{T|F}stat_lpFWE-WB_c{c#}.nii This is the log10 map of the voxelwise bootstrap-calculated FWE P values for contrast {c#}. (In previous versions of the toolbox this map was known as lP_FWE{+-}.nii*.)
swe_vox_{T|F}stat_lpFDR-WB_c{c#}.nii This is the log10 map of the voxelwise bootstrap-calculated FDR P values for contrast {c#}. (In previous versions of the toolbox this map was known as lP_FDR{+-}.nii*.)
swe_tfce_c{c#}.nii This is the parametric TFCE statistic for contrast {c#}.
swe_tfce_lp-WB_c{c#}.nii This is the log10 map of the TFCE bootstrap-calculated uncorrected P values for contrast {c#}.
swe_tfce_lpFWE-WB_c{c#}.nii This is the log10 map of the TFCE bootstrap-calculated FWE P values for contrast {c#}.
swe_vox_resid_y{y#}.nii These are the wild-bootstrap generated residuals obtained for scan {y#}. (In previous versions of the toolbox this map was known as ResWB_{y#}.nii.)
swe_vox_fit_y{y#}.nii These are the fitted values obtained for scan {y#} calculated using the wild-bootstrap generated residuals given in swe_vox_resid_y{y#}.nii. (In previous versions of the toolbox this map was known as YfittedWB_{y#}.nii.)

*Note: For non-parametric analyses {c#} is 001 for activation and 002 for deactivation. In previous versions of the toolbox these were represented with either a +/- or p/n.

✝ These maps will be removed once an analysis has been run. They will only be retained if an analysis is ended prematurely.