Docsity

Spm8 processing manual, Appunti di Bioimaging

Toggle sidebar
bg1
SPM8%Processing%Manual%
Table%of%Contents%
SPM8%Processing%Manual................................................................................................................... 1!
SPM%Introduction ................................................................................................................................. 3!
SPM!Introduction......................................................................................................................................... 3!
Using!SPM .................................................................................................................................................... 6!
Order!of!Preprocessing ................................................................................................................................ 7!
PREPOCESSING...................................................................................................................................... 9!
Basic!IO ........................................................................................................................................................ 9!
Convert!files!to!SPM!format ........................................................................................................................ 9!
Slice!Timing ................................................................................................................................................ 10!
Realignment ............................................................................................................................................... 10!
Coregistratio n ........................... ........................... ............................ ........................... ........................... .... 11 !
Segmentation ............................................................................................................................................ 11!
Normalizatio n ................................ ................................. ................................. ................................. ......... 12!
Smoothing ................................................................................................................................................. 13!
SUBJECT%LEVEL%ANALYSIS............................................................................................................... 14!
1st!level!analys is ................................ ................................. ................................. ................................. ...... 14!
fMRI%model%s pecification ...... ..................... ...................... ...................... ...................... ...................... .... 14!
Model%estimation .................................................................................................................................. 16!
Contrasts: .............................................................................................................................................. 16!
Printing%Results...................................................................................................................................... 17!
Multiple!conditions!file!for!1st!level!design!specification .......................................................................... 17!
Creating%a%M ultiple%condition%f ile ........................ .......................... ........................... .......................... ... 17 !
Examples%of%Matlab%scripts%for%getting%onsets%into%multiple%conditions%file .......................................... 19!
GROUP%ANALYSIS ...............................................................................................................................21!
2nd!level!analysis ........................................................................................................................................ 21!
Specify%Design........................................................................................................................................ 21!
Model%estimation .................................................................................................................................. 22!
Contrasts ............................................................................................................................................... 22!
Results ....................................................................................................................................................... 22!
Viewing%Results ..................................................................................................................................... 22!
Significance%Table .................................................................................................................................. 23!
Overlay%Images...................................................................................................................................... 23!
Plot ........................................................................................................................................................ 24!
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Anteprima parziale del testo

Scarica Spm8 processing manual e più Appunti in PDF di Bioimaging solo su Docsity!

SPM8 Processing Manual

  • SPM8 Processing Manual................................................................................................................... Table of Contents
  • SPM Introduction
  • SPM Introduction.........................................................................................................................................
  • Using SPM....................................................................................................................................................
  • Order of Preprocessing................................................................................................................................
  • PREPOCESSING......................................................................................................................................
  • Basic IO
  • Convert files to SPM format
  • Slice Timing................................................................................................................................................
  • Realignment...............................................................................................................................................
  • Coregistration
  • Segmentation
  • Normalization
  • Smoothing
  • SUBJECT LEVEL ANALYSIS
  • 1 st level analysis
    • fMRI model specification
    • Model estimation
    • Contrasts:
    • Printing Results......................................................................................................................................
  • Multiple conditions file for 1st level design specification
    • Creating a Multiple condition file
    • Examples of Matlab scripts for getting onsets into multiple conditions file..........................................
  • GROUP ANALYSIS
  • 2 nd level analysis
    • Specify Design........................................................................................................................................
    • Model estimation
    • Contrasts
  • Results
    • Viewing Results
    • Significance Table..................................................................................................................................
    • Overlay Images......................................................................................................................................
    • Plot
  • Batch Script Processing
  • GIU Batch...................................................................................................................................................
  • Script Batch (Advanced).............................................................................................................................
  • Preprocessing_batch.m
  • Preprocessing_batch_job.m

b) To process data you can use the first window and select each step individually or

you can use the “batch” function from the Menu or Graphics window.

c) The Batch Editor will open in a new window. The window can be

stretched/resized to see all information. An “<-X” means you need to enter data

for this line. Use the mouse to select each line.

Information on the batch interface can be found in the SPM8 manual.pdf chapter 42

i) Adding to the Batch

(1) Processes can be added, deleted & replicated in the batch but the order is

determined by the order it is added to the script, appending to the end. It

cannot be reordered manually.

(a) Different stages can be saved separately & loaded together to create

1full script.

ii) Saving & Editing Batch files. I recommend saving each batch you run for later

editing and/or checking of work.

(1) File - > Save Batch or the Save button

(2) File - > Save Batch & Script: use this option if you plan on doing advanced

editing in matlab

(a) Useful for mass edit & replace of file names/locations

(b) Output: filename.m & filename_job.m

(i) You must edit the number of runs in filename.m for the file to run.

(c) Edit .m file in matlab editor

(i) Once a template has been made enter the information for 1 subject

(ii) Open filename_job.m file in matlab editor

1. Edit replace file locations for each subject (subject directory)

2. Save filename_job.m file with

(d) Run script:

(i) Matlab prompt: run filename.m

(ii) Batch window

1. load filename.m (multiple files can be loaded at once) and it will

automatically start the script,not necessary to load

filename_job.m

2. load filename_job.m (multiple files can be loaded at once) and

you can view and edit batch before running/executing it

iii) Loading a saved batch file

(1) File - > load batch or the Open folder button

iv) Clearing batch:

(1) Clear all information: select “new” or new icon on toolbar

(2) Clear selected files: while on procedure of interest: Edit - > Clear Value

iii) Selecting nii files

(1) Select nii file, & all timepoints

(a) Filter: ^filename

(i) ^ start of a string

(ii) $ end of a string

(iii). any character

(iv)

(b) Specify timepoints: 1:1000 (can set above available timepoints)

(2) Ed : you can use this option to change selected file information (changing a

2 to a 3….)

(3) Rec : recursively select files with current filter in all subdirectories of

current location

c) SPM Terms:

i) TR = time for 1 collection of all slices (usually 2500ms)

(1) # of TRs = # of volumes = # of scans

(a) These terms are used interchangeably in the field

(b) TR will refer to time length

(c) # of TRs will be verified by imbedded data in the Dicom and Nifti files.

If the number of files does not match SPM will crash. If this happens

start with the conversion step again.

ii) Session: this refers to 1 scan/run (ex: 7 or 8 ). It does not refer to all runs

together.

(1) These steps require processing of individual sessions:

(a) DICOM conversion

(b) Slice Timing

(c) Realignment

(d) Analysis

(2) These steps can be run with all sessions together:

(a) Normalization

(b) Smoothing

Order of Preprocessing

Preprocessing can be done in a few different ways

a) Direct Normalization

i) Realign - > Slice Time* - > Normalization - > Smoothing

b) Indirect Normalization

i) Realign - > Slice Time* - > Coregistration - > Segmentation - > Normalization - >

Smoothing

c) *Slice Timing is an optional step. The order of slice timing depends on the

amount of movement and the slice acquisition order (sequential vs. interleaved,

WUSTL data = sequential). See notes below.

42.1. BATCH TUTORIAL - SINGLE SUBJECT 453

Figure 42.3: Flow chart for batch

    1. 5 Data flow In chapter 29 , each processing step was performed on its own. In most cases, output data was simply passed on from one module to the next. This scheme is illustrated in figure 42. 3. Only the coloured items at the top of the flow chart are subject specific and need to be entered in the final batch. All arrow connections are subject-independent and can be specified in the batch template.

Slice Timing

Slice timing accounts for acquisition timing. This step is sometimes considered optional

in the processing stream. The order of slice timing, before or after realignment, depends

on your data. If you have acquired slices in sequential order and have little movement

then you should do realignment first : correct for the movement and then account for the

timing of acquisition. If you have acquired slices in sequential order and have lots of

movement run slice timing first and then realignment: it is likely that the slice timing will

correct for the wrong slice if there is a lot of movement and it has been corrected for.

Interleaved slice acquisition: debatable whether to use slice time correction especially

with large movement. If you plan on running a DCM analysis you must run slice timing.

a) Temporal: Slice Timing

i) Session: select data for each session individually, do not combine across a

subject

ii) # of slices: 26

iii) TR: 2.5 seconds

iv) TA: 2.5-(2.5/26)

v) Slice order

(1) Interleaved Slice order:

(a) bottom->up

(b) 1:2:26 2:2:

(c) Reference slice: the middle acquired slice during the TR (ex.: 13 or 2)

(2) Sequential Slice order:

(a) Ascending (Bottom->up): [1:1:nslices] (ex.: 1:1:26)

(b) Descending (Top->down): [nslices:-1:1] (ex.: 26:-1:1)

(c) Reference slice: middle slice (ex.: 13)

b) Output

i) a.img & .hdr for each image or a single a.nii file for the entire run

Realignment

The realignment step corrects for motion across and within sessions of an individual

subject. Acceptable movement is up to 6 mm, however, with the realignment step and

inclusion of the text output even the most extreme movement can be controlled for. With

SPM all timepoints must be included. Timepoints with large movement cannot be

removed as they can be with other programs but use of the ART program can specify

movement and signal outliers as a regressor to be included at the 1

st

level.

a) Spatial: Realign: Estimate & Reslice

i) Estimate only: no new images that are resliced, only estimated parameters

written to files

b) Add number of sessions per scan

c) Select files for each session (ex. 201, then 301, then 401)

d) Defaults:

i) Resliced images: mean only

e) Output:

i) mean*.nii: mean image of all sessions for this subject

ii) Filename prefix: r

(1) If you select reslice images & mean this will be the prefix applied to the

output

iii) rp_session1.txt: this file contains information of the mm of motion correction

for each slice for translation (x,y,z) and rotation (roll, pitch, and yaw)

dimensions per run/session

Coregistration

This step is included for indirect normalization. Since EPI data is not as detailed as the

structural T1 images this option allows for a better normalization to the MNI template. In

this step you will coregister the individuals T1 to their EPI.

a) Spatial: Coregister: Estimate & reslice

i) Reference image: This image does not move

(1) Mean EPI image

ii) Source Image: This image is the one that will move

(1) T1 image

Segmentation

This is the second step in indirect normalization. This will segment the T1 image into

CSF, white matter, & grey matter. Segmentation is based on the MNI template;

therefore this step must calculate the transformation before segmenting. These

calculations will be used to in the next step of normalization of the EPI images.

a) Spatial: Segmentation: Estimate

b) Data: coregistered T1 volume

i) Dependency: coregistration output

c) Sampling size: if using a T1 image that has small voxel size in raw format change

from 3 - > 2

d) Output files: coordinate transformation

(i) Optional: grey, white, csf

(ii) Default: native

(iii) If doing VBM analysis: native + modulated + unmodulated

e) Optional: New Segment

iii) Images to write: (Dependency) output from Coregistration

Smoothing

The smoothing process applies a smoothing filter to the images. This helps with subject

spatial differences especially when it comes to group analysis. If there is a specific

region you are interested in, sensitivity can be optimized by smoothing to the diameter

of that region. However, remember that all regions are not the same size and this may

affect other regions.

a) Spatial: Smooth

b) Images to smooth

i) Dependency - > Normalize output

(1) normalize: estimate & write: normalized images subject 1

(2) All subjects/sessions can be smoothed at the same time

c) FWHM

i) Edit value: enter a vector of 3 numbers, usually the same smoothing filter in

all dimensions

(1) [8 8 8]

(a) a minimum of 2voxel diameters (or widths)

(b) minimum of 6mm

ii) Output: Filename prefix: s

SUBJECT LEVEL ANALYSIS

1 st^ level analysis

In this step we specify the design and the contrasts at the individual subject level. At this

stage we enter all the information about different conditions, onsets and durations for all

the scans combined across a subject. After the model has been specified it must be

“estimated”. For Block design studies I suggest creating a template with onsets/

durations. For Event design I suggest using the “multiple conditions” option which allows

for the uploading of a *.mat file that contains all the condition information. Multiple

conditions can be used for either design but most useful for event design where a lot of

information is being entered.

fMRI model specification

i) Directory: select separate output directory for each analysis

(1) Suggestion: “results” or “results1”

ii) Timing Parameters

8.2. DATA & DESIGN 63

Figure 8.2: Design matrix for fMRI data from two sessions. There are 24 experimental conditions for each session. The last two columns model the average activity in each session, giving a total of 50 regressors. There are 191 fMRI scans for each session. The overall design matrix therefore has 382 rows and 50 columns. want to temporally realign the regressors so that they match responses in the middle slice then make t 0 = t/2 (assuming there is a negligible gap between volume acquisitions). Do not change the default setting unless you have a long TR. A typical use of the t and t 0 parameters is to set them to correspond to the results of any slice timing correction you have made eg. if you have 24 slices and have made slice 12 the reference slice you would set t=24, t0=12.

  1. 2 Data & Design The design matrix defines the experimental design and the nature of hypothesis testing to be implemented. The design matrix has one row for each scan and one column for each effect or explanatory variable. (e.g. regressor or stimulus function). Figure 8. 2 shows an example of a design matrix. You can build design matrices with separable session-specific partitions. Each partition may be the same (in which case it is only necessary to specify it once) or different. Responses can be either event- or epoch related, where the latter model involves prolonged and possibly time- Design Matrix for 2sessions & 4conditions

Model estimation

a) Select SPM.mat file

i) Dependency: fMRI model specification: SPM.mat

Contrasts:

Contrasts are entered on an individual subject & session basis, useful if each subject

does not have the same conditions across all sessions, or they can be entered at the

end and replicated if the conditions are consistent across subjects and sessions. I

recommend first specifying a t-contrast for each condition individually then using a

factorial design at the group level. In addition, if you want to do group comparisons

enter the specific contrast desired (cond1 vs cond 2) at the individual level as well.

(1) Individual subject level

(a) Select SPM.mat file

(i) Dependency: Model Estimation: SPM.mat

(ii) OR select SPM.mat file specific to the subject

(b) New: F-Contrast

(i) Specify an F-contrast for all conditions so that you can later examine

activity in a region relative to each task (i.e., plot activity for that region

by condition)

1. Name: effects of interest

2. Specify a 1 for each condition and the rest as 0 with 1 line per

condition:

(c) New: T-Contrast

(i) Enter appropriate name for contrast (ex: cond1 or cond1-cond2)

(ii) Enter the contrast desired (ex: 0 1 0 0 0 1 0 0 0 1 0 0 )

(iii) Be sure that there is a number for each condition across all runs

1. Replicate: If conditions are the same across runs specify the

contrast for the first run (ex: 0 1 0 0) and select replicate

2. You must take into account any regressors included in the model

specification. You will specify all regressors as 0. If you are

replicating you can leave the last columns blank

(iv) If comparing 2 or more conditions at the subject level the contrast must

equal 0 (ex: 0 1 0 - 1 or .5 .5 0 - 1)

(d) Editing existing contrasts: If you prespecified contrasts and made an error

you can edit & rerun the contrast file but be sure to select “delete existing

contrasts.” Otherwise the new contrasts will be added after the existing

ones

Printing Results

There is an option in the batch mode to print the results of any contrast specification.

a) Batch - > Stats - > Report Results

i) Select SPM.mat file

ii) Contrast Query:

(1) Contrasts: Inf will give all contrasts from this SPM.mat file

(2) Threshold: FWE & p<.05 or none (uncorrected) & p<.

(a) The p-values can be adjusted

Multiple conditions file for 1st^ level design specification

For 1st^ level design specification you can manually enter names, onsets, & durations for each

condition & run or you can select a mat file that includes an array of all names, onsets &

durations. You will need a multiple conditions file per run/session you specify.

Creating a Multiple condition file

  • Create a skeleton array that includes the names & durations pre‐specified.

o Use {} to specify the arrays. All parts will be grouped based on {n}.

 names {1} = cond

Examples of Matlab scripts for getting onsets into multiple conditions file

%%%%%%%%%%%%%%%%% EVENT SPM PM REGRESSOR SCRIPT %%%%%%%%%%%%%%%%%%%%%% %%%THIS SCRIPT MAKES INPUT REGRESSORS FOR SPM BASED ON THE AFNI PM AFNI %%%%EVENT REGRESSORS AS INPUTS function [onsets, names, durations]=reg_trans_SPM(subjs) %%%%DEFINE SUBJS & INPUT DIRECTORY %subjs=[1009211]; %%%%STATIONARY VARIABLES runs=[0,3,5,15]; counter=1; %%%%LOAD EVENT TEMPLATE WITH DURATIONS AND HEADER NAMES load multi_cond_event.mat for subj=subjs for run=runs %%%LOAD AFNI INPUTS

test=sprintf('load subj%d_%d_globaltimes.txt', subj,run); eval(test) %%%SAVE ONSETS (EACH COL= DIFFERENT CONDITION) test2=sprintf('onsets{counter}= transpose(subj%d_%d_globaltimes)',subj,run); eval(test2); counter=counter+1; end end %%%%SAVE MAT FILE WITH OUTPUTS outputname=sprintf('save subj%d_trans_spm.mat onsets names durations',subj); eval(outputname);