single-trials data

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Wed Nov 10 18:38:16 CET 2004


Hi Sreenivasan

On 9 Nov 2004, at 21:32, R. Sreenivasan wrote:

> Hi Robert,
>
> Attached is the script that I used for generating single-trial time
> series
> data for two dipoles. Then I want to do the freqanalysis on those
> source
> time-series data.
> Unfortunately, I amn't getting it ...Would you please check?
>

> cfg.vartrllength       = 2;
This has no effect, since you are not doing partial artifact rejection.
Hence all your trials have the same length.

> cfg.blc                = 'no'
> cfg.blcwindow          = [-0.0 0.25]
This has no effect.

> cfg.bpfreq            = [8 14]
> fg.bpfiltord          = 4
> cfg.bpfilttype        = 'fir'
This will result in a very sloppy filter.

> cfg = [];
> cfg.method   = 'lcmv';
> cfg.grid.pos = [1 4 1; 6 1 2];
> %cfg.singletrial = 'yes';
> cfg.rawtrial    = 'yes'
> cfg.keepfilter    = 'yes'
> cfg.hdmfile = strcat(ds, '/localSpheres.hdm');
> [source] = sourceanalysis(cfg, timelock)
Your single trial covariances are computed on only a 250ms time window
of the filtered data (see timelockanalysis cfg). Therefore each single
trial covariance is very poorly estimated and might even be rank
deficient (this is something that sourceanalysis will warn you about).
You should do singletrial=yes and rawtrial=no. Just to be sure you
should also do keepmom=yes.

> cfg = [];
> cfg.method = 'fft';
> cfg.output = 'powandcsd';
> cfg.tapsmofrq = smo;
> cfg.foilim = [f1 f2];
> %cfg.pad = 2.;
> %cfg.keeptrials = 'yes';
> cfg.sgncmb = 'all';
> [freq] = freqanalysis(cfg, source);
Freqanalysis is not so smart that it immediately knows how to do its
analysis on source data. You'll have to reformat the source data, and
especially source.trial.mom (i.e. the estimated dipole moment for each
trial) into something that looks like it comes from preprocessing.

datasrc = [];
datasrc.fsample = data.fsample;
datasrc.cfg     = source.cfg;
for i=1:length(datasrc.time)
   datasrc.time{i}  = timelock.time;
   datasrc.trial{i} = xxx; % something with source.trial(i).mom{1} and
mom{2};
end
datasrc.label = xxx; % perhaps {'dip1', 'dip2'}?

You'll have to fill out the xxx'es youself and especially you should
tink of how you want to treat the 3D dipole moment (i.e. regional
source strength with x, y, and z-component), i.e. as three virtual
channels or as one virtual channel. Maybe it is first better to have a
look at the moments of each dipole in a given trial by just plotting
it. Using SVD, you can for example extract the moment strength and
orientation along the most dominant direction. Try something like

[u, s, v] = svd(source.trial(1).mom{1});
mom = s*v;
plot(time, mom);

I hope this helps,
Robert

PS plotting virtual channels with sourceinterpolate and
sliceinterpolate won't work, but you already have that commented out.



More information about the fieldtrip mailing list