Group analyses with FieldTrip

Post on 24-Jan-2017

273 views 4 download

transcript

From raw MEG to publication: how to perform group analysis with FieldTrip

Robert OostenveldDonders Institute, Radboud University, Nijmegen, NLNatMEG, Karolinska Institute, Stockholm, SE

Presentation outline

FieldTrip background

Strategy for making analysis pipelines

Single subject pipelineHighlight: Reading and converting filesHighlight: Anatomical coregistration

Group analysis pipeline

M/EEG signal characteristics considered during analysis

timecourse of activity -> ERP

spectral characteristics -> power spectrum or TFR

spatial distribution of activity over the head -> source reconstruction

interaction between regions in the brain-> source reconstruction and connectivity

Channels show a superposition of the source activity

Some analyses can be done at the channel levelSome should be done at the source level

analyses

interpretations or hypotheses

require

FieldTrip basics

dataout = functionname(cfg, datain, …)

functionname(cfg, datain, …)

dataout = functionname(cfg)

the “cfg” argument is a configuration structure, e.g.

cfg.channel = {‘C3’, C4’, ‘F3’, ‘F4’} cfg.foilim = [1 70]

Using functions in an analysis protocol

ft_preprocessing

ft_rejectartifact

ft_freqanalysis

ft_multiplotTFR ft_freqstatistics

ft_multiplotTFR

cfg = [ ]cfg.dataset = ‘Subject01.ds’cfg.bpfilter = [0.01 150]...rawdata = ft_preprocessing(cfg)

Using functions in an analysis protocol

ft_preprocessing

ft_rejectartifact

ft_freqanalysis

ft_multiplotTFR ft_freqstatistics

ft_multiplotTFR

cfg = [ ]cfg.method = ‘mtmfft’cfg.foilim = [1 120]...freqdata = ft_freqanalysis(cfg, rawdata)

Event related response

timelockData = avg: [151x900 double] var: [151x900 double] label: {151x1 cell} time: [1x900 double] dimord: 'chan_time’ cfg: [1x1 struct]

Example use in scripts

cfg = []cfg.dataset = ‘Subject01.ds’cfg.bpfilter = [0.01 150]...rawdata = ft_preprocessing(cfg)

cfg = []cfg.method = ‘mtmfft’cfg.foilim = [1 120]...freqdata = ft_freqanalysis(cfg, rawdata)

cfg = []cfg.method = ‘montecarlo’cfg.statistic = ‘indepsamplesT’cfg.design = [1 2 1 2 2 1 2 1 1 2 ... ]...freqstat = ft_freqstatistics(cfg, freqdata)

ft_preprocessing

ft_freqanalysis

ft_freqstatistics

ft_topoplotTFR

Example use in scripts

cfg = []cfg.dataset = ‘Subject01.ds’cfg.bpfilter = [0.01 150]...rawdata = ft_preprocessing(cfg)

cfg = []cfg.method = ‘mtmfft’cfg.foilim = [1 120]...freqdata = ft_freqanalysis(cfg, rawdata)

cfg = []cfg.method = ‘montecarlo’cfg.statistic = ‘indepsamplesT’cfg.design = [1 2 1 2 2 1 2 1 1 2 ... ]...freqstat = ft_freqstatistics(cfg, freqdata)

ft_preprocessing

ft_freqanalysis

ft_freqstatistics

ft_topoplotTFR

Example use in scripts

cfg = []cfg.dataset = ‘Subject01.ds’cfg.bpfilter = [0.01 150]...rawdata = ft_preprocessing(cfg)

cfg = []cfg.method = ‘mtmfft’cfg.foilim = [1 120]...freqdata = ft_freqanalysis(cfg, rawdata)

cfg = []cfg.method = ‘montecarlo’cfg.statistic = ‘indepsamplesT’cfg.design = [1 2 1 2 2 1 2 1 1 2 ... ]...freqstat = ft_freqstatistics(cfg, freqdata)

ft_preprocessing

ft_freqanalysis

ft_freqstatistics

ft_topoplotTFR

Example use in scripts

cfg = []cfg.dataset = ‘Subject01.ds’cfg.bpfilter = [0.01 150]...rawdata = ft_preprocessing(cfg)

cfg = []cfg.method = ‘mtmfft’cfg.foilim = [1 120]...freqdata = ft_freqanalysis(cfg, rawdata)

cfg = []cfg.method = ‘montecarlo’cfg.statistic = ‘indepsamplesT’cfg.design = [1 2 1 2 2 1 2 1 1 2 ... ]...freqstat = ft_freqstatistics(cfg, freqdata)

ft_preprocessing

ft_freqanalysis

ft_freqstatistics

ft_topoplotTFR

Example use in scripts

cfg = []cfg.dataset = ‘Subject01.ds’cfg.bpfilter = [0.01 150]...rawdata = ft_preprocessing(cfg)

cfg = []cfg.method = ‘mtmfft’cfg.foilim = [1 120]...freqdata = ft_freqanalysis(cfg, rawdata)

cfg = []cfg.method = ‘montecarlo’cfg.statistic = ‘indepsamplesT’cfg.design = [1 2 1 2 2 1 2 1 1 2 ... ]...freqstat = ft_freqstatistics(cfg, freqdata)

ft_preprocessing

ft_freqanalysis

ft_freqstatistics

ft_topoplotTFR

Example use in scripts

subj = {‘S01.ds’, ‘S02.ds’, …}trig = [1 3 7 9]

for s=1:nsubjfor c=1:ncond

cfg = [] cfg.dataset = subj{s} cfg.trigger = trig(c) rawdata{s,c} = ft_preprocessing(cfg)

cfg = [] cfg.method = ‘mtmfft’ cfg.foilim = [1 120] freqdata{s,c} = ft_freqanalysis(cfg, rawdata{s,c})

endend

Example use in scripts

subj = {‘S01.ds’, ‘S02.ds’, …}trig = [1 3 7 9]

for s=1:nsubjfor c=1:ncond

cfg = [] cfg.dataset = subj{s} cfg.trigger = trig(c) rawdata = ft_preprocessing(cfg)

filename = sprintf(‘raw%s_%d.mat’, subj{s}, trig(c)); save(filename, ‘rawdata’)

endend

Example use in scripts

subj = {‘S01.ds’, ‘S02.ds’, …}trig = [1 3 7 9]

for s=1:nsubjfor c=1:ncond

cfg = [] cfg.dataset = subj{s} cfg.trigger = trig(c) cfg.outputfile = sprintf(‘raw%s_%d.mat’, subj{s}, trig(c)); rawdata = ft_preprocessing(cfg)

endend

Example use in distributed computing

subj = {‘S01.ds’, ‘S02.ds’, …}trig = [1 3 7 9]

for s=1:nsubjfor c=1:ncond

cfgA{s,c} = [] cfgA{s,c}.dataset = subj{s} cfgA{s,c}.trigger = trig(c) cfgA{s,c}.outputfile = sprintf(‘raw%s_%d.mat’, subj{s}, trig(c))

cfgB{s,c} = [] cfgB{s,c}.dataset = subj{s} cfgB{s,c}.trigger = trig(c) cfgB{s,c}.inputfile = sprintf(‘raw%s_%d.mat’, subj{s}, trig(c)); cfgB{s,c}.outputfile = sprintf(‘freq%s_%d.mat’, subj{s}, trig(c));

endend

dfeval(@ft_preprocessing, cfgA)dfeval(@ft_freqanalysis, cfgB)

MATLAB distributed computing

Example use in distributed computing

subj = {‘S01.ds’, ‘S02.ds’, …}trig = [1 3 7 9]

for s=1:nsubjfor c=1:ncond

cfgA{s,c} = [] cfgA{s,c}.dataset = subj{s} cfgA{s,c}.trigger = trig(c) cfgA{s,c}.outputfile = sprintf(‘raw%s_%d.mat’, subj{s}, trig(c))

cfgB{s,c} = [] cfgB{s,c}.dataset = subj{s} cfgB{s,c}.trigger = trig(c) cfgB{s,c}.inputfile = sprintf(‘raw%s_%d.mat’, subj{s}, trig(c)); cfgB{s,c}.outputfile = sprintf(‘freq%s_%d.mat’, subj{s}, trig(c));

endend

qsubcellfun(@ft_preprocessing, cfgA)qsubcellfun(@ft_freqanalysis, cfgB)

FieldTrip distributed computing

FieldTrip is a toolbox

the data and the separate functions are all in your hands

you write a script or set of scripts that represents the analysis pipeline

scripts correspond to analysis protocolsscripts can be reviewed by supervisorsscripts are often reused and shared with colleaguesscripts can be published/released

File importing with FieldTriphighlight 1

FieldTrip private functions(low-level)

FieldTrip main functions

end-user perspective

FieldTrip toolbox structure - at a glance

FieldTrip toolbox structure - a closer look

fileio forward preproc private

FieldTrip main functions

end-user perspective

utilities

externalEEGLAB

externalSPMpreproc

FieldTrip toolbox structure - a closer look

fileio forward private

end-user perspective

ft_read_data(…) ft_compute_leadfield(…)ft_preproc_bandpassfilter(…)

utilitiesFieldTrip main functions

SPM under the hood

preprocfileio forward

end-user perspective

ft_read_data(…) ft_compute_leadfield(…)ft_preproc_bandpassfilter(…)

fieldtrip

SPM

… private

EEGLAB under the hood

fileio forward

end-user perspective

ft_read_data(…) ft_compute_leadfield(…)

fieldtrip

EEGLAB

… private

The fileio (input/output) mini toolbox

In FieldTrip primarily ft_definetrial(cfg)ft_preprocessing(cfg)ft_read_mri

Provides a consistent interface (API) to datasets from 7 MEG systems and >30 EEG systems

ft_read_event

ft_read_header

ft_read_data

ft_read_xxx(filename, …)

highlight 2

Coregistration between MEG/EEG and anatomy

1) anatomical landmarks (lpa, rpa, nas)2) HPI/HCL coil locations3) scalp surface points

Lab specific conventions for landmarks and markers

Landmarks: anatomically recognizeable points on a head

Markers (or fiducials): points that are visible in multiple modalities, e.g. HPI coils or vitamin E capsules

Sharing anonymous imaging data

Facial details have been removed, e.g. using ft_defacevolume or ft_defacemesh.

Nasion is missing, the outline of the nose is missing, sometimes also the ears.

Coregistration

1. Redo the coregistration using limited data2. Trust the coregistration that was provided

FieldTrip BrainStorm

Presentation outline

FieldTrip background

Strategy for making analysis pipelines

Single subject pipelineHighlight: Reading and converting filesHighlight: Anatomical coregistration

Group analysis pipeline

Making a group analysis pipeline

Start with version control> git init

Write the pipeline for a single subject> git commit

Manage subject differences> git commit

Run for all subjects> git commit

Do group analysis> git commit

Share your pipeline along with paper and data> git push

Wrap up and topics for discussion

Managing and sharing pipelines- version control, provenance, consistency,

reproducibility

Preventing “data dredging”, “double dipping” and biassed analyses

Sharing data for (re)analysis- BIDS: Brain Imaging Data Structure now also for

MEG (see poster Mo-P012)- Provide sufficient detail, but not all

http://datacolada.orghttps://aspredicted.org