using osl: sensor space analyses - ohba analysis group · fieldtrip fsl fastica neuromag netlab...

44
Using OSL: Sensor Space Analyses OHBA Analysis Workshop Mark Woolrich

Upload: others

Post on 22-Jul-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Using OSL: Sensor Space Analyses

OHBA Analysis Workshop !

Mark Woolrich

Page 2: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

•  Induced  analysis  of  the  decision  making  period:  •  source  reconstruc*on  •  epoching:  8me-­‐locked  to  when  the  response  is  given  •  compute  the  average  evoked  power  (the  induced  response,  ERD/ERS)  from  1-­‐12Hz    •  group  averaged  over  30  subjects

25% 40%OR

Response  locked

Hunt et al., Nature Neuroscience, 2012.

superior  parietal  lobule  (SPL) premotor  

cortex  

primary  motor  cortex  

Page 3: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Talk Outline!• Analysing continuous data in sensor space

• time-wise GLM !

• Analysing epoched data in sensor space • trial-wise GLM

!• OSL (OHBA’s Software Library):

• OAT (OSL’s Analysis Tool)

Page 4: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Continuous Data Example

• Finger tapping versus rest

• 20sec blocks of alternating:

➡ rest

➡ finger tapping

• We want to compare changes in beta power (13-30 Hz)

Page 5: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

AFRICA: remove eyeblinks/cardiac etc. Epoch

Remove outlier trials

Time-frequency decomposition

Source reconstruction

Signal Source Separation (MaxFilter) Convert into SPM format

Compute statistics on contrasts

oslview: remove bad epochs

Fit General Linear Model (GLM)

Page 6: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

AFRICA: remove eyeblinks/cardiac etc. Epoch

Remove outlier trials

Time-frequency decomposition

Source reconstruction

Signal Source Separation (MaxFilter) Convert into SPM format

Compute statistics on contrasts

oslview: remove bad epochs

Fit General Linear Model (GLM)

Page 7: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

AFRICA: remove eyeblinks/cardiac etc.

Time-frequency decomposition

Signal Source Separation (MaxFilter) Convert into SPM format

Compute statistics on contrasts

oslview: remove bad epochs

Fit General Linear Model (GLM)

beta power time courses

• continuous data

• time-wise GLM

• in the time-frequency domain

Page 8: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

Rest condition

Beta power time course at a sensor

error

+!

time

b1

0 1

Finger tapping

condition

+!

0 1

b2

Continuous Data Time-wise Example

Page 9: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

Y! X! e b =! +!

Design Matrix

Finger tappingcondition

Rest condition error

b1 b2

+!

time

More formally we fit (for each sensor) a General Linear Model (GLM):

Time-wise GLM Example

Beta power time course at a sensor

Page 10: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

Y! X! e b =! +!

Design Matrix

error

b1 b2

+!

time

Dependent Variable

Independent Variables

Time-wise GLM Example More formally we fit (for each sensor) a General Linear Model (GLM):

Beta power time course at a sensor

Finger tappingcondition

Rest condition

Page 11: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

Y! X! e b =! +!

Design Matrix

error

b1 b2

+!

Dependent Variable

Regressors

Regression parameters

Time-wise GLM Example

time

More formally we fit (for each sensor) a General Linear Model (GLM):

Beta power time course at a sensor

Finger tappingcondition

Rest condition

Page 12: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

Y! X! e b =! +!

Design Matrix

error

b1 b2

+!

Dependent Variable

Regressors

UNKNOWN

Time-wise GLM Example

time

More formally we fit (for each sensor) a General Linear Model (GLM):

Beta power time course at a sensor

Finger tappingcondition

Rest condition

Page 13: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

Y! X! e b =! +!

Design Matrix

Finger tapping

condition

Rest condition error

b1 b2

+!

time

GLM  can  be  fitted  at  each  sensor

Y=Xb+e

Repeat for all sensors

Sensor (topographic) map of mean beta power decrease

between finger tapping and rest, i.e. B1-B2

Beta power at a sensor

time

Ordinary Least Squares (OLS) estimate B=[B1, B2], which are the

Parameter Estimates (PEs) of b

Page 14: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Epoched Data Example

• Faces versus motorbikes

➡ 240 trials (epochs) of presenting pictures of faces

➡ 120 trials (epochs) of presenting pictures of motorbikes

• We want to compare the responses time-locked to stimulus presentation (i.e. the Event-Related Fields (ERFs))

Page 15: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

AFRICA: remove eyeblinks/cardiac etc. Epoch

Remove outlier trials

Time-frequency decomposition

Source reconstruction

Signal Source Separation (MaxFilter) Convert into SPM format

Compute statistics on contrasts

oslview: remove bad epochs

Fit General Linear Model (GLM)

Page 16: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

AFRICA: remove eyeblinks/cardiac etc. Epoch

Remove outlier trials

Signal Source Separation (MaxFilter) Convert into SPM format

Compute statistics on contrasts

oslview: remove bad epochs

• epoched data

• trial-wise GLM

• in the time-domain

Fit General Linear Model (GLM)

Page 17: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

1s Local field potential (LFP)

1nAm

1pT pick-up coils

What we’ve got

What we want

sensor 1

sensor 2

time

sens

or

Epoching  and  ERFs

Epoching takes continuous 2D data: sensors x timepoints !!

Page 18: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

1s Local field potential (LFP)

1nAm

1pT pick-up coils

What we’ve got

What we want

time

sens

or

tria

l 1

tria

l 2

tria

l 3

tria

l 4

tria

l 5

tria

l 6

tria

l 7

tria

l 8

Epoching  and  ERFs

sensor 1

sensor 2

Epoching takes continuous 2D data: sensors x timepoints !!

Page 19: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

evoked response

Averaging

trial 1

trial 2

trial N

Epoching takes continuous 2D data: sensors x timepoints

and produces epoched 3D data: sensors x trials x timepoints-within-trial !

E.g. at one sensor:

+0.3s-0.1s(time of stim presentation)

time within trials

trial

sEpoching  and  ERFs

0s

Page 20: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

evoked response

Averaging

trial 1

trial 2

trial N

+0.3s-0.1s

time within trials

trial

s

Average over all “face” epochs/trials to get a face Event Related Field (ERF):

time within trials (s)

0s

Epoching takes continuous 2D data: sensors x timepoints

and produces epoched 3D data: sensors x trials x timepoints-within-trial !

E.g. at one sensor:

Epoching  and  ERFs

(time of stim presentation)

Page 21: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

error

+!

trials

b1

0 1

+!

0 1

b2

Motorbikescondition

Face condition

Data at a sensor and at a timepoint within trial

Trial-­‐wise  GLM

Page 22: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

Y! X! e b =! +!

Design Matrix

Motorbikescondition

Face condition error

b1 b2

+!

trials

Trial-­‐wise  GLM

Data at a sensor and at a timepoint within trial

Page 23: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

Y! X! e b =! +!

Design Matrix

Motorbikescondition

Faces condition error

b1 b2

+!

trials

GLM  can  be  fit  to  each  time-­‐point  within  trial

Y=Xb+e

Repeat for all timepoints within-trial at a sensor

Motorbikes (B2) at a sensor near the visual cortex (motorbike ERF)

Data at a sensor and timepoint-within-trial

trials

time within trials (s)

Estimate B, which are the Parameter Estimates (PEs) of b

Page 24: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

Y! X! e b =! +!

Design Matrix

Motorbikescondition

Faces condition

Data at a sensor and timepoint-within-trial error

b1 b2

+!

trials

Y=Xb+e

Repeat for all sensors at a time-within-trial

Motorbikes (B2) at 100ms post-stimulus

Estimate B, which are the Parameter Estimates (PEs) of b

The  GLM  can  be  fit  to  each  sensor

trials

Page 25: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

=!

Sensor data at a voxel and at a timepoint

within trialerror

+!

trials

Note that the GLM is a general framework, e.g. in which we can also fit continuous variables:

b1

GLM

total value of the two

options

Hunt, Nature Neuroscience, 2012

Page 26: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Contrasts

Contrast [1 0] gives a COPE =1xB1+0xB2

= B1

Contrast [1 -1] gives a COPE =1xB1-1xB2

= B1 - B2

=!

Y! X! e b =! +!

Design Matrix

Motorbikescondition

Face condition error

b1 b2

+!

trials

A COntrast of Parameter Estimates (COPE) is a linear combination of the regression parameter estimates, e.g.

Page 27: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Contrasts

Contrast [1 0] gives a COPE =1xB1+0xB2

= B1

Contrast [1 -1] gives a COPE =1xB1-1xB2

= B1 - B2

=!

Y! X! e b =! +!

Design Matrix

Motorbikescondition

Face condition error

b1 b2

+!

trials

Use a t-test to test the null hypothesis that COPE=0:

t-statistic:

t =COPE

std(COPE)

t =COPE

std(COPE)

t =COPE

std(COPE)

t =COPE

std(COPE)

A COntrast of Parameter Estimates (COPE) is a linear combination of the regression parameter estimates, e.g.

Page 28: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Null Hypothesis Test

t’

t

t’

t

t =COPE

std(COPE)t-statistic:

P-Value=prob(t>t’|COPE=0) (one-tailed test)

Under null hypothesis, COPE=0,

t’ is from a t-distribution

Small P-Value => null hypothesis unlikely If P-Value < P-threshold then reject null hypothesis P-threshold corresponds to False Positive Rate (FPR)

Page 29: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Contrasts

A COntrast of Parameter Estimates (COPE) is a linear combination of parameter estimates, e.g.

Contrast [0 1] gives a COPE = 0xB1+1xB2

= B2 =!

Y! X! e b =! +!

Design Matrix

Motorbikescondition

Face condition error

b1 b2

+!

trials

t =COPE

std(COPE)

t =COPE

std(COPE)

t =COPE

std(COPE)

Test the null hypothesis that B2=0 e.g. where in time and space is there significant positive* activity in response to the motorbike condition? !* as we are doing a one-tailed t-test

Page 30: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Contrasts

Contrast [1 -1] gives a COPE =1xB1-1xB2

= B1 - B2 =!

Y! X! e b =! +!

Design Matrix

Motorbikescondition

Face condition error

b1 b2

+!

trials

t =COPE

std(COPE)

t =COPE

std(COPE)

t =COPE

std(COPE)

Test the null hypothesis that B1-B2=0 e.g. where in time and space is there more* activity in response to the faces than the motorbike condition? !* as we are doing a one-tailed t-test

A COntrast of Parameter Estimates (COPE) is a linear combination of parameter estimates, e.g.

Page 31: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Other stuff the GLM can do• Linear trends between conditions

➡ plus quadratic, higher order trends

• Factorial designs (interaction effects)

• F-tests (combined explanatory power over multiple contrasts)

• Subject-wise GLMs at the group level (e.g. patients vs controls)

• See the FSL course FEAT/FMRI Preprocessing and Model-Based slides at:

http://www.fmrib.ox.ac.uk/fslcourse

Page 32: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

OHBA’s Software Library

OSL

SPM

Fieldtrip

FSL fastICA Neuromag Netlab Custom software

OSL can be used for • task (GLM) and rest (e.g. ICA) analyses • preprocessing • sensor space analysis • source space analysis • statistics

Page 33: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

OAT - OSL’s (easy) Analysis Tool

• Task-based analysis in:

➡ sensor space, or

➡ source space (e.g. via beamforming)

• In:

➡ in time-frequency domain (e.g. induced responses)

➡ time domain (e.g. ERF-style), or

• First-level (within-subject) analysis, using:

➡ trial-wise GLM on epoched data

➡ time-wise GLM on continuous data

• Group-level (between-subject) subject-wise GLM analysis

Page 34: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

OAT Pipeline Stages

• 4 distinct pipeline stages:

SPM MEEG object

subject COPES and t-statistics

Source Reconstruction

First-level within-session GLM

Subject-level session averaging

Design matrix

Contrasts

OAT

session COPEs and t-statistics

group COPES and t-statistics

Group-level subject-wise GLM

Design matrix

Contrasts

(Note: the source recon stage always gets run even for a

sensor space analysis)

Page 35: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

OAT Setup and Pipeline Stages• Set some mandatory fields, and then use

osl_check_oat call to setup an OAT struct:

➡ oat= osl_check_oat(oat);

• 4 distinct stages to the pipeline, with corresponding settings:

➡ oat.source_recon, e.g. • oat.source_recon.method=‘beamform’; % for beamforming

• oat.source_recon.method=‘none’; % for a sensor space analysis

➡ oat.first_level (GLM within-session analysis)

➡ oat.subject_level (within-subject averaging)

➡ oat.group_level (GLM subject-wise analysis)

Page 36: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Some oat.first_level settings

• oat.first_level.bc specifies whether BC should be done for each contrast

➡ BC is computed on the COPE time course

➡ no need to do BC on differential contrasts (e.g. [1 -1] contrast)

➡ recommended to do BC on main effect contrasts (e.g. [1 0] contrast)

• baseline correction (BC), subtracts mean COPE in baseline time window (e.g. t<0s)

baseline

Page 37: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Some oat.first_level settings• Set time range and freq range using:

• oat.first_level.time_range (for TF analyses need to make this time range is smaller than oat.source_recon.time_range to remove edge effects)

• oat.first_level.tf_freq_range

!

Page 38: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Some oat.first_level settings

!

• To do an ERF analysis set oat.first_level.tf_method=‘none’

• To do a Hilbert Time-Frequency (TF) analysis set oat.first_level.tf_method=‘hilbert’

• To do a Morlet Wavelet Time-Frequency (TF) analysis set oat.first_level.tf_method=‘morlet’

• For TF analyses set the number of frequency bins using oat.first_level.tf_num_freqs=10

!

• Set time range and freq range using:

• oat.first_level.time_range (for TF analyses need to make this time range is smaller than oat.source_recon.time_range to remove edge effects)

• oat.first_level.tf_freq_range

!

Page 39: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Running OAT

• Use osl_run_oat to run an OAT:

➡ oat=osl_run_oat(oat);

• This runs the stages specified in oat.to_do, e.g.:

➡ oat.to_do=[1 1 0 0]; only runs source_recon and first-level stages

Page 40: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

OAT output• Results are stored in the directory specified in

oat.source_recon.dirname, with a ‘.oat’ suffix

• This directory includes a *.mat file, can load this into Matlab with: oat=osl_load_oat(oat);

Page 41: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

OAT output

!

• This loads in a struct containing the settings used and the filenames of the outputs for each stage of the pipeline:

➡ oat.source_recon.results_fnames

➡ oat.first_level.results_fnames

➡ oat.subject_level.results_fnames

➡ oat.group_level.results_fnames

• These can be loaded into Matlab, e.g. to load session 2’s first level results use the call:

➡ res=osl_load_oat_results(oat, oat.first_level.results_fnames{2})

• Results are stored in the directory specified in oat.source_recon.dirname, with a ‘.oat’ suffix

• This directory includes a *.mat file, can load this into Matlab with: oat=osl_load_oat(oat);

Page 42: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Viewing OAT output

• It is highly recommended that you inspect oat.results.report (an HTML page), to ensure that OAT has run successfully (See the practical)

!

• In sensor space, use:

• Use osl_stats_multiplotER and osl_stats_multiplotTFR to call Fieldtrip interactive topoplots

• The two orientations of the MEGPLANARs are combined (in the first_level stage) by rectifying and adding

Page 43: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Practical

!1) Sensor space trial-wise GLM using OAT on epoched data:!

!a) Time-domain (ERF) analysis!!

b) Time-frequency (induced response) analysis!!2) Sensor space time-wise GLM using OAT on continuous data.!

!

Page 44: Using OSL: Sensor Space Analyses - OHBA Analysis Group · Fieldtrip FSL fastICA Neuromag Netlab Custom software OSL can be used for ... • Group-level (between-subject) subject-wise

Finally

!• If you end up using OSL for your own data

analysis then please get in touch with me!!

• Look at and use the OSL Wiki!!!

• https://sites.google.com/site/ohbaosl/!!

• sign up for OSL email list!!

!