another help request for *.tfc files

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Mon May 7 22:04:51 CEST 2007

Hi Andrew,

On 19 Apr 2007, at 0:28, Andrew Smart wrote:
> In prepare_timefreq_data I changed:
> output.label  = input.label;
> to
> output.label  = input.labelcmb;
> To accomodate the labelcmb field in the fieldtrip structure. This
> gets me by
> the errors about the field 'label' not existing.

The input data selection in freqanalysis depends on
prepare_timefreq_data, but then that subfunction is not smart enough
to work with bivariate measures (i.e. coherence depends on channel
pairs and is bivariate, whereas power is univariate). I suggest that
you change the code in freqstatistics by the code below. That renames
both cohspctrm and labelcmb into something that the remainder of the
code should be able to support. subsequently the low-level code
should behave as if it is univariate data. Please let me know if it

best regards,


function [stat] = freqstatistics(cfg, varargin)

% here is the help

% the low-level data selection function does not know how to deal
with other parameters, so work around it
if isfield(cfg, 'parameter') && strcmp(cfg, 'powspctrm')
   % use the power spectrum, this is the default
elseif isfield(cfg, 'parameter') && strcmp(cfg, 'csdspctrm')
   % use the cross spectrum, this might work as well (but has not
been tested)
elseif isfield(cfg, 'parameter') && strcmp(cfg, 'cohspctrm')
   % for testing coherence on group level:
   % rename cohspctrm->powspctrm and labelcmb->label
   for i=1:length(varargin)
     dat         = varargin{i}.cohspctrm;
     labcmb      = varargin{i}.labelcmb;
     for j=1:size(labcmb)
       lab{j,1} = sprintf('%s - %s', labcmb{j,1}, labcmb{j,2});
     varargin{i} = rmsubfield(varargin{i}, 'cohspctrm');
     varargin{i} = rmsubfield(varargin{i}, 'labelcmb');
     varargin{i} = setsubfield(varargin{i}, 'powspctrm', dat);
     varargin{i} = setsubfield(varargin{i}, 'label',     lab);
   % rename the desired parameter to powspctrm
   fprintf('renaming parameter ''%s'' into ''powspctrm''\n',
   for i=1:length(varargin)
     dat         = getsubfield(varargin{i}, cfg.parameter);
     varargin{i} = rmsubfield (varargin{i}, cfg.parameter);
     varargin{i} = setsubfield(varargin{i}, 'powspctrm', dat);

% call the general function
[stat] = statistics_wrapper(cfg, varargin{:});

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 and

More information about the fieldtrip mailing list