data conversion

Thomas Thesen tnt at PHYSIOL.OX.AC.UK
Wed May 25 10:52:59 CEST 2005


Hi.

I have 3-D spectrograms (time x frequency x amplitude) for different
conditions and multiple subjects which were generated outside FieldTrip. I
would like to compare them statistically using the paired t-test in
CLUSTERRANDANALYS with correction for multiple comparisons. I have attempted
to transfer these data into a format which FieldTrip should be able to read.
However, it doesn't seem to work correctly.
Below are the steps I have made during the transformation including a link
to the files that were used or were generated in the process.

Examples of the input and output data of various steps can be found here:
http://www.physiol.ox.ac.uk/~tnt/specs/


Step 1:
(converting data structure of individual subjects into FieldTrip format, one
.mat file per condition per subject)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subj = {
'C1_A1/Average_L_A1_sub01_a_C1_A1'  %  example:
'input_example_Step1_Average_L_A1_sub12_a_C1_A1.mat' on the web
'C1_A1/Average_L_A1_sub02_a_C1_A1'
'C1_A1/Average_L_A1_sub04_a_C1_A1'
'C1_A1/Average_L_A1_sub05_a_C1_A1'
'C1_A1/Average_L_A1_sub07_a_C1_A1'
'C1_A1/Average_L_A1_sub07_b_C1_A1'
'C1_A1/Average_L_A1_sub09_a_C1_A1'
'C1_A1/Average_L_A1_sub10_a_C1_A1'
'C1_A1/Average_L_A1_sub10_b_C1_A1'
'C1_A1/Average_L_A1_sub11_a_C1_A1'
'C1_A1/Average_L_A1_sub11_b_C1_A1'
'C1_A1/Average_L_A1_sub12_a_C1_A1'
'C1_A1/Average_L_A1_sub12_b_C1_A1';
};
load fieldtrip_example1    % load template of data structure used by
FieldTrip (example: 'fieldtrip_example1.mat' on the web )

Nsubj = 13;
for i=1:Nsubj
       dataset =
['/home/magnum/tnt/data/meg/analysis/McGurk/MEG_for_SAM/Spectrograms/'
subj{i} '.mat'];
    outputname =
['/home/magnum/tnt/data/meg/analysis/McGurk/MEG_for_SAM/fieldtrip_analysis/specs/'
subj{i} '.mat'];
 load (dataset);    % a sample dataset:
'input_example_Step1_Average_L_A1_sub12_a_C1_A1.mat' on the web
 tfr = oldtfr;
 %tfr.powspctrm = zeros(151, size(data.F,2), size(data.T,2));  % if htis
line is used, 151 channels are created
 tfr.powspctrm = zeros(1, size(data.F,2), size(data.T,2)); % if this line is
used 1 channel is created
 tfr.powspctrm(1,:,:) = data.specgr.data;                             % 3D
put spectogram data into channel 1 of FieldTrip structure
   tfr.foi = data.F;       % frequency information for y-axis
 tfr.toi= data.T;       % time information for x-axis
 save (outputname, 'tfr');
end
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This produces 'output_example_Step1_sub12_a_C1_A1.mat' on the web.

In the next step I tried to convert all spectrograms from individual
subjects into one data structure carrying the data for all subjects within
one structure (this was done separately for two conditions):


Step 2:
(moving all subject data into a group structure, one for each condition)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

load fieldtrip_example1.mat;    % example: 'fieldtrip_example1.mat' on the web
group = oldtfr;
group.sgn = oldtfr.label;
group.powspctrm = [];

files = dir('Average_L_A1_sub*mat'); % all the files created in step 1
above,  e.g. 'output_example_Step1_sub12_a_C1_A1.mat'

for i = 1:length(files)
    load (files(i).name);
    group.powspctrm(i,:,:,:) = tfr.powspctrm; % load subject data
end
group.toi=tfr.toi;
group.foi=tfr.foi;
group.dimord =  'rpt_sgn_frq_tim';
save ('group_Spec_L_A1.mat', 'group')
%%%%%%%%%%%%%%%%%%%%%%%%%%

creates 'output_Step2_group_Spec_L_A1.mat' on the web.

When a matrix with 151 channels is created in step 1 by:
tfr.powspctrm = zeros(151, size(data.F,2), size(data.T,2)

 the files become too large for the machine to handle at the group level
(~500Mb each x 13 sets).

Therefore, I proceed to the next step with a matrix of one channel
tfr.powspctrm = zeros(1, size(data.F,2), size(data.T,2));



Step 3:
(comparing two conditions from 13 subjects)
%%%%%%%%%%%%%%%%%%%%%%%%%
cfg = [];
cfg.statistic = 'depsamplesT';
cfg.alphathresh = 0.05;
cfg.makeclusters = 'yes';
cfg.minnbchan = 2;
cfg.clusterteststat = 'maxsum';
cfg.onetwo = 'twosided';
cfg.alpha = 0.05;
cfg.nranddraws = 100;
cfg.channel = {'MEG'};
cfg.latency = [0 1];

[clusrand] = clusterrandanalysis (cfg, group_A, group_B);

%%%%%%%%%%%%%%%%%%%%%%%%%%

Then the following error message appears:

>> [clusrand] = clusterrandanalysis (cfg, group_C1, group_C4);
Selecting and formatting the data.
selected 151 channels
selected 626 time bins
selected 159 frequency bins
??? Index exceeds matrix dimensions.

Error in ==>
/home/magnum/tnt//Fieldtrip/fieldtrip-20050522/private/prepare_timefreq_data.m
On line 360  ==>       dat{c} = avgoverdim(varargin{c}.dat(:, chansel,
freqsel, timesel), avgdim);

Error in ==>
/home/magnum/tnt//Fieldtrip/fieldtrip-20050522/clusterrandanalysis.m
On line 267  ==> [cfg,data]=prepare_timefreq_data(cfg,
varargin{1:Nvarargin});
 >>

%%%%%%%%%%%%%%


Thanks a lot in advance for your help.

Thomas



More information about the fieldtrip mailing list