data.label wrong after componentanalysis?

a.stolk@fcdonders.ru.nl a.stolk at FCDONDERS.RU.NL
Tue Nov 10 17:39:49 CET 2009


Hi Nathan,

I managed to simulate your problem. The intersect function does indeed find matching labels (desired) and then orders those alphabetically (undesired).

The most practical solution is to use 'match_str' which only matches the channelindices and, thus, does not give back your labelarray in alphabetical order.

For example;
[ai, bi] = match_str(a, b)
with
a  = [1 2 3 4]   (here in numbers, but should be strings)
and
b = [3 2]

gives
ai = [2 3]
and
bi = [2 1]


I therefore replaced

cfg.channel = intersect(cfg.channel, cfg.topolabel);

with

tmpchan = match_str(cfg.channel, cfg.topolabel);
cfg.channel = cfg.channel(tmpchan);

and everything worked fine here: data.cfg.channel = tmpcomp.cfg.channel.

You'll find this replacement in tomorrow's version of FT. Thanks for your clear explanation and please let me know if these changes appear to be problematic to your analysis.

Friendly regards,
Arjen








----- Original Message -----
From: "Nathan Weisz" <nathanweisz at MAC.COM>
To: FIELDTRIP at NIC.SURFNET.NL
Sent: Monday, October 26, 2009 9:17:31 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: [FIELDTRIP] data.label wrong after componentanalysis?

hi everyone,

for an analysis of EEG data i'm doing some ICA cleaning. since there
are many conditions / epochs, i do the ICA on a subset of trials and
then apply the calculated mixing matrix to the individual conditions.

i noticed (and i'm quite sure it's no user related error) that after
rejecting components and reconstructing the preprocessing data
structure, that the sequence in data.label has changed (apparently
into alphabetical order). however that rows in the 2-D matrices making
up data.trial(xy) have not changed, accordingly. i noticed because the
topography of the auditory N1 was a huge mess.

changing the labels solved the problem, i.e.:
ica_cleaned_data.label = data_before_ica_cleaning.label;

for those interested here the original code:

load([outdir '/dataB1F1.mat'], 'dataB1F1') %load data for one condition

cfg=[];
cfg.topo=comp.topo;
cfg.topolabel=comp.topolabel;

tmpcomp=componentanalysis(cfg,dataB1F1); %apply precomputed ICA to
condition

cfg=[];
cfg.component=ncmp;

dataB1F1=rejectcomponent(cfg, tmpcomp); %reject components obviously
representing artefacts

 >> [comp.cfg.channel(1:5) tmpcomp.cfg.channel(1:5)] %demonstrate
channel label mismatch

ans =

     'Lm'     'L1'
     'LE1'    'L10'
     'LE2'    'L11'
     'LE3'    'L12'
     'LD2'    'L13'

the crucial line appears to be in componentanalysis line 220:
cfg.channel = intersect(cfg.channel, cfg.topolabel);

intersect sorts the outcome:
 >> a=randperm(10)

a =

      7     1     9     3     6     2     5     4    10     8

 >> b=randperm(10)

b =

      6     3     5     1     8     2    10     4     9     7

 >> intersect(a,b)

ans =

      1     2     3     4     5     6     7     8     9    10

since i use all channels, simply replacing the label-field with the
original label-field works for me.

best,
nathan

----------------------------------
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.



More information about the fieldtrip mailing list