data conversion

Thomas Thesen tnt at PHYSIOL.OX.AC.UK
Wed May 25 11:18:05 CEST 2005


Dear Robert,

Thank you for your comment.
When running CLUSTERRANDANALYSIS I have the following data structures that
feed into the statistical analysis:

group_C1 =

        label: {151x1 cell}
       dimord: 'rpt_sgn_frq_tim'
    powspctrm: [4-D double]
          foi: [1x159 double]
          toi: [1x2187 double]
          cfg: [1x1 struct]
         grad: [1x1 struct]
          sgn: {151x1 cell}


As you said "group_C4.sgn" and "group_C4.label" indicate 151 channels,
whereas the data in fact has only 1. I've tried the following:

group_C4.sgn = ['spec']
group_C4.label = ['spec']


    and

group_C4.sgn={'spec'}
group_C4.label={'spec'}

but no success. Do you have any suggestion?

Thanks a lot,
Thomas



On Wed, 25 May 2005 10:54:08 +0200, Thomas Thesen <tnt at PHYSIOL.OX.AC.UK> wrote:

>Hi Thomas
>
>
>I did not look in full detail at the mail, but just browsed over it and
>noticed something that may be the cause: It states "selected 151
>channels", but you mentioned that you have only one channel. In
>selecting a single channel to reduce the amount of data, did you also
>make the corresponding change in freq.label?
>
>
>Robert
>
>On Wed, 25 May 2005 10:52:59 +0200, Thomas Thesen <tnt at PHYSIOL.OX.AC.UK> wrote:
>
>>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