Export source maps to SPM8

The statistical analysis is still limited in Brainstorm, but you can easily export your source maps and run your tests with an external application. This tutorial explains how to export source maps to SPM8. It is based on the median nerve tutorial dataset that was used in the tutorials of the section ?Processing continuous recordings. If you have followed those tutorials, this dataset should be available in your database in the protocol TutorialRaw.

SPM8 has an important limitation with respect with SPM12: it cannot work on surfaces. We have to export all the sources to full volumes, which is highly inefficient. If you get the option, consider updating to SPM12.

Export source files

We want now to export the sources estimated for all the trials for the left condition to volume files in NIfTI1 format (readable by SPM). We are going to get rid of the time information, very difficult to handle with those full volumes in SPM, and keep only two averaged time windows per condition: a baseline [-20,-15]ms and an active state [33,38]ms.

Clear the Process1 box and drop all the trials for condition Left in it. Select the button "Process sources" on the left of the Process1 tab.

introBst.gif

Select the process "File > Export to SPM8 (volume)".

exportLeftBaseline.gif

Configure the process:

Add another export process after this one, to export the "active" state. Set the time window to [33,38]ms, to capture the peak of the response in the primary somatosensory cortex, and the file name to "subject01_left_active".

exportLeftActive.gif

Click on Run and let it process for a while. It will generate two NIfTI files of 130Mb each in the output folder: subject01_left_active.nii and subject01_left_baseline.nii. Each file contains 101 volumes, one per trial.

You can try opening some of those volumes with a NIfTI file viewer, just to make sure that what is saved is coherent. You can use for instance the free software Mricron to view the file subject01_left_active.nii, volume #2. The values saved in this file are not integers, so you may have to edit manually the amplitude scale for the colormap (the text boxes in the second line of toolbar). For instance, set this range from 0 to 5e-10 pAm.

This is a stimulation of the left median nerve, we observe as expected a response in the central regions of the right hemisphere.

mriCronConstr.gif

Note that you can also use Brainstorm as a NIfTI viewer: go to the anatomy view of the protocol, create a new subject, right-click on it > Import MRI > Select a .nii file.

Export T1 MRI

One last thing you need to export from Brainstorm: the T1 MRI volume of the subject, for displaying the results in SPM. Go the anatomy view of the protocol TutorialRaw, right click on Subject01 / MRI > File > Export to file. Select the file format "MRI: NIfTI-1" and save the file T1.nii in the same folder with all the other .nii files.

exportMri.gif

Run SPM8

Installing SPM is easy: http://www.fil.ion.ucl.ac.uk/spm/software/spm8/

Start Matlab, go to the SPM folder, add it to your path if it is not done already, then type "spm". Select "M/EEG" on the SPM startup screen.

Import note: Do not run Brainstorm and SPM at the same time, always close Brainstorm before starting SPM (but you don't need to close Matlab).

spmStart1.gif

In the main SPM window, click on "Specify 2nd level".

spmStart2.gif

Now you can specify your stats design in the Batch Editor window. We are going to start with a simple t-test for the left condition: active state versus baseline. Select the following options:

(*) File selector: Using the SPM file selector for importing the 4D NIfTI files we have exported from Brainstorm is not that intuitive. Follow those guidelines:

spmFileSelect.gif

Once you have defined all the options, click on the Run button (the green button in the toolbar on top of the Batch Editor window).

spmSetupTwoSample.gif

The design matrix window is displayed in the Graphics window, and a file SPM.mat is saved in the output directory you defined in the options.

spmDesign.gif

In the SPM8 Menu window, click on the Estimate button. Select the SPM.mat file that was just created. SPM estimates the parameters, it may take a while.

spmRun.gif

When done click on Results in the SPM8 Menu window, select again the same SPM.mat file. A window pops up, you have to specify the contrast(s) of interest.

spmContrast1.gif

Click on "Define new constrast...". Edit the options to define the t-test post-stim > pre-stim:

spmContrast2.gif

It updates the window "SPM contrast manager".

spmContrast3.gif

Click on "Done", then a list of parameters is asked in the "SPM8: Stats: Results" window.

spmContrast4.gif

Then the typical SPM8 glass brain shows up in the Graphics window. The window SPM8 Results shows more display options for this figure. Select "overlays > sections". Pick the file T1.nii we exported from Brainstorm.

spmContrast5.gif

You get the final results in the Graphics window. You can explore the volume by clicking on the MRI slices.

spmResultsConstr.gif

You can repeat the same operations with the right condition.

The results you get here are very basic, but the logic of exporting source results from Brainstorm to SPM can be extended to any type of analysis.

Using uncontrained sources

We have done this analysis using a source model where all the dipoles where located in the grey matter, with orientations constrained to the normal of the cortex surface. You can repeat the same analysis using sources distributed in the full brain volume, as detailed in the tutorial Volume source estimation.

Right-click on (common files) > Compute head model > MRI volume. Use the default options for the grid of points.

height="239",width="432"

Right-click on the new head model > Compute sources > keep all the default options.

height="227",width="387"

We want now to export the unconstrained sources to volume files in NIfTI1 format. Clear the Process1 box and drop all the trials for condition Left in it. Select the button "Process sources" on the left of the Process1 tab.

Problem: it selects at the same time the constrained and unconstrained sources (total 202 files instead of 101). We can use the process "File > Select files with tag" (detailed in the tutorial Selecting files in the database). Configure it as following:

selectFiles.gif

Add immediately after the two processes to export the baseline and the active state (use a different folder). Set the same options as previous (constrained case). Then click on Run.

exportUnconstr.gif

Look for instance at the file subject01_left_active.nii, volume #2, [0 2e-10] pAm.

mriCron.gif

Close Brainstorm, start SPM, and run exactly the same analysis steps as before. In the end you should obtain the follwing results.

Clean Brainstorm database

To restore the original state of the protocol TutorialRaw and be able to use it as the starting point for another advanced tutorial, delete the two new files in Subject01 / Common files:

restoreDb.gif

ExportSpm8 (last edited 2013-09-18 21:59:36 by agrippa)