# Source analysis on timelockdata

Tue Dec 22 17:00:56 CET 2009

```Hi everyone,

I got a problem with performing source analysis (minimum norm estimate) on
timelockdata, and I would be very glad if anyone could help me out!
So far, I've done the following steps (using fieldtrip version 20091221):

1) Compute timelockanalysis with cfg.latency = [0.05 0.4] and baseline
correction for condition 1 and 2
2) Source analysis with cfg. method = 'mne' on the timelock data, using
inverse grids
In the output from the source analysis I have avg.pow = 4560x211 for each
subject (211 = number of time samples)

The problem is that I can't compute sourcegrandaverage (see code below) on
these data (error at sourcegrandaverage at 178, dat(:,i) = tmp(:));
I already tried to put the single datasets directly into sourcestatistics,
but this doesn't work either (error: "the function requires source or volume
data as input")

I guess the problem is caused by the time dimension in the timelock data -
does anyone have an idea how to handle this information in source analysis /
source grandaverage / source statistics?

Best
Christine

%-------------------------------------------------
% Code for Source Statistics

datapath =
'/data/home1/ctillman/data/MooneyMEEGFieldtripAnalysis/ERF/Pilot/MNE/';

DataFaceFiles = {
};

DataInvertedFiles = {

};

template =
Nx = length(template.template_grid.xgrid);
Ny = length(template.template_grid.ygrid);
Nz = length(template.template_grid.zgrid);
%--------------------------------------------------------------------------

for i = 1:length(DataFaceFiles)
fullname1 = strcat(datapath,DataFaceFiles{i,1});
end

for i = 1:length(DataInvertedFiles)
fullname2 = strcat(datapath,DataInvertedFiles{i,1});
end

%--------------------------------------------------------------------------
% Fixing the structure properties
% Absolute power difference
for l = 1:length(DataFaceFiles)

DataFace{l}.DataERFOut.xgrid = template.template_grid.xgrid;
DataFace{l}.DataERFOut.ygrid = template.template_grid.ygrid;
DataFace{l}.DataERFOut.zgrid = template.template_grid.zgrid;
DataFace{l}.DataERFOut.dim = [Nx Ny Nz];
DataFace{l}.DataERFOut.pos = template.template_grid.pos;
DataFace{l}.DataERFOut.inside = template.template_grid.inside;
DataFace{l}.DataERFOut.outside = template.template_grid.outside;
DataFace{l} = DataFace{l}.DataERFOut;

end

for l = 1:length(DataInvertedFiles)

DataInverted{l}.DataERFOut.xgrid = template.template_grid.xgrid;
DataInverted{l}.DataERFOut.ygrid = template.template_grid.ygrid;
DataInverted{l}.DataERFOut.zgrid = template.template_grid.zgrid;
DataInverted{l}.DataERFOut.dim = [Nx Ny Nz];
DataInverted{l}.DataERFOut.pos = template.template_grid.pos;
DataInverted{l}.DataERFOut.inside = template.template_grid.inside;
DataInverted{l}.DataERFOut.outside = template.template_grid.outside;
DataInverted{l} = DataInverted{l}.DataERFOut;

end

% Compute grand average for Condition 1 and 2
cfgGA = [];
cfgGA.keepindividual = 'yes';
% cfg.parameter = 'pow';
% create command strings for the computation:
commandstr1 = strcat ('DataGAFace', '= sourcegrandaverage(cfgGA');
commandstr2 = strcat ('DataGAInverted',  '= sourcegrandaverage(cfgGA');

for l = 1 : length(DataFace)
commandstr1 = strcat(commandstr1, ',DataFace{', num2str(l) , '}');
end
% finalize command strings
commandstr1 = strcat(commandstr1,');');

for l = 1 : length(DataInverted)
commandstr2 = strcat(commandstr2, ',DataInverted{', num2str(l) , '}');
end
% finalize command strings
commandstr2=strcat(commandstr2,');');

cfg = [];
cfg.dimord = 'voxel';
cfg.dim = [15 19 16];
nSubjects = length(DataFaceFiles);
a = [1:nSubjects];
b = ones(1,nSubjects);
cfg.design = [a a; b (2*b)];
cfg.uvar = 1; % "subject" is unit of observation
cfg.ivar = 2; % row
cfg.method = 'montecarlo';
cfg.correctm = 'fdr';
cfg.alpha = 0.05;
cfg.numrandomization = 6000;
cfg.parameter = 'pow';
cfg.statistic = 'depsamplesT';

sourceStat = sourcestatistics(cfg, DataGAFace, DataGAInverted);

--
Christine Grützner, geb.Tillmann
Max-Planck-Institut für Hirnforschung
Abt. Neurophysiologie
Deutschordenstr. 46
60528 Frankfurt am Main
Germany

Phone: +49 (0)69/6301-83225
E-Mail: tillmann at mpih-frankfurt.mpg.de
http://www.mpih-frankfurt.mpg.de/global/Np/Staff/tillmann.htm

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20091222/2bc0814f/attachment-0001.html>
```