Download as pdf or txt
Download as pdf or txt
You are on page 1of 172

Schedule - 2º Brainn Congress

Day 1
08:30 - 09:30: fMRI introduction
09:30 - 10:30: fMRI acquisition
10:30 - 10:45: Coffee break
10:45 - 12:30: fMRI analysis (theory and hands-on)
12:30 - 14:00: Lunch
14:00 - 15:30: fMRI analysis (theory and hands-on)
15:30 - 16:30: EEG introduction
16:30 - 16:45: Coffee break
16:45 - 18:00: EEG inside the MR scanner
Schedule - 2º Brainn Congress
Day 2
08:30 - 09:00: EEG-fMRI introduction
09:00 - 10:30: EEG-fMRI acquisition
10:30 - 10:45: Coffee break
10:45 - 12:30: EEG-fMRI analysis (theory and hands-on)
12:30 - 14:00: Lunch
14:00 - 15:30: EEG-fMRI analysis (theory and hands-on)
15:30 - 15:45: Coffee break
15:45 - 18:00: EEG source localization
EEG + fMRI
Authors:
How to get there! Brunno M. de Campos
Guilherme C. Beltramini
Paulo R. Bazán
Raphael F. Casseb 2015
Outline
1) fMRI introduction
2) EEG introduction
3) fMRI+EEG Introduction
4) EEG artifact removal (BV Analyzer 2)
5) fMRI analysis (SPM)
6) EEG-informed fMRI analysis (SPM)
7) Additional information
fMRI
Introduction
1.Basics of MRI signal
MRI is based on the nuclear resonance of atoms in a strong
magnetic field (Nuclear Magnetic Resonance - NMR).
Three main steps:

1. Magnetic field: alignment of nuclear spins;


2. Resonance: disturbance of the alignment using a
radiofrequency pulse (nuclei absorb energy);
3. Relaxation: nuclei release energy and realign.
1.Basics of MRI signal

Radiofrequency pulse
(Larmor frequency)

Magnetic
Field

Reference: https://www.youtube.com/watch?v=djAxjtN_7VE
2.Types of images
Roughly, MRI technique can produce two types of images:

Structural
Functional:
series of measurements, allowing the
analysis of neural activity over time.
3.Functional images

http://jonlieffmd.com/blog/complexity-in-searching-for-the-neural-
code

Lindauer U. et al. (2010) “Pathophysiological interference with neurovascular coupling - when imaging based on hemoglobin might go blind”.
Frontiers in Neuroenergetics, vol. 2, article 25
4.BOLD signal
Blood Oxygenation Level-Dependent signal
Neuronal Oxygen Deoxyhemoglobin Blood flow, Relative
activity consumption concentration Blood volume deoxyhemoglobin
concentration
5.fMRI
Pros Cons
➔ High spatial resolution (0.5- ➔ Low temporal resolution (1-
4mm) 3s)
➔ Non-invasive ➔ Expensive
➔ No need for radioactive tracers, ➔ Volunteer has to lie still and
nor x-rays can’t move their head
➔ Whole-brain coverage (restriction on possible
➔ Usually easy subject preparation experiments)
➔ Useful for evaluation of short ➔ Noisy environment
events and of sustained activity
6.Brain signal - Spatial x Temporal
resolutions

http://www.nature.com/neuro/journal/v17/n11/fig_tab/nn.3839_F1.html
7.fMRI - Experimental design
Resting State Block
Alternating long periods (~10-30s) of task and rest
● Same task/instruction during the entire
acquisition
● Either eyes open (looking at a fixation
Stimuli
cross) or closed
● Not thinking about anything in particular
(resting state)
● Connectivity studies: evaluate the BOLD signal from
similarity between signal oscillation in each stimulus
different regions of the brain

Sum of signals
7.fMRI - Experimental design
Event-Related (similar to EEG/ERP)
Slow Event-Related Rapid Event-Related
Short tasks separated by long (10-15s) intervals Short tasks separated by short intervals of
variable duration along the acquisition

Stimuli Stimuli

BOLD signal from BOLD signal from


each stimulus each stimulus

Sum of signals Sum of signals


http://afni.nimh.nih.gov/pub/dist/HOWTO/howto/ht03_stim/html/stim_background.html
8.fMRI - How to analyze
Analysis steps:
● Check your data!
● Perform preprocessing steps
● Statistical analysis
● Choose viewing/threshold options (results)
Alternative Connectivity analysis:
● Psycho-Physiological Interactions (PPI); Independent
Component Analysis (ICA); Dynamic Causal Modelling
(DCM); Granger-causality
EEG
Introduction
1.Local membrane potential

● Ion flow across the membrane


○ extracellular sources and sinks
○ current flow along the surface of the
membrane
● Direction of the current depends whether it’s
an excitatory or inhibitory postsynaptic
potential
2.EEG - Origin of the signal
● Measures the extracellular postsynaptic potential of
synchronized pyramidal neurons
○ Synchronization: higher amplitude
○ Pyramidal neurons: similar orientation → dipole
● Temporal resolution:
○ Sampling rate: ~2-4 ms
○ Postsynaptic potential: ~10-100 ms
● Spatial resolution:
○ ~6 cm² of active cortex are necessary to generate signal
○ Spaces between electrodes ~cm
3.EEG - How to measure
● Electrodes on the scalp
● Amplifiers
● Computer to record data
4.EEG - How to analyze
● Identify artifacts
● Bilateral symmetry, spatial distribution, ...
● Alterations: epileptiform activity, asymmetry, coma, ...
● Frequency spectrum (delta, theta, alpha, beta, gamma)
● Event-related potential
EEG-fMRI
Introduction
1.EEG-fMRI: Motivation
● EEG
○ Good temporal resolution
○ Can detect epileptiform activity, sleep stages,
frequency bands
○ Signal of electrophysiological origin
● fMRI
○ Good spatial resolution
○ Great variety of cognitive experimental paradigms
○ Signal of hemodynamic origin
2.EEG-fMRI: How to combine?
● Set up the EEG electrodes
○ Ensure good connection between the electrodes and scalp
● EEG electrodes and amplifiers are taken into the
scanner room
● EEG and fMRI are recorded simultaneously
○ Clocks must be synchronized
3.Equipment: MR scanner
● Head coil
○ Head coils without adequate openings for the EEG cables must not be
used (loops would be inevitably formed)
○ Desired: head coils with an opening at the back
4.Equipment: EEG
● High magnetic fields require attention

● Caution with moving objects and heating


○ Only non-ferromagnetic objects
○ No loops
○ Cables don’t touch the subject skin directly
○ Cables aligned with the magnet
4.Equipment: EEG
● Loops:
○ Cable loops
○ Loops between cables and the subject
○ Loops within the patient (arms crossed)

● Impedances of the electrodes must be < 50 kOhm


○ High impedance electrodes act as
antennas
○ They pick up RF energy and dissipate
in the amplifier
4.Equipment: Common terms
● MR-conditional: Item has been demonstrated to pose no
known hazards in a specified MR environment (field
strength) under specified conditions of use (coil
configuration, MR-sequence)
○ BrainCap MR, ExG-AUX input box, EMG-MR-electrodes
● MR-safe: Item poses no known hazards in all MR
environments
○ fiber optic cable
● MR-unsafe: Item is a known threat or poses a hazard in
all MR environments
○ BrainAmp USB Adapter, trigger cable, SyncBox
4.MR-conditional EEG equipment
● Allowed MR-sequences:
○ Localizer/Scout/Survey
○ GE-EPI (Gradient Echo Echo-Planar Imaging)
○ 3D TFE (Philips) = MP-RAGE (Siemens) = FSPGR (General Electric)
○ T1-FFE (Philips) = FLASH (Siemens) = SPGR (General Electric)

● Forbidden MR-sequences: with multiple pulses (specially


inversion pulses) and structural sequences with high SAR
○ Spin echo EPI ○ DTI (Diffusion Tensor Imaging)
○ Turbo spin echo ○ ASL (Arterial Spin Labeling)
○ FLAIR ○ MREG (MR-Encephalography)
○ Turbo FLASH
5.EEG-fMRI: Synchronization between
the EEG and the MR scanner
● Volume (or slice) trigger: every TR, the MR scanner
sends a TTL pulse
○ Used for image artifact removal
○ If missing, BV Analyzer can detect the start of every volume and
create markers
● Phase synchronization between the BrainAmp clock
system and the scanner clock (using the SyncBox)
○ Stable and repetitive gradient artifact
○ For optimum correction of the artifacts in the EEG data
○ If the gradient system is not under control of the scanner's master
clock, the SyncBox adds no benefit for the EEG recording
○ If missing, gradient artifacts might vary from volume to volume (or slice
to slice) → poor gradient artifact template → poor corrected EEG
6.EEG-fMRI: SyncBox

● Master clock output (almost all scanners): 10 MHz sine


wave
● The SyncBox divides the scanner masterclock pace to
5kHz and drives the BrainAmp phase locked to the
scanner artifact.
○ lower variance in the gradient artifact template
○ improves gradient artifact subtraction substantially
7.EEG: Setup
● Recorder workspace
● Impedances
● Synchrony
7.EEG: Setup - Workspace
The Recorder software allows
the recording of EEG data. The
Recorder Workspace is a set of
configurations about electrode
cap, sampling frequency,
filters, etc.

Click File, Open Workspace…


to open a Workspace

You have to select an


appropriate workspace
according to your cap.
Attention: you may have to look
for it in the installation CD
(default installation does not
copy all available workspaces).
7.EEG: Setup - Workspace
The configurations of the
Workspace can be
changed by clicking on
File, Edit Workspace.

The Raw File Folder is


the folder where your
data will be saved

Output filename options


7.EEG: Setup - Workspace
Scan for Amplifiers

● Check the number of channels


● Sampling Rate (Hz): highest value
● Low cutoff (s): 10
● High cutoff (Hz): 250
● Low Impedance (10 MOhm): uncheck
● Ground Series Resistor (kOhm): 10
● Reference Series Resistor (kOhm): 10

“Forward”
7.EEG: Setup - Workspace

No online filters. Go “Forward” Finish


7.EEG: Setup - Impedances
● Cleanup of volunteer scalp with alcohol and gauze
○ Skin can be oily, dirty, greasy, sweaty or can contain dead skin
● Position the electrode cap
○ Fix the front part first and pull the back
○ Cz must be in the center of the head (left-right, nasion-inion)

● Lower the impedances


○ Remove the hair from the whole of the electrode
○ Clean the area with alcohol
○ Put gel between the skin and the electrode

● Check the signal (inside and outside the scanner)


○ Blink, move the head, close the eyes, ECG
7.EEG: Setup - Cleaning up

● After the experiment


○ Take off the cap and remove all gel with water and baby
shampoo
○ Let it dry over a spherical object
○ Remove the gel from the head with gauze
○ Wash the hair
7.EEG: Setup - Synchrony
Check the Synchrony between the clocks of the EEG
and the fMRI equipments. Open the SyncBox Settings
(Amplifier, SyncBox Settings).

Choose the scanner frequency, interval between


markers (Update Interval Sync Status Marker [s]) and
whether a Sync On/Sync Off marker will be saved.

The Red circle indicates a problem with synchrony. If


synchrony is working properly, the circle will turn green.

An equivalent circle also appears in the lower part of the Recorder window (green indicates synchrony is OK)
7.EEG: Setup - Synchrony
To set markers incoming from digital
ports, select Amplifier, Digital Port
Settings...

Test if the signal you are sending from experiment


computer is received as expected, viewing the Current
State of the bits.
8.ECG electrode
● Attached along the paravertebral axis three
fingers to the left of the subject's spine
● The ECG cable must can be straight but
without tension
○ If the subject moves, the ECG will not detach

● Always verify the quality of the ECG before


starting the scan
○ If needed, correct ECG electrode impedance and
position
9.EEG amplifier positioning

Inside the bore Outside of the bore

BrainAmp MR: Operating Instructions for use in an MR environment, Version 015


10.EEG-fMRI: Safety

● No loops and cables touching the subject skin directly

● For receiver-only head coils (body coil is the transmitter):


○ Do not use additional sensors (EMG, acceleration sensors)
○ The cap can not have more than 2 free electrodes (ECG, EOG)

● Contact the subject between scans to make sure they


are not feeling warm spots
11.EEG-fMRI: Artifacts
● Induced voltages in the signal when there is
variation in the magnetic field or in the cross-
section areas
○ Head or EEG equipment movement
○ RF pulse and gradient fields → “Image artifact”
○ Solution:
■ Reduce the current loop areas
■ Immobilize equipment and head
■ Turn off helium pump (be careful)
■ Correction algorithms ~100x larger than physiological signal
11.EEG-fMRI: Artifacts

scale: 0,050 mV scale: 0,050 mV scale: 5,0 mV

Static magnetic field Gradients and RF pulse


11.EEG-fMRI: Pulse artifact
11.EEG-fMRI: Pulse artifact
11.EEG-fMRI: Artifact correction
1. High sampling rate: 5 kHz
[for more precision in the calculation of the artifact template]

2. Analog low-pass filter (cutoff = 250 Hz)


[10% of the Nyquist frequency to avoid signal saturation and to remove part of the
image noise]

3. AAS: average artifact subtraction


3.1. Once for the image artifact
3.2. Once for the pulse artifact
4. Digital low-pass filter (cutoff = 70 Hz)
[to keep the physiological signal]
11.EEG-fMRI: AAS
Artifact

Artifact template

Mulert & Lemieux (2010), Cap. 8


12.EEG-fMRI: How to analyze?
1. EEG-fMRI symmetrical fusion

Mulert & Lemieux (2010), Cap. 25


12.EEG-fMRI: How to analyze?
2. Asymmetric integration

EEG-informed fMRI analysis

fMRI-informed EEG analysis

Mulert & Lemieux (2010), Cap. 6


EEG
Artifact removal using BrainVision Analyzer
1.BrainVision Analyzer
● Software requisites
○ BV Analyzer + valid license
○ Supported operating systems:
■ Windows XP
■ Windows Vista
■ Windows 7
■ Windows 8
● Supported file formats: http://www.brainproducts.
com/productdetails.php?id=17&tab=2
2.Data format
Each recording consists of 3 files:
● .eeg: data file (binary [usually] or ASCII)
● .vhdr: header file (ASCII)
○ Information about the recording (data structure, channels,
impedances, …)
● .vmrk: marker file (ASCII)
○ Information about the markers (trigger event codes)

Be careful when renaming these files (content of the vhdr


and vmrk files must be changed too)
3.Analyzer environment - Menu

● File: Open and define workspace, settings,


preferences, …
3.Analyzer environment - Menu

● Display: Define montage (how channels are visualized),


appearance
3.Analyzer environment - Menu

● Transformations: Signal processing functions


○ Dataset preprocessing
○ Artifact rejection/reduction
○ Frequency and component analysis
○ Segment analysis
○ Comparison and statistics
○ Special signal processing: MR and CB correction
○ Others
3.Analyzer environment - Menu

● Add Ins: Marker navigation, ...


3.Analyzer environment - Menu

● Export: Choose data format and type of information to


be exported
○ Files will be exported to the “Export folder” defined in
the workspace
3.Analyzer environment - Menu
● Macros: Customized scripts

● Solutions: Additional plugins that complement functions


from Transformations (EKG, EMG, Export, ICA, ...)
○ Each solution is installed separately
3.Analyzer environment - Menu

● History Template: Define a sequence of steps to be


applied to all datasets
3.Analyzer environment - Menu

● Help: Updates, support, documentation, version, license


4.Workspace file
● There is no option to open a data file, only a workspace
● Workspace:
○ Configuration file with path information
○ 3 folders:
■ Raw: EEG recorded data (.eeg, .vhdr, .vmrk)
● BV Analyzer will never edit these files
■ History: where Analyzer saves the processing
steps applied to the raw data
● Do not delete or rename these files!
■ Export: output files of Analyzer
Do not confuse with the Recorder workspace (user-defined settings, such as storage location of EEG
files, amplifier parameters, specifications entered in the Configuration and Amplifier menus)
5.Loading data
1. Create 3 dedicated folders (Raw, History, Export)
2. Analyzer: File, New

3. Choose the full path for each folder

4. Save the workspace file


5.Loaded file
Buttons: Decrease and increase number of displayed channels, change
scaling of the amplitude, ...

Navigation Bar: Scroll


through the data
Markers
6.History Explorer
● Primary tab: history tree of the raw data

● Secondary tab: history tree of data


generated from multiple history files as
a result of processing steps (e.g.: Grand
Average)

● History tab: list of all opened history


nodes
6.History tree: A complete overview
of the analysis
= file from the raw data folder

= raw data
○ First node in the tree
○ Cannot be deleted or overwritten

= function was applied (always to the active node)


○ One new node for each operation
○ It’s possible to drag and drop the history tree of transformations from one
node to another
6.History tree
● History node:
○ Can be renamed, deleted, restored if
deleted, copied, ...
○ Operation Infos...: settings used to
create the node
○ Properties: data properties
○ Markers: marker name, type and count
○ Edit Parameters / Reprocess: re-
activate the dialog of the node with the
parameters used at its creation; node
will be overwritten
○ Double click to see the data
6.History tree: Automatic processing
1) Select and drag with the mouse the 2) Drop the nodes on the destination
nodes you want to apply to another node of the other dataset
dataset
6.History template
● Used when you want to apply the same history tree to
other files
1. Menu History Template, New
6.History template
2. Drag and drop the history tree you want to replicate
onto the “Root” node

3. Save the history template


6.History template
● Apply the history template to other datasets:
1. Open a new workspace
2. Menu History Template, Open
3. Apply to History File(s): select files
7.Some transformations
● Change sampling rate
● Frequency filter
● MR Correction
● CB Correction
7.Transformation: Change sampling rate
1. Menu Transformations → section Dataset
Preprocessing, Change Sampling Rate
2. Choose the new rate and the method of interpolation
7.Transformation: Frequency filter
1. Menu Transformations → section Artifact
Rejection/Reduction, Data Filtering, IIR Filters
2. Choose high and low cutoff, and attenuation intensity
7.Transformation: Frequency filter
● To display filtered and original data in the same window,
drag and drop the “Filters” node on the raw signal window
(or vice versa)
7.Transformation: MR Correction
Menu Transformations → section Special Signal Processing, MR Correction

Raw EEG, acquired


during fMRI
7.Transformation: MR Correction
Volume acquisition type
Scanner trigger (“Continuous” means
(R128) that the whole EEG
contains artifact)

TR value
7.Transformation: MR Correction
● Baseline correction before averaging
● Period of the interval relative to the marker

Average Options:
● Use All Scanned Intervals for Average
● Select Scanned Intervals for Average by
Following Criteria: criteria to include interval in
the artifact template calculation
● Use Sliding Average Calculation: choose an
odd number
● Use Template Drift Compensation: when there’
s jitter between the artifact and the sampling
7.Transformation: MR Correction
The downsampling avoids
massive data storage. The high
sampling rate is only used to
estimate the MRI artifact
template.

The recommendation is to apply


these filters in a separate step
(as shown previously)

Define the channels for


correction
7.Transformation: MR Correction
Memory vs. Processing:
● Store corrected data in memory
→ more disk space
● Do not store, but calculate on demand
→ more processor power
7.Transformation: MR Correction
Inside the scanner
(only B0) During EPI

scale: 0,050 mV scale: 5,0 mV scale: 0,050 mV

Artifact correction
Gradients and RF pulse
(MR and CB artifacts)
7.Transformation: CB Correction
Menu Transformations → section Special Signal Processing, CB Correction

Pulse artifact = cardiac artifact = cardioballistic (CB) artifact =


= ballistocardiogram (BCG) artifact
7.Transformation: CB Correction
Marker identification

Reference period to
search for the BCG
artifact template

Pulse rate interval

Thresholds to find
peaks similar to the
template
7.Transformation: CB Correction
Color of the lines:

● Red: potentially pulse peaks that


do not meet all criteria

● Yellow: edited peak

● Green: detected peak

Only yellow and green lines will give


rise to markers.
7.Transformation: Markers
Menu Transformations → section Others, Edit Markers

Type of marker editing:


● Automatic: you can edit complete, existing
marker groups according to editing rules
● Table: you can set and edit individual
markers
● Graphical: you can set and edit individual
markers freely in the EEG
7.Transformation: Markers
Automatic mode: For each rule, all the markers of the Manual (table) mode: Color code for the possible
dataset are selected with a suitable type and states of the markers (updated automatically):
description and edited in accordance with the ● Unchanged markers: black
specifications. The rows are processed in the order in ● Changed markers: blue
which they appear in the table. ● Added markers: green
● Deleted markers: red
7.Transformation: Markers
Graphical mode: With a single mouse click it’s
possible to create a marker of any width (Point
Width text box or hold the mouse button down and
drag the mouse pointer to the left or right over the
graph)
8.Views
Switch View: whole dataset
Transient View: selected area
8.Views

Standard View: Amplitude x Time Mapping View: Topographic map


displaying voltage distribution over
time or frequency
8.Views
3D Head View: Mapping View Butterfly view: all EEG channels
projected onto a 3D head model overlaid over each other
8.FFT Transient View
For all Transient Views:
● The output is not stored
and no new node is
created → transient
● Output is shown in a new
window
● Area can be increased,
decreased and moved
fMRI
Analysis using SPM
1.Images format
Probably all MR scanners export files in DICOM (.dcm)
format. This is very useful, because image header
contains lots of information like: patient’s name,
patient’s birthdate, protocol used in the acquisition, and
much more.
It is recommended to also export images in NIfTI (.nii)
format, because this is the file type supported by many
software packages.
1.Images format
If you didn’t export images in .nii format,
dcm2nii software is an easy tool to convert from
.dcm to .nii.
Both versions have bugs.
Go with the newest.

Old software New software


version version
1.Conversion from .dcm to .nii
1. Once software is open,
under Output Format,
select FSL (4D NIfTI nii).
2. Then, just drag and drop
a DICOM file in the
window.
3. Note that all DICOM files
in that folder will be
converted.
2.Preprocessing
Even after converting images, they cannot be promptly
analyzed, because there are problems like:

● Lots of noise in the signal


● Subjects may have moved the head during scanning
● Head shapes are very different to make a straight
comparison between them

To overcome these issues, we preprocess the images.


2.Statistical Parametric Mapping
(SPM)

Here, we will show how to perform preprocessing steps using


SPM (developed at UCL), which runs inside Matlab.
SPM is free and the newest version is SPM12. It can be
downloaded from:
www.fil.ion.ucl.ac.uk/spm/software/spm12/
2.Important observations on SPM
MATLAB’s
● NIfTI (.nii or .hdr/.img) and Analyze (.hdr/. current
folder:
img) are supported. You can also import change to
the folder
DICOM. where you
● There is no double click in SPM (it is a stored your
images. It
common mistake until you get used to it). will make
selection
○ A single click on the file includes or excludes it easier.
○ In the pop up windows, when inserting values,
Return key, just creates a new line. To confirm, hit
Ctrl+Return, or just click OK:

● SPM adopts neurological convention (left on the screen is subject’s left)


2.Automatization - Batch Editor
● Programming via GUI (no need to know
programming)
● Create model for a single subject and apply
to others
● Allows complete processing of several
subjects’ data
2. 0th preprocessing step - Reorienting
Note that the other preprocessing steps that
follow may work without Reorienting images,
but you risk getting shady results if not
performing this step.
Raw images have their origin (0,0,0) set to a
voxel that hardly ever is in the position
expected by SPM. So, let us set the origin in
the anterior commissure.
2. 0th preprocessing step - Reorienting
How to set the origin in the anterior commissure in SPM12:

1 - In Matlab workspace type: >> 2 - In the SPM main window, click


spm fmri on Display button.
2. 0th preprocessing step - Reorienting

3 - Add a structural 3D image and


click “Done” 4 - Set the blue crosshair
on the anterior commissure
2. 0th preprocessing step - Reorienting
5 - Observe the distance of the anterior
commissure from the actual image origin.

6 - Click “Set Origin”.

7 - Click “Reorient”.

8 - You do not need to “Save reorientation


matrix for future reference”, but it is up to you!

DONE!!!
2.Preprocessing per se
STEPS
1.Realignment: Coregistration between each volume of the functional image
–Motion correction
2.Slice timing correction: Temporal interpolation
–Compensates for the temporal difference in the acquisition of each slice
3.Coregistration: Coregistration between structural and functional images
–Allows us to use the structural image as the background of statistical results
4.Segmentation: Split structural image into different tissues (e.g., white matter, grey matter and CSF)
–Necessary step to perform normalization using “unified segmentation” algorithm
5.Normalization: Coregistration between template and subject’s image
6.Smoothing: Blurring with a gaussian kernel
–Reduces spatial variability, which is normally high; increases signal-to-noise ratio
2.1.Realignment
Objective: Motion correction
Operation: Rigid body transformation (translation and rotation)
Method: First scan of the list is used as a reference and all others are realigned (first scan of each
session with the first of all, and then scans of each session with respect to the first scan)
Output:
● Results window shows graphs of the translation and rotation
● Realign (Estimate):
○ In the folder where the functional images are: A rp_* .txt file and *.mat for each session
○ In the current folder (Current Folder in MATLAB): spm_aaaaMmmdd.ps file
● Realign (Estimate & Reslice):
○ rp_*. txt, *.mat, spm_*.ps
○ * .nii mean (average functional image of all EPIs)
○ r*.nii and r*.mat for each EPI but: avoid using Reslice because of interpolation errors; there
will be only one Reslice in Normalise. We recommend creating only Mean Image.
4
1

2
3: Choose:
Mean Image Only 3
2

Wrap Y 4
- Philips Achieva 3T:
fold-over direction =
"AP" (E.g..: nose may
appear behind the
head)

Obs.: The button to run the preprocessing step ("Play") is only


enabled when all fields with "<-X" are filled (see step 9).
9
5
7
6

6:
7: Right click; then Select All; or
- “cue to identify first session files”.*
Shift+click
- 1:N, we suggest to set N as a
6 number greater than the total
9: before running: repeat steps 5-8 for
all the sessions (EPIs)
number of scans and hit Enter.
Output Obs .: If we do realignment after
slice timing correction (which is the
case for interleaved acquisition
slices), in steps 5-8 we must select
files resulting from the slice timing
correction (a*.nii).
2.2.Slice timing correction
Objective: Temporal correction
Operation: Adjust the time of acquisition of each slice so it looks like they were acquired at the same
time – usually the interval between one slice and the next is TR/(number of slices)
Method: Add a phase in the frequency domain to create a shift in time
Output:
- In the folder where the EPIs are: a*.nii file and a*.mat file for each session
Warning:
- Necessary for:
- Long TR (but accuracy decreases with increasing TR: do for TR > 3s)
- Interleaved acquisition
- Event-related paradigm
- Alternative: include time derivative as an additional regressor in the design matrix
4
3:
2
- Number of slices: 40 (for
3 example)
- TR: repetition time in seconds
- TA: time interval between
acquisition of the first and last
slices. Write: TR-TR/(no. slices)
(E.g.: for TR = 2s and 40 slices,
write: 2-2/40)
- Slice order: the order of
acquisition of the slices (slice 1
is the bottom slice). The bottom
of the window Batch Editor
shows how to fill for each
situation. E.g., for bottom up
sequential acquisition
(ascending), write: 1:40
2: do exactly the same as steps - Reference slice: usually the
5-8 from realignment, choosing central slice is selected
the same files also
2.3.Coregistration
Objective: Align the structural and functional images; step necessary to implement the normalization
(“unified segmentation”)
Operation: Source Image and Other Images undergo rigid body transformation to align with the
reference scan
Method: Minimize or maximize chosen cost function
Output:
● Header of Source and Other Images is changed
3
1
2

2:
Ref. Image: mean*.nii (result of
Realign: Est & Res)
Source Image: structural image
Output
Check if co-registration is correct
by clicking on the images in
Graphics window.
You can also use Check Reg:
2.4.Segmentation
Objective (everything below is part of the same algorithm):
● Bias correction: yields more uniform intensity for the same types of tissue to facilitate automatic
processing (often visually imperceptible)
● It is necessary for the recommended method of spatial normalization
● CSF, white matter and gray matter separation
Output (in the folder where structural image is):
● Bias corrected: m*.nii
● y_*.nii and iy_*.nii files (used in spatial normalization step)
● Tissues (e.g.: c1: gray matter; c2: white matter; c3: CSF; c4: bone):
○ in alignment with the original image: c1*.nii, c2*.nii etc. (native space)
○ Normalized images: wc1*.nii, wc2*.nii etc. (unmodulated normalized),
○ mwc1*.nii, mwc2*.nii etc. (modulated normalized)
(Modulation: gray scale level adjustment and volume correction to keep total signal of gray matter)
Alternative: algorithms available in Batch -> SPM -> Tools -> Old Segment
2.4.Warning
● Segmentation can sometimes fail if the structural image is not
similarly orientated with MNI templates. In other words, we need:
○ anterior commissure to a maximum of 2 cm away from the point
(0,0,0)
○ image angulation within a few degrees of tissue probabilities map
● If the result of segmentation is weird, check image orientation (both
items above)
● To orient images, refer to 0th Preprocessing Step
8
1

2
3
4

5
6
4 7

2: Choose structural
image (the same
4: Tissues: 1 is gray matter, 2 is white matter, 3 CSF, 4 bone, 5 soft tissue, 6 air and
chosen in
background. We will use only 1, 2 and 3.
Coregistration) 5: Choose “None” for tissues 4, 5 and 6.
3: Choose “Save 6: Choose “Modulated + Unmodulated” for tissues 1, 2 and 3.
Bias Corrected” 7: Choose if you want to save Forward, Inverse or both deformation parameters
images (used to normalize or bring to native space, respectively)
2.5.Normalization
Objective: Convert images to coordinate standard space (MNI)
Operation: Distort the images to resemble the reference image
Methods available:
● Unified segmentation: advised method
1) Structural image is segmented
2) Grey matter of the subject is coregistered with grey matter of the template; white
matter is analogous
3) Spatial transformation is used to normalize the above EPIs
● Normalize: Estimate & Write gives worse results than the above method

● In this tutorial, we will use Unified Segmentation (Segment first, then Normalise: Write)
5

1 3
4
2

For structural image:


2: Voxel size in mm (e.g.: 1 1 1)
4: Deformation field: file *y_*.nii generated in Segmentation step
Images to Write: choose the bias corrected structural image resulting from Segmentation step (m*.nii)
2.5.Normalization
Do steps 1-5 again for the functional images, where:
2: voxel size in mm (e.g., 3 3 3)
4:
● Deformation Field: same file *y_*.nii generated in Segmentation step.
● Images to Write: functional images resulting from Slice Timing correction
(a*.nii) for all sessions (if there is more than one).

Output: w*.nii for all images chosen in Images to Write


2.6.Smoothing
Objectives:
● Intra-subject: reduce high variability of the signal between neighboring voxels; increase signal-
to-noise ratio
● Inter-subject: reduce effects due to differences between individual micro-structures
Operation: image blurring
Method: convolution of volumes with a gaussian kernel
Output: s*.nii file for each of the selected images
2: all functional images
4 (w*.nii), created in
1 Normalization step.
2
3 3: usually FWHM = 2 x
voxel size, i.e., for voxel
3x3x3 mm³ FWHM
would be 6 6 6
3.Statistical analysis
1. Create the model
2. Estimate the parameters
3. Show the results
3.1.Creating the model: SPM

1: In Matlab “workspace window” type:


spm fmri
3.1.Creating the model: SPM
2: Click to create a Batch processing file

3: SPM → Stats → fMRI model specification


3.1.Creating the model: SPM

4: Output Directory for the results

5: Units for design: Scans or Seconds. We will


use Seconds in this tutorial

Units for design is the time unit of the onset and


duration of the conditions (stimulus, spike, ...). You can
use Scans, and set the onset times and duration in
scan number units or in Seconds, as we defined on the
previous section in Excel. To convert Seconds to
Scans, divide the time in seconds by the acquisition
repetition time (TR) and add 1 (0s= scan 1)
3.1.Creating the model: SPM

6: Interscan interval = repetition time (time between


two consecutive scans or volumes). In this case TR is
2 seconds.
3.1.Creating the model: SPM

7: Data & Design: Click on it and then on New:


Subject/Session.
New options will appear: Scan, Conditions,
Multiple conditions, Regressors, Multiple regressors
and High-pass filter.

A session like that should be created for each EPI


(functional session) and should be filled with the
information obtained during this EPIs (stimuli, spikes
etc.)
3.1.Creating the model: SPM

8: Double click on Scans to add the preprocessed


functional images (“swa” prefix in this case)

Use the filter option to isolate the images of interest

Remember to add ALL volumes (dynamics) by typing


“inf” (“1:N”, where N is a number). Then right click on
the file list and Select All. To finish, click Done.
3.1.Creating the model: SPM
9: Double click on Conditions (events that occurred
during this session)

New options will appear: Name, Onsets, Durations:


● Name: set a name to distinguish a condition.
Ex.: Right_Spike
● Onsets: add all onset times of this condition (vector
of numbers with values in the units chosen).
● Durations: add a vector with the duration of the
events (can be 0). If all events have the same
duration, just add this value once. If they have
different durations, the vector must have the same
size as the Onsets vector.

Repeat these steps if you have more than one condition in the
same session.
3.1.Creating the model: SPM
Adding regressors: The regressor most commonly used is
the movement realignment parameters.
● The rp_*.txt file generated after the realignment can be
added to control the statistics for head motion.
● It has 6 columns: 3 with translation and 3 with rotation
parameters.

10: Double click on Multiple regressors.


11: Add the rp_*.txt file corresponding to the current session
(EPI). There is one rp_*.txt file for each EPI.
3.1.Creating the model: SPM

Repeat those steps if you have more


than one session (EPI):
● Use the same condition name if you have
the same type of condition in distinct
sessions
● The Onsets start from 0 in all sessions
(time is not cumulative between sessions)
3.1.Creating the model: SPM

12: Basis Functions → Canonical HRF → Model


derivatives, choose Time and Dispersion derivatives

The Canonical HRF (SPM default), in general, is a


good approach to physiological responses. By adding
derivatives, you design a more flexible model of
BOLD responses.
3.1.Creating the model: SPM
13: After choosing all parameters, the “Play” button
will turn green. Run your batch file!
3.2.Estimating the parameters: SPM

14: Model Estimation: SPM → Stats → Model


Estimation

The Model Estimation will estimate the betas,


residuals and other aspects of your model.
3.2.Estimating the parameters: SPM

15: Select SPM.mat: add the “SPM.mat” file created


in the output folder indicated during the fMRI model
specification

16: After that step, the “Play” button will turn green.
Run your batch file!
3.3.Results: SPM

17: To proceed with the results, go to the SPM


Menu, and click on Results
3.3.Results: SPM

Add the SPM.mat file after model


estimation
3.3.Results: SPM
Now we will define the contrasts. Contrasts indicate the
statistical tests applied to the estimated Betas.

This is the design matrix. Each column represents a


condition or regressor of the model.
3.3.Results: SPM

Each block represents a session (EPI)

In this figure (just an example), six runs (or


sessions or EPIs) were added!
3.3.Results: SPM
1 2 3 4 5 6 7 8 9 Each column in a block represents regressors/conditions
added in a session:

1 - Condition: cond1

2 - Derivative 1 of cond1 (time derivative)

3 - Derivative 2 of cond1 (dispersion derivative)

4:9 - Six movement regressors


3.3.Results: SPM
In total, there are 45 columns, and the condition of
interest (cond1) is always the first column of each block
(session)

The contrast vectors just indicate the columns of


interest and their weights. In this example it would be:

1000000001000000001000000001000000001000000001

8 zeros
2 from the derivatives and 6 from the movement regressors

So far….
3.3.Results: SPM

1 - Click on t-contrast → Define new contrast


3.3.Results: SPM

2 - Give a name for your contrast

3 - Enter the contrast vector. Remember to


always type a space between numbers

3 - Click Ok
3.3.Results: SPM

4 - Select the contrast

5 - Click Done
3.3.Results: SPM

6 - Apply masking: for whole brain studies


click on none
3.3.Results: SPM
7 - Define the statistical adjustment. FWE
(Family Wise Error) is a very good approach to
correct against false positives, but also very
restrictive.
3.3.Results: SPM

8 - Define the statistical threshold: only


voxels with p-value smaller than the chosen
threshold will be shown.

9 - Define the cluster size threshold: only


regions with at least this number of clustered
voxels will be shown.
3.3.Results: SPM
Navigate using left-
and right-click

There are lots of options to


explore the results
EEG-informed
fMRI Analysis
Using SPM
1.Preprocessing
● EEG-informed fMRI analysis: some information from the
EEG is used in the fMRI statistical analysis

● The preprocessing can be the same as you would do for


a similar study without EEG (as explained in the
previous session)
2.Statistical analysis
● For the fMRI statistical analysis, onsets and durations of
the stimuli must be inserted

● EEG-informed fMRI analysis: the “stimuli” are events in


the EEG

● Get the events of interest from the EEG and use them
as stimuli in the fMRI statistical analysis
3.Creating the model
How to prepare your EEG output to insert in SPM General
Linear Model (GLM)?

There are many ways to do this. We will show how to use


Excel manually, but you can create a macro or use Matlab.

For epilepsy, Excel may be the best choice. For paradigms


with a simple repetition pattern, Matlab is enough.

The following example is just one possible scenario.


3.Creating the model: Preparation

Analyzer folders:
1. Export
2. History
3. Raw
3.Creating the model: Preparation
Inside the Export folder

One marker file per


functional scan (EPI)

The Markers files describe all response times registered by the MRI trigger and the events
(markers, stimulus, spikes….) marked by the user on the EEG data.
3.Creating the model: Preparation
Export folder

The files can be opened with a


text editor
3.Creating the model: Excel
We will show an example of methodology to organize your data for
future insertion in a statistical model: the ExcelⓇ way.

1 - Open a new spreadsheet


2 - Go to data options
3 - Choose the option from a
text file (or something similar)
3.Creating the model: Excel

1 - Go to your Export folder


2 - Modify the filter to All Files
3 - Choose a file
4 - Import
3.Creating the model: Excel

Select Delimited
3.Creating the model: Excel

1 - Set the Delimiters to Others and


use the comma
2 - Finish
3.Creating the model: Excel
There are 4 columns: Type, Description, Position, Length and Channel

Copy your sampling interval (just


the value) to a separate cell

4
3.Creating the model: Excel
To convert Position from sample points to seconds, you need to create an equation:

The Position of the first “Response”


(R128) is the EEG time when the first
MRI trigger occurred. This time will be the
reference to calculate all stimuli (spikes,
events, ...) onset times.
3.Creating the model: Excel
Onset is the instant when your stimulus started on the EEG

The Onset equation:

The equation is: The Stimulus


Position (C9), minus the Reference
Position (C3), multiplied by the
Sampling interval (1/250Hz or 4 ms)
(C1). Divide by 1000 to get the
answer in seconds.

If you apply the same equation to two


consecutive “R128” markers, you’ll get 2
seconds, which is the TR used.
3.Creating the model: Excel
Duration is the period that your event lasted on the EEG The Duration equation

The equation is: The Stimulus Length


(D9), multiplied by the Sampling
interval (1/250Hz or 4 ms) (C1) and
divided by 1000 to get the answer in
seconds.

Each “R128” marker has a duration of 1


sampling point, or 4 ms. In the original
recording, the sampling interval was 0.2 ms
(5 kHz) This creates the jitter in the artifact
template calculation.
3.Creating the model: Excel

These are the vectors needed to design the statistical model (GLM) in SPM.
4.Statistical analysis
● The onset, duration and name of all events in the EEG
must be inserted into the statistical model (GLM)
● This can be done as shown in the section about fMRI
analysis
● Model creation, parameter value estimation and results
follow the same pipeline
5.Complete analysis with SAfE
SAfE = Straightforward Analysis of fMRI and EEG-fMRI
● Available at: http://www.lni.hc.unicamp.br/~beltramini/#safe (tested
with SPM8)
● Preprocessing
● Statistical analysis
○ Including macro in Excel to organize the markers
● Results
6.SAfE: Excel

User input

Macro
6.SAfE: Matlab
Additional information
● fMRI
○ Buxton, R.B. (2009). Introduction to Functional Magnetic Resonance
Imaging: Principles and Techniques. Cambridge University Press
○ Huettel, S.A., Song, A.W., McCarthy, G. (2014). Functional Magnetic
Resonance Imaging. Sinauer Assoc.
● EEG
○ Buzsaki, G. (2011). Rhythms of the Brain. Oxford University Press
○ Niedermeyer, E. & Lopes da Silva, F. (2004). Electroencephalography:
Basic Principles, Clinical Applications, and Related Fields. Lippincott
Williams & Wilkins
● SPM
○ User Manual
○ Discussion list: http://www.fil.ion.ucl.ac.uk/spm/support/
● BV Recorder and BV Analyzer 2
○ User Manuals
○ Press Release Articles (tricks and tips, LORETA, ICA, ...): http://www.
brainproducts.com/productdetails.php?id=17&tab=3
● EEG-fMRI:
○ Mulert, C. & Lemieux, L. (2010). EEG - fMRI: Physiological Basis,
Technique, and Applications. Springer
○ Ullsperger, M. & Debener, S. (2010). Simultaneous EEG and fMRI:
Recording, Analysis, and Application. Oxford Univ. Press
○ http://www.jove.com/video/50283/best-current-practice-for-obtaining-high-
quality-eeg-data-during
○ Beltramini, G.C. (2014). Análise temporal de correlatos hemodinâmicos
associados à atividade epileptiforme através da técnica de EEG-RMf
simultâneos. Ph.D. Thesis. University of Campinas: Brazil [text in
Portuguese] http://webbif.ifi.unicamp.br/teses/apresentacao.php?
filename=IF1660
If you have questions, suggestions, comments,
please contact us at
sci.supp@brainsupport.com.br

For more products and solutions, check out


www.brainsupport.com.br

You might also like