Fieldtrip question from Piers C

Jan Mathijs Schoffelen Jan.Schoffelen at FCDONDERS.RU.NL
Mon Oct 9 08:31:58 CEST 2006

Dear Piers,

Since I am not a big wavelet-analysis expert, I forward this reply to the
fieldtrip-mailinglist. Recently there has been a thread concerning this type
of analysis. (To subscribe, please have a look at:, and follow the links to the
discussion list; there's a thread on freqanalysis_wltconvol)
I'd like to give you a global idea of what's going on with your analysis,
for the details I'd like to refer to Markus' and Brian's discussion.

The NaNs in your spectrogram are the consequence of your
configuration-settings, and your data length. Only at frequencies and
time-points where the wavelet-kernel completely covers your data, an
estimate is returned.
You could play around a bit with your cfg.width, and cfg.gwidth parameters
to change this.



-----Original Message-----
From: p.cornelissen at [mailto:p.cornelissen at]

Sent: Friday, October 06, 2006 12:23 PM
To: Jan Mathijs Schoffelen
Subject: RE: Fieldtrip question from Piers C

Dear Jan-Mathijs

Thanks for this advice. It turns out that there is an easy solution in the
form of a commandline programme called newDS (this is either a CTF thing,
or something written by the team at Aston) which allows one to incorporate
a virtual electrode dataset (defined by a SAM weights file) into a DS
file. Then, when reading into Fieldtrip, you have to include the 'V0' in
the line: 	= {'MEG' 'STIM' 'V0'};

However, I have a new question. I ran the following wavelet analysis on a
virtual electrode channel dataset:

cfg1 = [];
cfg1.output       = 'pow';
cfg1.sgn          = 'MEG';
cfg1.method       = 'wltconvol';      = 'V0';
cfg1.width        = 5;                     % Width of wavelet
cfg1.gwidth       = 5;
cfg1.foi          = 1:1:50;
cfg1.toi          = -0.2:0.01:0.7;

WVLT = freqanalysis(cfg1, raw);

Created a suingle plot as follows.

cfg2 = [];
cfg2.baseline     = [-0.2 0.0];
cfg2.baselinetype = 'relative';
%cfg2.baseline     = 'no';
%cfg2.baselinetype = 'absolute';
cfg2.zlim         = 'maxmin';
cfg2.xlim         = [-0.2 0.7];
cfg2.ylim         = [1 35];      = 'V0';
singleplotTFR(cfg2, WVLT);

 ... and obtained the result that is attached as a PNG file to this email.
It seems as if the plot has been thresholded/masked in a way to exclude
values that are (probably) poorly estimated - or something like that. So,
please can you advise what rules govern this exclusion/masking, and how
they can either be switched off, or the analysis/data collection carried
out in such a way that they are not invoked.

Thanks very much again


> Dear Piers,
> First of all, I took the liberty to include as a CC to this mail the
> FieldTrip discussion list. It might be that some of its members could
> positively contribute to answering your questions. You can subscribe to
> this
> list on the fieldtrip-website.
> Anyway, currently there is no support for reading in SAM weights files
> into
> fieldtrip. The most important reason for us not having implemented it, is
> that we do our source estimation in fieldtrip directly. Perhaps anyone
> already has an implementation to directly read in your SAM weights into
> matlab (hence the cc to the discussion list). As soon as those weights are
> available, it is pretty straightforward to create virtual channel data and
> do the subsequent analysis within fieldtrip.
> Otherwise a reading routine for SAM weights would be a valuable
> contribution
> to the code.
> Another approach would be to use fieldtrip's beamforming algorithm to
> create
> your virtual channels. The 'lcmv'-algorithm is not all too different from
> SAM, so you could try this on your specified voxels of interest.
> There is a tutorial on the frequency-domain beamformer on the web-site.
> The
> time-domain beamformer needs a slightly different configuration and
> input-data.
> 1 you should use timelockanalysis to compute the covariance of your
> bandpass-filtered data.
> 2 then you can call sourceanalysis, with the output of timelockanalysis as
> an input, in combination with a configuration-structure.
> Key-elements of this configuration would be:
> cfg.method = 'lcmv';
> cfg.pos    = Nx3 matrix with x,y,z coordinates of your virtual channels
> cfg.reducerank = 2; (necessary for comparability with SAM, and also to
> give
> reasonable results in the first place)
> cfg.hdmfile = .hdm file specifying the forward model used
> ...and I guess some other stuff as well.
> Yours,
> Jan-Mathijs
> -----Original Message-----
> From: p.cornelissen at
> [mailto:p.cornelissen at]
> Sent: Friday, September 15, 2006 2:54 PM
> To: Jan.Schoffelen at
> Subject: Fieldtrip ? from Piers C
> Dear Fieldtrip team,
> First - thanks for your excellent software!
> I hope its OK for me to ask you a Fieldtrip question.
> We have data from an experiment using Aston (UK) universitie's old 151
> channel CTF system, and we have used the CTF tools to extract a set of
> virtual electrodes, selected on the basis of a robust group SAM analysis.
> What we would really like to do is to use our SAM weights files for these
> virtual electrodes, to define specific channels in Fieldtrip so that we
> can create and compare time*frequency plots from the virtual electrodes in
> Fieldtrip.
> Any advice on how to do this (preferably by way of example code)would be
> deeply appreciated
> Regards
> Piers Cornelissen

More information about the fieldtrip mailing list