electrode load and clusterrandanalysis

Charles Cook charles.cook at ULETH.CA
Thu May 14 15:41:21 CEST 2009


Hi Michael,

Here's the basics of the code. As I mentioned I modified the code from Peter
Praamstra's data where the TF power was computed in BESA. The full analysis
will have both between group (males vs. females) and within group (location
vs. feature identity) aspects. At this point in the code, I'm just trying to
get the between group analysis going on one of the tasks. I'm not certain
what precise version I'm with, I believe it's from fall 2008.

For brevity, I've not included the BESA datafile lists for my different
conditions. 

------------------------------------------------------------------

% collect all single subject data in a convenient cell-array
for i=1:nsubj
  femfeat{i} = besa2fieldtrip(filename_femfeat{i});
  femloc{i} = besa2fieldtrip(filename_femloc{i});
  malefeat{i} = besa2fieldtrip(filename_malefeat{i});
  maleloc{i} = besa2fieldtrip(filename_maleloc{i});
end
 
% this is needed for the channel labels in the data from Peter Praamstra
% Matlab is case sensitive and so the channel and electrode names should match 

for i=1:nsubj
  for j=1:length(maleloc{i}.label)
    if maleloc{i}.label{j}(end)=='H'
      maleloc{i}.label{j}(end)='h';
    end
  end
  for j=1:length(femloc{i}.label)
    if femloc{i}.label{j}(end)=='H'
      femloc{i}.label{j}(end)='h';
    end
  end



% load a set of electrodes (these are on a unit sphere)  
% note, this will be different for your own data
load ('elec'); <------------------------------------------where it breaks down
%scale the electrodes to a realistic head size (in cm)
elec.pnt = 10*elec.pnt;
 
%prepare layout
read_fcdc_elec('HGSN_129_NoFids.sfp');
cfg = [];
cfg.rotate = 0;
cfg.elecfile = 'HGSN_129_NoFids.sfp';
mylay = prepare_layout(cfg);
%cfg.layout = 'HGSN_129_NoFids.sfp';
%mylay = prepare_layout(cfg);
 
% compute the grand average for both conditions
cfg = [];
cfg.keepindividuals = 'yes';
femfeat_avg = freqgrandaverage(cfg, femfeat{:});
femloc_avg = freqgrandaverage(cfg, femloc{:});
malefeat_avg = freqgrandaverage(cfg, malefeat{:});
maleloc_avg = freqgrandaverage(cfg, maleloc{:});

% Create difference waves
% Female Location and feature
fem_diff_feat_loc = femfeat_avg; %creates a dummy array
male_diff_loc_feat = maleloc_avg;
male_diff_loc_feat.powspctrm = maleloc_avg.powspctrm - femloc_avg.powspctrm;
fem_diff_feat_loc.powspctrm = femfeat_avg.powspctrm - malefeat_avg.powspctrm;

cfg = [];
cfg.layout = mylay;
cfg.showlabels = 'yes';

% recompute the average, except do _not_ average but keepindividual
% this collects all identical time/frequency/channel samples over all
% subjects into a single data structure
cfg = [];
cfg.keepindividual = 'yes';
maleloc_all = freqgrandaverage(cfg, maleloc{:});
femloc_all = freqgrandaverage(cfg, femloc{:});

%
% perform the statistical test using randomization and a clustering approach
% using the OLD clusterrandanalysis function
cfg = [];
cfg.elecfile    = mylay;
%cfg.geomfile   = mylay;
cfg.neighbourdist = 4;
cfg.latency     = 'all';
cfg.frequency   = 'all';
cfg.channel     = 'all'; % see CHANNELSELECTION
cfg.avgovertime = 'no';
cfg.avgoverfreq = 'no';
cfg.avgoverchan = 'no';
cfg.statistic   = 'indepsamplesT';
cfg.nranddraws  = 200;
stat = clusterrandanalysis (cfg.elecfile, maleloc_all, femloc_all);
 

% perform the statistical test using randomization and a clustering approach
% using the NEW freqstatistics function
cfg = [];
cfg.elecfile         = mylay;
cfg.neighbourdist    = 4;
cfg.latency          = 'all';
cfg.frequency        = 'all';
cfg.channel          = 'all'; % see CHANNELSELECTION
cfg.avgovertime      = 'no';
cfg.avgoverfreq      = 'no';
cfg.avgoverchan      = 'no';
cfg.statistic        = 'indepsamplesT';
cfg.numrandomization = 200;
cfg.correctm         = 'cluster';
cfg.method           = 'montecarlo';
cfg.design           = [
  1 2 3 4 5 6 7 8 9 10 11 1 2 3 4 5 6 7 8 9 10 11     % subject number
  1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2];  % condition number
cfg.uvar = 1;                                   % "subject" is unit of
observation
cfg.ivar = 2;                                   % "condition" is the
independent variable
stat = freqstatistics(cfg, maleloc_avg, femloc_avg);
-----------------------------------------------------------------------
The error I get is as follows:

??? Error using ==> load
Unable to read file elec: No such file or directory.

Error in ==> CMCWM2_clust at 108
load ('elec');

Any help would be greatly appreciated. 

Cheers,

Charles

----------------------------------
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.



More information about the fieldtrip mailing list