electrode load and clusterrandanalysis

Michael Wibral wibral at BIC.UNI-FRANKFURT.DE
Thu May 14 19:13:43 CEST 2009


Hi Charles,
if your code literally contains: 

load ('elec');

that will not work, for sure. The reason is, that you are trying to read a file (via MATLAB's load command) named "elec" in the current directory, which almost certainly does not exist. 
Try something like:
elec = read_fcdc_elec('HGSN_129_NoFids.sfp');
and then add this as a field to the relevant data structures, like this

femfeat{i}.elec=elec
...
...

This way you'll be doing an electrode name based averaging over subjects. 
It may be better - since you have all the individual digitized electrode positions as .sfp files (do you?) - to export everything into a virtual BESA standard montage (81 ch in average reference is the most popular option) and then to fieldtrip, as this will take into account the different electrode positions in the different subjects (but we can leave that for later, let's first get the above running :-)...).

Michael







> -----Ursprüngliche Nachricht-----
> Von: "Charles Cook" <charles.cook at ULETH.CA>
> Gesendet: 14.05.09 15:42:41
> An: FIELDTRIP at NIC.SURFNET.NL
> Betreff: Re: [FIELDTRIP] electrode load and clusterrandanalysis


> 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.femfeat{i}
> 
> 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';read_fcdc_elec('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.
> 



----------------------------------
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 --------------
A non-text attachment was scrubbed...
Name: Michael Wibral.vcf
Type: text/x-vcard
Size: 344 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20090514/c1fa004a/attachment-0002.vcf>


More information about the fieldtrip mailing list