Error during regression Analysis of EEG data

I have been trying to run the regression analysis of EEG data and for the regressand(dependant variable) t-test, I tried running the below loop but I keep running into error. Can someone identify where I'm going wrong, please?
for ichan = 1:size(freqres.powspctrm,1)
for ifrq = 1:size(freqres.powspctrm,4)
cfg = [];
cfg.previous = freqres.cfg;
cfg.channel = freqres.label;
cfg.frequency = [2 40];
cfg.method = 'analytic';
cfg.statistic = 'depsamplesT';
cfg.alpha = 0.05;
cfg.tail = 1;
cfg.correctm = 'no';
Nsub = 11;
cfg.design(1,1:2*Nsub) = [ones(1,Nsub) 2*ones(1,Nsub)];
cfg.design(2,1:2*Nsub) = [1:Nsub 1:Nsub];
cfg.ivar = 1; % the 1st row in cfg.design contains the independent variable
cfg.uvar = 2; % the 2nd row in cfg.design contains the subject number
stat = ft_timelockstatistics(cfg,ichan{:}, ifrq{:});
end
end

2 commentaires

Geoff Hayes
Geoff Hayes le 13 Jan 2016
Maazah - what is the error that you are observing? Please describe it and include the full error message. If the behaviour is unexpected, then describe the desired behaviour.
Maazah Ali
Maazah Ali le 13 Jan 2016
Modifié(e) : Geoff Hayes le 14 Jan 2016
Hi Geoff, I am trying to run a regression analysis on EEG data. I have used search preference as the predictor and data as the regressand. This is the code I'm using:
predictor = searchpref'
predictor = predictor(:);
ichan = 117;
data =(ichan, ifrq);
for ichan = 1:size(freqres.powspctrm,2)
for ifrq = 1:size(freqres.powspctrm,4)
cfg = [];
cfg.previous = freqres.cfg;
cfg.channel = freqres.label;
cfg.frequency = [2 40];
cfg.method = 'analytic';
cfg.statistic = 'depsamplesT';
cfg.alpha = 0.05;
cfg.tail = 1;
cfg.correctm = 'no';
% Nsub = 11;
% cfg.design(1,1:2*Nsub) = [ones(1,Nsub) 2*ones(1,Nsub)];
% cfg.design(2,1:2*Nsub) = [1:Nsub 1:Nsub];
% cfg.ivar = 1;
% cfg.uvar = 2;
%
end
end
stat = ft_timelockstatistics(cfg,searchpref, data);
However, MATLAB seems to give an error for the last line and won't run the regression t-test.
Error in Regression_searchpreference (line 70)
stat = ft_timelockstatistics(cfg,predictor,data)
If you could identify the problem, I would be very grateful. Many thanks.

Connectez-vous pour commenter.

Réponses (1)

That appears to be a reference to the third party FieldTrip Toolbox
Your for loops on ichan and ifrq are over integers, 1 to the size of something. But your call has
stat = ft_timelockstatistics(cfg,ichan{:}, ifrq{:});
the {:} is only valid for cell arrays, but you are using {:} on those integers.
Your size are over freqres.powspctrm which must be at least 4 dimensional, so it is not obvious to me what you would be trying to index as a cell array. Maybe
stat = ft_timelockstatistics(cfg, freqres.powspctrm{ichan, :, :, ifrq})

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by