[FieldTrip] Maxfilter and PCA

Seymour, Robert (Research Student) seymourr at aston.ac.uk
Mon Sep 19 15:09:45 CEST 2016


Hi Mike & others,

Instead of specifying a set number of components (e.g. 51) I tend to use data-driven approach that reduces my data to the number of components that describes 99% of the variance in my covar matrix. I do this like so:

covar = zeros(numel(data.label));
for itrial = 1:numel(data.trial)
    currtrial = data.trial{itrial};
    covar = covar + currtrial*currtrial.';
end
[V, D] = eig(covar);
D = sort(diag(D),'descend');
D = D ./ sum(D);
Dcum = cumsum(D);
numcomponent = find(Dcum>.99,1,'first') +1; % number of components accounting for 99% of variance in covar matrix
disp(sprintf('\n Reducing the data to %d components \n',numcomponent));
cfg = [];
cfg.method = 'pca';
cfg.updatesens = 'yes';
cfg.channel = 'MEG';
comp = ft_componentanalysis(cfg, data);
cfg = [];
cfg.updatesens = 'yes';
cfg.component = comp.label(numcomponent:end);
data_fix = ft_rejectcomponent(cfg, comp);
Cheers,

Robert Seymour (Aston Brain Centre)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20160919/38e0a6e1/attachment-0001.html>


More information about the fieldtrip mailing list