From d.vanbarneveld at STUDENT.SCIENCE.RU.NL Thu Jul 6 16:58:40 2006 From: d.vanbarneveld at STUDENT.SCIENCE.RU.NL (Denise van Barneveld) Date: Thu, 6 Jul 2006 16:58:40 +0200 Subject: problem with text in topoplot and triplot Message-ID: Dear all, since I started using the new version of Matlab (R2006a) on a mac, I have this problem with text in the figures which I generate with topoplot.m and triplot.m. The upper half of the text lines (title, colorbar, electrodes, etc) is not visible (see attached figure). Does anyone have this problem too? Especially people who are using this new version on a pc. And does anyone perhaps has a solution for this problem? I am currently looking in the code, if I can find where it goes wrong, but I wonder whether it is a problem only with the new version, or only at a mac, or only at my computer. Best regards, Denise van Barneveld -------------- next part -------------- A non-text attachment was scrubbed... Name: topo.jpg Type: application/applefile Size: 48798 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: topo.jpg Type: image/jpeg Size: 85086 bytes Desc: not available URL: From muthuraman10 at HOTMAIL.COM Fri Jul 7 12:04:26 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Fri, 7 Jul 2006 10:04:26 +0000 Subject: query on confidence limit, DICS In-Reply-To: <37FAA4DD-5DD8-4F2F-ABA6-D9F47F6AB95E@fcdonders.ru.nl> Message-ID: Hello As i am able to sucessfully use the coherence analysis using freq_mtmfft and frq_mtmwelch to calculate the coherence i would like to know is there a way to calculate the confidence limit for the coherence calculated from the freqanalysis, is there a standard code Next, i would like to follow with the source analysis 'DICS' is there a tutorial available thanking you with regards Muthuraman >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] query on CTF software!!! >Date: Fri, 23 Jun 2006 15:23:22 +0200 > >dear Muthuraman > >On 23 Jun 2006, at 12:54, Muthuraman Muthuraman wrote: >>For the Beamformer source analysis, do we need the CTF software >>because when i am trying out the tutorial in beamforming > >You do not need the ctf software to follow the tutorial. The tutorial is >based however on a ctf MEG dataset. > >>CTF_READ_RES4 [v 1.12] >>....done ( 0.67 sec) >> >>i get the error >> >>??? Error using ==> read_fcdc_header >>could not read CTF res4 header file >> >>Error in ==> preprocessing at 263 >>hdr = read_fcdc_header(cfg.headerfile); > >Based on your error I suspect that matlab/fieldtrip cannot find the >dataset that you are trying to analyze, or that you matlab path is >incorrect. The function "CTF_READ_RES4" is not supposed to be called (it >is part of the NIH ctf import routines, e.g. used in EEGLAB), since the >default private/read_ctf_res4.m function can deal with the tutorial >dataset just fine. Please look into the code of read_fcdc_header (using >the matlab debugger) to figure out what your exact problem is. > >best >Robert From r.oostenveld at FCDONDERS.RU.NL Fri Jul 7 12:36:02 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 7 Jul 2006 12:36:02 +0200 Subject: query on confidence limit, DICS In-Reply-To: Message-ID: On 7 Jul 2006, at 12:04, Muthuraman Muthuraman wrote: > As i am able to sucessfully use the coherence analysis using > freq_mtmfft and frq_mtmwelch to calculate the coherence > i would like to know is there a way to calculate the confidence > limit for the coherence calculated from the freqanalysis, is there > a standard code You can compute a jackknife estimate of the variance in the coherence using the freqdescriptives function. That requires keeptrials=yes in freqanalysis. > Next, i would like to follow with the source analysis 'DICS' is > there a tutorial available No there is no tutorial available specifically for that. You can look at the beamformer tutorial at http://www2.ru.nl/fcdonders/fieldtrip/ doku.php?id=fieldtrip:documentation:tutorial:beamformer, the relevant options are cfg.method=dics, cfg.refchan and/or cfg.refdip. Robert From j.poort at NIN.KNAW.NL Tue Jul 11 11:43:49 2006 From: j.poort at NIN.KNAW.NL (Jasper Poort) Date: Tue, 11 Jul 2006 11:43:49 +0200 Subject: Confidence intervals for evoked potentials Message-ID: Hi all, I have some questions regarding confidence intervals for timelocked data in FieldTrip. I noted that a field .var is returned by timelockanalysis line 510 timelockanalysis % compute the variance tmp1 = repmat(dofvec(:)', [nchan 1]); tmp2 = repmat(dofvec(:)', [nchan 1])-1; var = (ss - (s.^2)./tmp1) ./ tmp2; Assuming that the sampling distribution is normal I can presumably use this field for computation of confidence intervals of the .avg field? Is nonparametric estimation of variance using a bootstrap or jackknife also implemented somewhere? In general I'm just curious to know how others compute confidence intervals for evoked potentials in FieldTrip, for example to get an idea at what point in time two conditions start to differ, best regards, Jasper -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.oostenveld at FCDONDERS.RU.NL Tue Jul 11 15:50:09 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 11 Jul 2006 15:50:09 +0200 Subject: Confidence intervals for evoked potentials In-Reply-To: <017d01c6a4ce$835853e0$910b57c0@ABSYS> Message-ID: Hi Jasper, On 11 Jul 2006, at 11:43, Jasper Poort wrote: > Hi all, I have some questions regarding confidence intervals for > timelocked data in FieldTrip. I noted that a field .var is returned > by timelockanalysis > > line 510 timelockanalysis > % compute the variance > tmp1 = repmat(dofvec(:)', [nchan 1]); > tmp2 = repmat(dofvec(:)', [nchan 1])-1; > var = (ss - (s.^2)./tmp1) ./ tmp2; > > Assuming that the sampling distribution is normal I can presumably > use this field for computation of confidence intervals of the .avg > field? Yes, you can use it to compute the channel-timepoint specific standard-error of mean (SEM). > Is nonparametric estimation of variance using a bootstrap or > jackknife also implemented somewhere? In general I'm just curious > to know how others compute confidence intervals for evoked > potentials in FieldTrip, for example to get an idea at what point > in time two conditions start to differ, Bootstrap and jackknife estimates of variance are only different from teh normal variance estimate if the measure involves a nonlinear or biased estimate (i.e. coherence). The jackknife estimate of variance of the ERP is exactly the same as the normal estimate of variance, since the ERP is a plain (linear) average. The same holds for bootstrap estimates. So that means that for ERPs the jackknife and bootstrap only would be a computationally expensive methods, resulting in the same variance as usual. Therefore they are not implemented. best regards, Robert From muthuraman10 at HOTMAIL.COM Tue Jul 11 16:59:58 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Tue, 11 Jul 2006 14:59:58 +0000 Subject: DICS In-Reply-To: Message-ID: Hello Thanks for the suggestion to use the jackknife variance estimate it works thanks a lot To use the DICS method We have a 64 channel EEG measurement from (Neuroscan) and 4 EMG channels recording and also we have the 64 channel measurement in FRMI the electrode locations we have it in a file with 3 columns x,y,z for each electrode using the polhemus sensors but our own software In the Source analysis Cfg.method='DICS'; but Cfg.xgrid, ygrid and zgrid the grid values are the sensor location values or it should be the cfg.grid.pos-where i can give in the 3 values [x y z] for each electrode I am a starter in the source analysis in combining EEG-FMRI please let me know with regards muthuraman. >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] query on confidence limit, DICS >Date: Fri, 7 Jul 2006 12:36:02 +0200 > >On 7 Jul 2006, at 12:04, Muthuraman Muthuraman wrote: >>As i am able to sucessfully use the coherence analysis using freq_mtmfft >>and frq_mtmwelch to calculate the coherence >>i would like to know is there a way to calculate the confidence limit for >>the coherence calculated from the freqanalysis, is there a standard code > >You can compute a jackknife estimate of the variance in the coherence >using the freqdescriptives function. That requires keeptrials=yes in >freqanalysis. > >>Next, i would like to follow with the source analysis 'DICS' is there a >>tutorial available > >No there is no tutorial available specifically for that. You can look at >the beamformer tutorial at http://www2.ru.nl/fcdonders/fieldtrip/ >doku.php?id=fieldtrip:documentation:tutorial:beamformer, the relevant >options are cfg.method=dics, cfg.refchan and/or cfg.refdip. > >Robert From r.oostenveld at FCDONDERS.RU.NL Tue Jul 11 17:51:28 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 11 Jul 2006 17:51:28 +0200 Subject: DICS In-Reply-To: Message-ID: Dear Muthuraman On 11 Jul 2006, at 16:59, Muthuraman Muthuraman wrote: > To use the DICS method > > We have a 64 channel EEG measurement from (Neuroscan) and 4 EMG > channels recording > and also we have the 64 channel measurement in FRMI > > the electrode locations we have it in a file with 3 columns x,y,z > for each electrode > using the polhemus sensors but our own software > > In the Source analysis > Cfg.method='DICS'; > but Cfg.xgrid, ygrid and zgrid > the grid values are the sensor location values > > or it should be the > cfg.grid.pos-where i can give in the 3 values [x y z] for each > electrode in SOURCEANALYSIS you specify using cfg.xgrid/ygrid/zgrid the locations at which the _dipoles_ will be placed, it is not the position of the electrodes. At each grid location a spatial filter is constructed and the power (and coherence) is computed. If you do not want to scan on a full 3-D grid, but on only a few dipole locations of interest, you can use cfg.grid.pos to specify those dipole locations. The electrode positions are specified in the cfg.elec structure, or in the cfg.elecfile filename. You can find more details on the definition of electrode positions at http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? id=fieldtrip:documentation:frequently_asked_questions#how_are_electrodes _magnetometers_or_gradiometers_described Furthermore, you can try using the READ_FCDC_ELEC function for reading the electrode locations, but probably taht will not work since youy are using your own software for digitization. Alternatively, you can manually construct an "elec" electrode definition. best regards Robert PS please upgrade to a recent fieldtrip version, the sourceanalysis options cfg.xgrid/ygrid/zgrid have been renamed. The old options still will work, but in general it is preferable to work with a recent copy of the toolbox. From muthuraman10 at HOTMAIL.COM Thu Jul 13 13:11:35 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Thu, 13 Jul 2006 11:11:35 +0000 Subject: DICS In-Reply-To: <43B3E5A4-716B-48A0-8CE0-5F8810DC4A65@fcdonders.ru.nl> Message-ID: Hello Thankyou for the suggestions I have dowloaded the latest version now and i am working with it i have created the own elec file which is "elec1" and these are the steps i follow please go through it and reply me, why is the error -First i calculate the coherence using the freqanalysis and freqdescriptives which works perfectly -Second i calculate the Grid using Prepare_leadfield vol = []; vol.r = 12 * [0.88 0.92 1.00]; vol.c = [1 1/80 1]; vol.o = [0 0 0]; >>cfg1 = []; cfg1.elec = elec1; cfg1.vol = vol; cfg1.resolution = 2; grid = prepare_leadfield(cfg1); which also works i get the output for the Grid -Third I want use the source analysis for the DICS cfg.method='dics'; cfg.grid=grid; cfg.elecfile=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmfft); using headmodel specified in the configuration ??? Error using ==> fprintf Function is not defined for 'struct' inputs. Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 310 fprintf('reading electrodes from file %s\n', cfg.elecfile); Error in ==> sourceanalysis at 574 [vol, sens, cfg] = prepare_vol_sens(cfg, data); -I also tried grid using the freqmtmfft-which as the results for the freqanalysis vol = []; vol.r = 12 * [0.88 0.92 1.00]; vol.c = [1 1/80 1]; vol.o = [0 0 0]; >>cfg1 = []; cfg1.elec = elec1; cfg1.vol = vol; cfg1.resolution = 2; grid = prepare_leadfield(cfg1,freqmtmfft); I get error using headmodel specified in the configuration using electrodes specified in the configuration ??? Error using ==> delaunayn Not enough unique points to do tessellation. Error in ==> delaunay at 49 tri = delaunayn([x(:) y(:)]); Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 330 elec.tri = delaunay(elec.prj(:,1), elec.prj(:,2)); Error in ==> prepare_leadfield at 179 [vol, sens, cfg] = prepare_vol_sens(cfg, data); Thanking you with regards Muthuraman. >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] DICS >Date: Tue, 11 Jul 2006 17:51:28 +0200 > >Dear Muthuraman > >On 11 Jul 2006, at 16:59, Muthuraman Muthuraman wrote: >>To use the DICS method >> >>We have a 64 channel EEG measurement from (Neuroscan) and 4 EMG channels >>recording >>and also we have the 64 channel measurement in FRMI >> >>the electrode locations we have it in a file with 3 columns x,y,z for >>each electrode >>using the polhemus sensors but our own software >> >>In the Source analysis >>Cfg.method='DICS'; >>but Cfg.xgrid, ygrid and zgrid >>the grid values are the sensor location values >> >>or it should be the >>cfg.grid.pos-where i can give in the 3 values [x y z] for each electrode > >in SOURCEANALYSIS you specify using cfg.xgrid/ygrid/zgrid the locations at >which the _dipoles_ will be placed, it is not the position of the >electrodes. At each grid location a spatial filter is constructed and the >power (and coherence) is computed. If you do not want to scan on a full >3-D grid, but on only a few dipole locations of interest, you can use >cfg.grid.pos to specify those dipole locations. > >The electrode positions are specified in the cfg.elec structure, or in the >cfg.elecfile filename. You can find more details on the definition of >electrode positions at http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? >id=fieldtrip:documentation:frequently_asked_questions#how_are_electrodes >_magnetometers_or_gradiometers_described > >Furthermore, you can try using the READ_FCDC_ELEC function for reading the >electrode locations, but probably taht will not work since youy are using >your own software for digitization. Alternatively, you can manually >construct an "elec" electrode definition. > >best regards >Robert > >PS please upgrade to a recent fieldtrip version, the sourceanalysis >options cfg.xgrid/ygrid/zgrid have been renamed. The old options still >will work, but in general it is preferable to work with a recent copy of >the toolbox. From r.oostenveld at FCDONDERS.RU.NL Fri Jul 14 11:37:47 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 14 Jul 2006 11:37:47 +0200 Subject: DICS In-Reply-To: Message-ID: On 13 Jul 2006, at 13:11, Muthuraman Muthuraman wrote: > cfg.method='dics'; > cfg.grid=grid; > cfg.elecfile=elec1; > cfg.vol=vol; > [source]=sourceanalysis(cfg,freqmtmfft); > using headmodel specified in the configuration > ??? Error using ==> fprintf > Function is not defined for 'struct' inputs. > > Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 310 > fprintf('reading electrodes from file %s\n', cfg.elecfile); You should specify either cfg.elecfile with a string (filename) or cfg.elec with a structure (i.e. cfg.elec.pnt and cfg.elec.label) > I get error > > using headmodel specified in the configuration > using electrodes specified in the configuration > ??? Error using ==> delaunayn > Not enough unique points to do tessellation. > > Error in ==> delaunay at 49 > tri = delaunayn([x(:) y(:)]); > > Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 330 > elec.tri = delaunay(elec.prj(:,1), elec.prj(:,2)); > > Error in ==> prepare_leadfield at 179 > [vol, sens, cfg] = prepare_vol_sens(cfg, data); That indicates that less than 3 electrodes were selected. Probably there is a mismatch between the channel names in the data and the names of the electrodes. FT selects the channels and electrodes based on the corresponding labels, if they do not correspond then no channels+electrodes are selected. Robert From muthuraman10 at HOTMAIL.COM Mon Jul 17 16:12:14 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Mon, 17 Jul 2006 14:12:14 +0000 Subject: DICS In-Reply-To: <242E1EA4-D9FE-42D8-B23A-B689CBBF7FA8@fcdonders.ru.nl> Message-ID: Hello Thankyou for pointing out errors now i am able to calculate the Grid values but when i wanted to use the source analysis for the freqmtmwelch cfg.frequency=5; cfg.refchannel='C1'; cfg.refdip=10; cfg.method='dics'; cfg.grid=grid; cfg.elec=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmwelch); using headmodel specified in the configuration using electrodes specified in the configuration 42 dipoles inside, 18 dipoles outside brain I get the error ??? Reference to non-existent field 'cumtapcnt'. Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 Ntrials = length(freq.cumtapcnt); Error in ==> sourceanalysis at 663 [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); when i use the mtmfft i get the cumtapcnt values but not when using the mtmwelch is this a problem in the mtmwelch or i am doing something wrong Please go through it thanking you with regards muthuraman >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] DICS >Date: Fri, 14 Jul 2006 11:37:47 +0200 > >On 13 Jul 2006, at 13:11, Muthuraman Muthuraman wrote: > >>cfg.method='dics'; >>cfg.grid=grid; >>cfg.elecfile=elec1; >>cfg.vol=vol; >>[source]=sourceanalysis(cfg,freqmtmfft); >>using headmodel specified in the configuration >>??? Error using ==> fprintf >>Function is not defined for 'struct' inputs. >> >>Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 310 >> fprintf('reading electrodes from file %s\n', cfg.elecfile); > >You should specify either cfg.elecfile with a string (filename) or >cfg.elec with a structure (i.e. cfg.elec.pnt and cfg.elec.label) > >>I get error >> >>using headmodel specified in the configuration >>using electrodes specified in the configuration >>??? Error using ==> delaunayn >>Not enough unique points to do tessellation. >> >>Error in ==> delaunay at 49 >> tri = delaunayn([x(:) y(:)]); >> >>Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 330 >> elec.tri = delaunay(elec.prj(:,1), elec.prj(:,2)); >> >>Error in ==> prepare_leadfield at 179 >>[vol, sens, cfg] = prepare_vol_sens(cfg, data); > >That indicates that less than 3 electrodes were selected. Probably there >is a mismatch between the channel names in the data and the names of the >electrodes. FT selects the channels and electrodes based on the >corresponding labels, if they do not correspond then no >channels+electrodes are selected. > >Robert From floris.delange at FCDONDERS.RU.NL Tue Jul 25 10:24:18 2006 From: floris.delange at FCDONDERS.RU.NL (Floris de Lange) Date: Tue, 25 Jul 2006 10:24:18 +0200 Subject: sourcestatistics question Message-ID: Dear FieldTrippers, I have a question concerning sourcestatistics. I have calculated the source localization using DICS for 11 individual subjects. Now I would like to test for the significance of the sources using sourcestatistics. The examples I find in the tutorial are about checking for significance within one subject by shuffling the individual trials. However, what I would like to do is to do the statistics on the 2nd level (subject), and to test for the consistency of the source reconstructions across subjects. Is this possible with sourcestatistics? If so, how should I feed the data to sourcestatistics? If I say something like stats = sourcestatistics(cfg,sources{1:11}) where each source{} is a normalized source (calculated by sourceanalysis, normalized with sourceinterpolate), it complains (rightfully) that there's a reference to the non-existing field 'statistic'. Any ideas are greatly appreciated! Kind regards, Floris From muthuraman10 at HOTMAIL.COM Tue Jul 25 10:34:30 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Tue, 25 Jul 2006 08:34:30 +0000 Subject: Source anaylsis In-Reply-To: <242E1EA4-D9FE-42D8-B23A-B689CBBF7FA8@fcdonders.ru.nl> Message-ID: Hello Thankyou for pointing out errors now i am able to calculate the Grid values but when i wanted to use the source analysis for the freqmtmwelch cfg.frequency=5; cfg.refchannel='C1'; cfg.refdip=10; cfg.method='dics'; cfg.grid=grid; cfg.elec=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmwelch); using headmodel specified in the configuration using electrodes specified in the configuration 42 dipoles inside, 18 dipoles outside brain I get the error ??? Reference to non-existent field 'cumtapcnt'. Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 Ntrials = length(freq.cumtapcnt); Error in ==> sourceanalysis at 663 [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); when i use the mtmfft i get the cumtapcnt values i get a error when using the mtmfft for source analysis cfg.frequency=5; cfg.refchannel='C1'; cfg.refdip=10; cfg.method='dics'; cfg.grid=grid; cfg.elec=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmfft); using headmodel specified in the configuration using electrodes specified in the configuration 610 dipoles inside, 600 dipoles outside brain ??? Error using ==> fieldtrip-20060712\private\prepare_freq_matrices The cross-spectral-density matrix is not complete Error in ==> sourceanalysis at 663 [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); Please go through it Because for the DICS i would like to use the freqmtmwelch is this a problem with freqmtmwelch or something wrong in my inputs thanking you with regards muthuraman From r.oostenveld at FCDONDERS.RU.NL Tue Jul 25 12:18:48 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 25 Jul 2006 12:18:48 +0200 Subject: DICS In-Reply-To: Message-ID: Hi Muthuraman The cumulative number of tapers per trial is indeed not kept in mtmwelch. You should specify it manually prior to freqanalysis. I do not recall whether you use keeptrials and keeptapers but if not, then it is safe to specify freq.cumtapcnt=1. Keeping count of the number of trials and tapers in the various freqanalysis methods is not done consistenly, it is something that we will improve in the future. best regards, Robert On 17 Jul 2006, at 16:12, Muthuraman Muthuraman wrote: > I get the error > > ??? Reference to non-existent field 'cumtapcnt'. > > Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 > Ntrials = length(freq.cumtapcnt); > > Error in ==> sourceanalysis at 663 > [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); > > when i use the mtmfft i get the cumtapcnt values > but not when using the mtmwelch is this a problem in the mtmwelch > or i am doing something wrong From r.oostenveld at FCDONDERS.RU.NL Tue Jul 25 12:29:23 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 25 Jul 2006 12:29:23 +0200 Subject: sourcestatistics question In-Reply-To: <44C5D532.4020708@fcdonders.ru.nl> Message-ID: Hi Floris, On 25 Jul 2006, at 10:24, Floris de Lange wrote: > I have a question concerning sourcestatistics. > I have calculated the source localization using DICS for 11 > individual subjects. Now I would like to test for the significance > of the sources using sourcestatistics. The examples I find in the > tutorial are about checking for significance within one subject by > shuffling the individual trials. However, what I would like to do > is to do the statistics on the 2nd level (subject), and to test for > the consistency of the source reconstructions across subjects. > Is this possible with sourcestatistics? Yes, that is possible. > If so, how should I feed the data to sourcestatistics? If I say > something like stats = sourcestatistics(cfg,sources{1:11}) where > each source{} is a normalized source (calculated by sourceanalysis, > normalized with sourceinterpolate), it complains (rightfully) that > there's a reference to the non-existing field 'statistic'. Assuming you want to use a randomization test to get a Monte-Carlo estimate of the probability of your null-hypothesis (cfg.method='montecarlo'), cfg.statistic should be a string describing the statistic whose randomization distribution you want to compute. See the help of statistic_montecarlo. Furthermore, the hypothesis that you want to test is about two conditions. That means that the two conditions both should be fed into sourcestatistics, e.g. something like for i=1:11 read data from condition 1 for each subject cond1{i} = sourceanalysis(...) cond1{i} = sourceinterpolate(...) cond1{i} = volumenormalize(...) read data from condition 2 for each subject cond2{i} = sourceanalysis(...) cond2{i} = sourceinterpolate(...) cond2{i} = volumenormalize(...) end cfg = [] cfg.design = [1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 % condition number 1 2 3 4 5 ..... 1 2 3 4 5 .... ] % subject number cfg.method = 'montecarlo' cfg.statistic = 'depsamplesT' cfg.ivar = 1; % row with the independent variable (condition) in the design cfg.uvar = 2; % row with the unit of observation (subject) in the design matrix stat = sourcestatistics(cfg, cond1{:}, cond2{:}); It is also possible to do other tests, which are more in line with a 2nd level analysis (e.g. compute t-maps per subject and test over subjects). It is better to discuss those face-to-face. best regards, Robert From Jan.Schoffelen at FCDONDERS.RU.NL Tue Jul 25 12:32:38 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Tue, 25 Jul 2006 12:32:38 +0200 Subject: DICS In-Reply-To: <4442BD57-7F97-469F-990B-CD63E171E371@fcdonders.ru.nl> Message-ID: Dear Muthuraman, One little addition to the freq.cumtapcnt-story. freq.cumtapcnt should be a vector instead of a scalar: the correct way to specify it would be: freq.cumtapcnt = ones(ntrl,1) with ntrl the number of trials in your data. Yours, Jan-Mathijs -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Robert Oostenveld Sent: Tuesday, July 25, 2006 12:19 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: Re: [FIELDTRIP] DICS Hi Muthuraman The cumulative number of tapers per trial is indeed not kept in mtmwelch. You should specify it manually prior to freqanalysis. I do not recall whether you use keeptrials and keeptapers but if not, then it is safe to specify freq.cumtapcnt=1. Keeping count of the number of trials and tapers in the various freqanalysis methods is not done consistenly, it is something that we will improve in the future. best regards, Robert On 17 Jul 2006, at 16:12, Muthuraman Muthuraman wrote: > I get the error > > ??? Reference to non-existent field 'cumtapcnt'. > > Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 > Ntrials = length(freq.cumtapcnt); > > Error in ==> sourceanalysis at 663 > [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); > > when i use the mtmfft i get the cumtapcnt values > but not when using the mtmwelch is this a problem in the mtmwelch > or i am doing something wrong From r.oostenveld at FCDONDERS.RU.NL Tue Jul 25 12:32:52 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 25 Jul 2006 12:32:52 +0200 Subject: Source anaylsis In-Reply-To: Message-ID: On 25 Jul 2006, at 10:34, Muthuraman Muthuraman wrote: > ??? Error using ==> fieldtrip-20060712\private\prepare_freq_matrices > The cross-spectral-density matrix is not complete this indicates that you did not include all channel combinations (cfg.channelcmb) in freqanalysis, and that you try to use a cross spectral density matrix for DISC that is not complete (i.e. come cross-spectra are missing). You should correct your configuration for the frequencyanalysus (e.g. cfg.channelcmb = {'all' 'all'} or see the CHANNELCOMBINATION function). best regards, Robert From jciveira at UNAV.ES Tue Jul 25 14:22:36 2006 From: jciveira at UNAV.ES (Juan Civeira) Date: Tue, 25 Jul 2006 14:22:36 +0200 Subject: Source anaylsis In-Reply-To: <77E33A56-A0D4-43FC-94E0-91A3AC31197B@fcdonders.ru.nl> Message-ID: I have the same problem and I do not know how to fix it, even though I tried your solution with cfg.channelcmb. My case is : i have a set of 82 electrodes, I make freqanalysis with cfg.channelcmb = channelcombination({'all' 'all'},data.label); thus I get freq = label: {82x1 cell} dimord: 'chan_freq' freq: [14 14.4000 14.8000 15.2000 15.6000 16 16.4000 16.8000 17.2000 17.6000 18] powspctrm: [82x11 double] labelcmb: {3321x2 cell} crsspctrm: [3321x11 double] cfg: [1x1 struct] When I make sourceanalysis with a dipole as a reference and I have no problems but when I want to use a channel as a reference I always have the same error: The cross-spectral-density matrix is not complete. Can you help me? Best regards Juan Robert Oostenveld ha escrito: > On 25 Jul 2006, at 10:34, Muthuraman Muthuraman wrote: > >> ??? Error using ==> fieldtrip-20060712\private\prepare_freq_matrices >> The cross-spectral-density matrix is not complete > > this indicates that you did not include all channel combinations > (cfg.channelcmb) in freqanalysis, and that you try to use a cross > spectral density matrix for DISC that is not complete (i.e. come > cross-spectra are missing). You should correct your configuration for > the frequencyanalysus (e.g. cfg.channelcmb = {'all' 'all'} or see the > CHANNELCOMBINATION function). > > best regards, > Robert ---------------------------------------------------------------- Este mensaje ha sido enviado desde https://webmail.unav.es From stephan.bickel at ANATOM.UNIZH.CH Tue Jul 25 17:39:32 2006 From: stephan.bickel at ANATOM.UNIZH.CH (Stephan Bickel) Date: Tue, 25 Jul 2006 17:39:32 +0200 Subject: import bva time-freq data Message-ID: Hi, I try to import brainvision analyzer dat files of wavelet time-frequency decompositions into fieldtrip. I exported an average file, so it consists only of a single segment. However I have some problems with it I am not sure if it is because I define the segment wrong or if it is not possible to import this data into fieldtrip. I pasted the code and the error message below and attached the marker- and header file. I would be really glad for any suggestions. Thank you very much, Stephan This is what I tried: cfg = []; cfg.headerfile =... 'c:\HumanEEG_data\Vision_Exports\WT_all_ft_test.vhdr'; cfg.datafile =... 'c:\HumanEEG_data\Vision_Exports\WT_all_ft_test.dat'; cfg.channel = 'all'; %Trialdefinition cfg.trialdef.trgfile =... 'c:\HumanEEG_data\Vision_Exports\WT_all_ft_test.vmrk'; cfg.trialdef.stim = 'New Segment'; %cfg.trialdef.segment = 'yes'; cfg.trialdef.timezero = 'yes'; % cfg.trialdef.eventtype = 'Time 0'; cfg.trialdef.prestim = 0.500; cfg.trialdef.poststim = 1.600; [cfg] = definetrial(cfg) [raw] = preprocessing(cfg) and this is the error message: evaluating trialfunction 'trialfun_brainvision' 0 stimulus markers converted into 0 trials 0 response markers converted into 0 trials 1 segment markers converted into 0 trials 1 "Time 0" markers converted into 1 trials found 0 events created 1 trials cfg = headerfile: [1x88 char] datafile: [1x87 char] channel: 'all' trialdef: [1x1 struct] dataset: [] trialfun: 'trialfun_brainvision' event: [] trl: [1 1051 -250] version: [1x1 struct] retaining exist trial definition retaining exist event information found 0 events created 1 trials rejected 0 trials completely rejected 0 trials partially resulting 1 trials reading and preprocessing reading and preprocessing trial 1 from 1 ??? Subscripted assignment dimension mismatch. Error in ==> fieldtrip-20060330\private\read_brainvision_eeg at 65 dat(line,:) = str2num(str); Error in ==> read_fcdc_data at 419 dat = read_brainvision_eeg(datafile, hdr, begsample, endsample); Error in ==> preprocessing at 322 dat = read_fcdc_data(cfg.datafile, hdr, begsample, endsample, rawindx, iscontinuous); -------------- next part -------------- A non-text attachment was scrubbed... Name: WT_all_ft_test.vmrk Type: application/octet-stream Size: 741 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: WT_all_ft_test.vhdr Type: application/octet-stream Size: 3459 bytes Desc: not available URL: From r.oostenveld at FCDONDERS.RU.NL Wed Jul 26 09:07:03 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 26 Jul 2006 09:07:03 +0200 Subject: Source anaylsis In-Reply-To: <20060725142236.lz6o47hwkkwo4sw4@webmail.unav.es> Message-ID: On 25 Jul 2006, at 14:22, jciveira at unav.es wrote: > I have the same problem and I do not know how to fix it, even > though I tried your solution with cfg.channelcmb. > > My case is : i have a set of 82 electrodes, I make freqanalysis > with cfg.channelcmb = channelcombination({'all' > 'all'},data.label); thus I get > > freq = > > label: {82x1 cell} > dimord: 'chan_freq' > freq: [14 14.4000 14.8000 15.2000 15.6000 16 16.4000 > 16.8000 17.2000 17.6000 18] > powspctrm: [82x11 double] > labelcmb: {3321x2 cell} > crsspctrm: [3321x11 double] > cfg: [1x1 struct] > > When I make sourceanalysis with a dipole as a reference and I have > no problems but when I want to use a channel as a reference I > always have the same error: > The cross-spectral-density matrix is not complete. > > Can you help me? > > Best regards > Juan Dear Juan Do you have 82 EEG electrodes, or 81 and one EMG electrode? I would expect the latter, since computing coherence between one particular EEG electrode and sources in the brain with DICS will not lead to meaningfull results. The selected EEG electrode will pick up volume- conducted activity from all sources in the brain (as opposed to an EMG electrode) and would be referenced to the same reference electrode as all other electrodes. So there will be a huge amount of trivial coherence, whose spatial distribution in the brain will probably more reflect the volume-conduction than something physiologically interpretable. Although I have not used DICS with a reference channel on EEG data, I would expect the code to work if you follow a procedure like this: cfg = ... trial selection stuff cfg = definetrial(cfg) cfg = ... preprocessing stuff cfg.channel = list of all EEG electrodes cfg.implicitref = name of implicit reference electrode used for the EEG channels cfg.reref = 'all' % rereference all EEG electrodes to an average reference data_eeg = preprocessing(cfg) cfg = ... trial selection stuff cfg = definetrial(cfg) cfg = ... preprocessing stuff cfg.channel = list of all EMG electrodes, assuming that they are bipolar channels % cfg.reref may be used if you have two unipolar channels on the muscle of interest cfg.rectify = 'yes' % this makes the spiky nature of the EMG more visible, and improves the coherence estimate cfg.baseline = 'yes' % remove baseline prior to rectification, not neccessary but still preferable data_emg = preprocessing(cfg) % combine EEG and EMG in one dataset, both are referenced differently data = appenddata([], data_eeg, data_emg); cfg = ... frequency analysis stuff cfg.ouptu = 'powandcsd' cfg.channelcmb = {'all', 'all'} freq = freqanalysis(cfg, data); cfg = ... source specific settings cfg.refchan = one of your bipolar EMG channels cfg.channel = all your EEG channels source = sourceanalysis(cfg, freq) best regards, Robert From r.oostenveld at FCDONDERS.RU.NL Wed Jul 26 09:46:59 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 26 Jul 2006 09:46:59 +0200 Subject: import bva time-freq data In-Reply-To: Message-ID: Hi Stephan, On 25 Jul 2006, at 17:39, Stephan Bickel wrote: > I try to import brainvision analyzer dat files of wavelet time- > frequency > decompositions into fieldtrip. I exported an average file, so it > consists > only of a single segment. However I have some problems with it I am > not sure ... > cfg.trialdef.trgfile = 'c:\HumanEEG_data\Vision_Exports > \WT_all_ft_test.vmrk'; > cfg.trialdef.stim = 'New Segment'; > %cfg.trialdef.segment = 'yes'; > cfg.trialdef.timezero = 'yes'; > % cfg.trialdef.eventtype = 'Time 0'; In general I would recommend to use the trialfun_general instead of the trialfun_brainvision (but the latter should also work). The trialfun_general was written later and will work for any dataformat that is supported by read_fcdc_event, the trialfun_brainvision is only there to support old scripts (i.e. scripts that predate the read_fcdc_event function). If not specified manually as trialfun, the trialfun_general or trialfun_brainvision is selected automatically based on the cfg settings. In your case you could do cfg.trialdef.eventtype = 'New Segment' or 'Time 0' cfg.trialdef.prestim = number, latency in seconds (optional) cfg.trialdef.poststim = number, latency in seconds (optional) See teh help of DEFINETRIAL. But in your case this is not the problem. The problem lies in > cfg.trialdef.prestim = 0.500; > cfg.trialdef.poststim = 1.600; If I do event = read_fcdc_event('WT_all_ft_test.vmrk') then I see that >> event(1) ans = type: 'New Segment' value: '1' sample: 1 duration: 0 offset: [] >> event(2) ans = type: 'Time 0' value: '251' sample: 1 duration: 0 offset: [] The 'New Segment' event is at sample 1, hence you cannot select a 500ms pre-stimulus window before it (you cannot read before the beginning of the data). The alternative 'Time 0' event is also at sample 1. It specifies a value of 251, which surprises me. I would expect that event to be present at sample 251. Reading the marker file with a text editor, I see (abbreviated) the explanation Mk=,,,, , and the markers Mk1=New Segment,,1,1,0,00000000000000000000 Mk2=Time 0,,251,1,0 So Mk2 should indeed be at sample 251. With the matlab debugger in the private/read_event.m file (around line 164) I notice that the problem lies in the missing value of the second field, i.e. Mk2=Time 0,,251,1,0 is interpreted as Mk2=Time 0,251,1,0 (one comma less) All fields are shifted by one, resulting in the sample number being interpreted as the description (i.e. value). I have fixed it in read_event, by replacing line 151 from tok = tokenize(line, '='); into tok = tokenize(line, '=', 0); % do not squeeze repetitions of the seperator and by replacing line 157 from tok = tokenize(tok{2}, ','); into tok = tokenize(tok{2}, ',', 0); % do not squeeze repetitions of the seperator i.e. both calls to the tokenize function now use the third argument. You can apply the same change to your copy, but please check that you have an up to date version of tokenize that accepts 3 input arguments (tokenize is in private as well). I will include the bug fix in the upcoming nightly release of FieldTrip. Better upgrade tomorrow to the latest FT version from the FTP server. I think that sofar it was not noticed since people here at the Donders typically use triggers as markers in their Brainvision data, and in case of triggers the second field would not be empty. If I now do cfg = []; cfg.dataset = 'WT_all_ft_test.vhdr' cfg.trialdef.eventtype = 'Time 0' cfg.trialdef.prestim = 0.5000 cfg.trialdef.poststim = 1 cfg = definetrial(cfg) I get evaluating trialfunction 'trialfun_general' found 2 events created 1 trials cfg = dataset: 'WT_all_ft_test.vhdr' trialdef: [1x1 struct] datafile: [] headerfile: 'WT_all_ft_test.vhdr' trialfun: 'trialfun_general' event: [1x2 struct] trl: [1 750 -250] version: [1x1 struct] which is correct. The trial (cfg.trl) runs from sample 1 to sample 750 in the data file, and the first sample of that trial corresponds with time cfg.trl(1,3)/fsample=-0.500 seconds. Thanks for reporting the bug, Robert From stephan.bickel at ANATOM.UNIZH.CH Wed Jul 26 17:28:54 2006 From: stephan.bickel at ANATOM.UNIZH.CH (Stephan Bickel, Anatomisches Inst.) Date: Wed, 26 Jul 2006 11:28:54 -0400 Subject: import bva time-freq data In-Reply-To: <30468A0B-0B5C-41EF-9FB3-84FD50036A22@fcdonders.ru.nl> Message-ID: Hi Robert, thank you very much for your response and for fixing the bug. Reading in the trial information works fine now. Unfortunately I encounter another problem when I want to read in the data with preprocessing. I wonder if it is yet possible to read in time-frequency data from bva-dat files? Sorry for bothering you again and thank you very much in advance. Stephan So when I do: cfg = []; cfg.dataset = 'WT_all_ft_test.vhdr' cfg.trialdef.eventtype = 'Time 0' cfg.trialdef.prestim = 0.5000 cfg.trialdef.poststim = 1 cfg = definetrial(cfg) cfg.datafile = 'WT_all_ft_test.dat'; cfg.channel = 'all'; [raw] = preprocessing(cfg) I get: cfg = dataset: 'WT_all_ft_test.vhdr' trialdef: [1x1 struct] datafile: 'WT_all_ft_test.dat' headerfile: 'WT_all_ft_test.vhdr' trialfun: 'trialfun_general' event: [1x2 struct] trl: [1 750 -250] version: [1x1 struct] channel: 'all' retaining exist trial definition retaining exist event information found 2 events created 1 trials rejected 0 trials completely rejected 0 trials partially resulting 1 trials reading and preprocessing reading and preprocessing trial 1 from 1 ??? Subscripted assignment dimension mismatch. Error in ==> fieldtrip-20060725\private\read_brainvision_eeg at 65 dat(line,:) = str2num(str); Error in ==> fieldtrip-20060725\private\read_data at 239 dat = read_brainvision_eeg(filename, hdr, begsample, endsample); Error in ==> read_fcdc_data at 49 [dat] = read_data(varargin{:}); Error in ==> preprocessing at 366 dat = read_fcdc_data(cfg.datafile, hdr, begsample, endsample, rawindx, iscontinuous); On Wed, 26 Jul 2006 09:46:59 +0200 Robert Oostenveld wrote: > Hi Stephan, > > On 25 Jul 2006, at 17:39, Stephan Bickel wrote: >> I try to import brainvision analyzer dat files of wavelet time- >> frequency >> decompositions into fieldtrip. I exported an average file, so it >> consists >> only of a single segment. However I have some problems with it I am >> not sure > ... >> cfg.trialdef.trgfile = 'c:\HumanEEG_data\Vision_Exports >> \WT_all_ft_test.vmrk'; >> cfg.trialdef.stim = 'New Segment'; >> %cfg.trialdef.segment = 'yes'; >> cfg.trialdef.timezero = 'yes'; >> % cfg.trialdef.eventtype = 'Time 0'; > > In general I would recommend to use the trialfun_general instead of the >trialfun_brainvision (but the latter should also work). The > trialfun_general was written later and will work for any dataformat that >is supported by read_fcdc_event, the trialfun_brainvision is only there to >support old scripts (i.e. scripts that predate the read_fcdc_event >function). > > If not specified manually as trialfun, the trialfun_general or > trialfun_brainvision is selected automatically based on the cfg settings. >In your case you could do > cfg.trialdef.eventtype = 'New Segment' or 'Time 0' > cfg.trialdef.prestim = number, latency in seconds (optional) > cfg.trialdef.poststim = number, latency in seconds (optional) > See teh help of DEFINETRIAL. > > But in your case this is not the problem. The problem lies in >> cfg.trialdef.prestim = 0.500; >> cfg.trialdef.poststim = 1.600; > > If I do > event = read_fcdc_event('WT_all_ft_test.vmrk') > then I see that > > >> event(1) > ans = > type: 'New Segment' > value: '1' > sample: 1 > duration: 0 > offset: [] > > >> event(2) > ans = > type: 'Time 0' > value: '251' > sample: 1 > duration: 0 > offset: [] > > The 'New Segment' event is at sample 1, hence you cannot select a 500ms >pre-stimulus window before it (you cannot read before the beginning of the >data). The alternative 'Time 0' event is also at sample 1. It specifies a >value of 251, which surprises me. I would expect that event to be present >at sample 251. > > Reading the marker file with a text editor, I see (abbreviated) the > explanation > Mk=,,,, > , > and the markers > Mk1=New Segment,,1,1,0,00000000000000000000 > Mk2=Time 0,,251,1,0 > So Mk2 should indeed be at sample 251. > > With the matlab debugger in the private/read_event.m file (around line >164) I notice that the problem lies in the missing value of the second >field, i.e. > Mk2=Time 0,,251,1,0 > is interpreted as > Mk2=Time 0,251,1,0 (one comma less) > All fields are shifted by one, resulting in the sample number being > interpreted as the description (i.e. value). > > I have fixed it in read_event, by replacing line 151 from > tok = tokenize(line, '='); > into > tok = tokenize(line, '=', 0); % do not squeeze repetitions of the > seperator > and by replacing line 157 from > tok = tokenize(tok{2}, ','); > into > tok = tokenize(tok{2}, ',', 0); % do not squeeze repetitions of > the seperator > i.e. both calls to the tokenize function now use the third argument. You >can apply the same change to your copy, but please check that you have an >up to date version of tokenize that accepts 3 input arguments (tokenize is >in private as well). I will include the bug fix in the upcoming nightly >release of FieldTrip. Better upgrade tomorrow to the latest FT version >from the FTP server. > > I think that sofar it was not noticed since people here at the Donders >typically use triggers as markers in their Brainvision data, and in case >of triggers the second field would not be empty. > > If I now do > cfg = []; > cfg.dataset = 'WT_all_ft_test.vhdr' > cfg.trialdef.eventtype = 'Time 0' > cfg.trialdef.prestim = 0.5000 > cfg.trialdef.poststim = 1 > cfg = definetrial(cfg) > I get > evaluating trialfunction 'trialfun_general' > found 2 events > created 1 trials > cfg = > dataset: 'WT_all_ft_test.vhdr' > trialdef: [1x1 struct] > datafile: [] > headerfile: 'WT_all_ft_test.vhdr' > trialfun: 'trialfun_general' > event: [1x2 struct] > trl: [1 750 -250] > version: [1x1 struct] > which is correct. The trial (cfg.trl) runs from sample 1 to sample 750 in >the data file, and the first sample of that trial corresponds with time >cfg.trl(1,3)/fsample=-0.500 seconds. > > Thanks for reporting the bug, > Robert From r.oostenveld at FCDONDERS.RU.NL Thu Jul 27 09:26:26 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 27 Jul 2006 09:26:26 +0200 Subject: import bva time-freq data In-Reply-To: Message-ID: On 26 Jul 2006, at 17:28, Stephan Bickel, Anatomisches Inst. wrote: > thank you very much for your response and for fixing the bug. > Reading in the trial information works fine now. Unfortunately I > encounter another problem when I want to read in the data with > preprocessing. I wonder if it is yet possible to read in time- > frequency data from bva-dat files? ... > Error in ==> fieldtrip-20060725\private\read_brainvision_eeg at 65 > dat(line,:) = str2num(str); > > Error in ==> fieldtrip-20060725\private\read_data at 239 > dat = read_brainvision_eeg(filename, hdr, begsample, endsample); Hi Stephan, I have no idea how time-frequency data is stored in the BVA *.dat files. Even if the low-level reading function were to support it, the PREPROCESSING function at least would not be able to deal with it, since the data structure returned by preprocessing does not allow for 3D data (channelXtimeXfrequency). That type of data would have to be stored in a structure that is compatible with the output of FREQANALYSIS. The preprocessing function is made for raw continuous (or trial-based) data, and it happens to work as well for averaged ERP data, although it is not specifically made for that. For other external software (BESA, EEGLAB, LORETA) I have created xxx2fieldtrip functions, i.e. functions that import already processed data and format it into the fieldtrip structure that is most compatible with it. In this case I can imagine a BRAINVISION2FIELDTRIP function that would read your dat file and return a "freq" structure. Besides making a brainvision2fieldtrip function, it requires making either the read_brainvision_eeg smarter (or probably making a seperate read_brainvision_tfr function) and improving the detection of teh content of the BVA *.dat file. Please have a look in besa2fieldtrip to see how I approach it there. best regards, Robert From jciveira at UNAV.ES Thu Jul 27 18:54:27 2006 From: jciveira at UNAV.ES (Juan Civeira) Date: Thu, 27 Jul 2006 18:54:27 +0200 Subject: Source anaylsis In-Reply-To: <9A0AA0F8-A8AD-4958-B224-4E3547238053@FCDONDERS.RU.NL> Message-ID: Dear Robert: Thanks for your answer but my problems are still there. The main problem is that i can not use DICS with a reference channel on EEG data, no matter if the reference is an EEG channel or EMG or some other channel. I have taken my measures with 85 electrodes, some of them are EEG1010, some EOG and some other that I have placed myself. I do the freq analysis and then the source analysis. Then I can make another source analysis with refdip but there is always errors when I use refchan. I do not think is a problem of the reference , cos always the program says that the cross-spectral-density with the reference channel is not complete . I have done the freq analysis making cfg.channelcmb combinations of all channels with only one, so i make sure that the cross-spectral-density is complete,but when I make source analysis with that channel as a reference is the same. Searching in the code I have come up with the fact that the error is always the condition in line 195 of the function prepare_freq_matrices (version 2006/03/08). My idea is that there is a confussion because if we have a set of N channels and we make combinations with channelcombination, the result is N-1 combinations because we do not include the combination of the reference with itself. I hope i explain myself clear enough, anyway I am trying to fix the problem by myself but any help or suggestion will be great Juan Robert Oostenveld ha escrito: > On 25 Jul 2006, at 14:22, jciveira at unav.es wrote: >> I have the same problem and I do not know how to fix it, even >> though I tried your solution with cfg.channelcmb. >> >> My case is : i have a set of 82 electrodes, I make freqanalysis >> with cfg.channelcmb = channelcombination({'all' 'all'},data.label); >> thus I get >> >> freq = >> >> label: {82x1 cell} >> dimord: 'chan_freq' >> freq: [14 14.4000 14.8000 15.2000 15.6000 16 16.4000 >> 16.8000 17.2000 17.6000 18] >> powspctrm: [82x11 double] >> labelcmb: {3321x2 cell} >> crsspctrm: [3321x11 double] >> cfg: [1x1 struct] >> >> When I make sourceanalysis with a dipole as a reference and I have >> no problems but when I want to use a channel as a reference I >> always have the same error: >> The cross-spectral-density matrix is not complete. >> >> Can you help me? >> >> Best regards >> Juan > > Dear Juan > > Do you have 82 EEG electrodes, or 81 and one EMG electrode? I would > expect the latter, since computing coherence between one particular EEG > electrode and sources in the brain with DICS will not lead to > meaningfull results. The selected EEG electrode will pick up > volume-conducted activity from all sources in the brain (as opposed to > an EMG electrode) and would be referenced to the same reference > electrode as all other electrodes. So there will be a huge amount of > trivial coherence, whose spatial distribution in the brain will > probably more reflect the volume-conduction than something > physiologically interpretable. > > Although I have not used DICS with a reference channel on EEG data, I > would expect the code to work if you follow a procedure like this: > > cfg = ... trial selection stuff > cfg = definetrial(cfg) > cfg = ... preprocessing stuff > cfg.channel = list of all EEG electrodes > cfg.implicitref = name of implicit reference electrode used for the EEG > channels > cfg.reref = 'all' % rereference all EEG electrodes to an average reference > data_eeg = preprocessing(cfg) > > cfg = ... trial selection stuff > cfg = definetrial(cfg) > cfg = ... preprocessing stuff > cfg.channel = list of all EMG electrodes, assuming that they are > bipolar channels > % cfg.reref may be used if you have two unipolar channels on the muscle > of interest > cfg.rectify = 'yes' % this makes the spiky nature of the EMG more > visible, and improves the coherence estimate > cfg.baseline = 'yes' % remove baseline prior to rectification, not > neccessary but still preferable > data_emg = preprocessing(cfg) > > % combine EEG and EMG in one dataset, both are referenced differently > data = appenddata([], data_eeg, data_emg); > > cfg = ... frequency analysis stuff > cfg.ouptu = 'powandcsd' > cfg.channelcmb = {'all', 'all'} > freq = freqanalysis(cfg, data); > > cfg = ... source specific settings > cfg.refchan = one of your bipolar EMG channels > cfg.channel = all your EEG channels > source = sourceanalysis(cfg, freq) > > best regards, > Robert ---------------------------------------------------------------- Este mensaje ha sido enviado desde https://webmail.unav.es From r.oostenveld at FCDONDERS.RU.NL Fri Jul 28 09:49:55 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 28 Jul 2006 09:49:55 +0200 Subject: Source anaylsis In-Reply-To: <20060727185427.3r2gdy6zkk0o4og8@webmail.unav.es> Message-ID: Hi Juan > I do the freq analysis and then the source analysis. Then I can > make another source analysis with refdip but there is always errors > when I use refchan. I do not think is a problem of the reference , > cos always the program says that the cross-spectral-density with > the reference channel is not complete . > > I have done the freq analysis making cfg.channelcmb combinations of > all channels with only one, so i make sure that the > cross-spectral-density is complete,but when I make source analysis > with that channel as a reference is the same. > > Searching in the code I have come up with the fact that the error > is always the condition in line 195 of the function > prepare_freq_matrices (version 2006/03/08). My idea is that there is > a confussion because if we have a set of N channels and we make > combinations with channelcombination, the result is N-1 > combinations because we do not include the combination of the > reference with itself. Say for simplicity that you want EMG as refchan. In freqanalysis, cfg.channelcmb should be all with all. You need the CSD between all EEG channels (all EEG with all EEG), and of all EEG channels with the EMG. In prepare_freq_matrices the CSD matrix (Cf) of EEG with EEG is made (Neeg X Neeg), the CSD vector (Cr) of all EEG channels with the reference EMG channel (Neeg X 1), and the power of the reference channel (Pr). Together they could also be shaped in a (Neeg+1) X (Neeg +1) matrix in principle, but that is not done for DICS. I have tried it out myself, and cannot reproduce your problem. Please find my test script below. It uses some simulated EEG data. The beginning of the script is copied from http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? id=fieldtrip:documentation:compute_forward_simulated_data_and_apply_a_di pole_fit The initial part generates raw EEG data, then I add a EMG channel (with noise, but it is only to demonstrate that fieldtrip does not give an error), then I do freqanalysis and sourceanalysis. Please try out and compare my cfgs with yours, since I suspect your configuration to be the problem. best regards, Robert %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % create a set of electrodes, randomly placed on the sphere elec = []; elec.pnt = randn(128,3); dum = sqrt(sum(elec.pnt.^2,2)); elec.pnt = elec.pnt ./ [dum dum dum]; % scale them to a unit sphere for i=1:128 elec.label{i} = sprintf('%03d', i); end % create a concentric 3-sphere volume conductor, the radius is the same as for the electrodes vol = []; vol.r = [0.88 0.92 1.00]; % radii of spheres vol.c = [1 1/80 1]; % conductivity vol.o = [0 0 0]; % center of sphere % create a dipole simulation with one dipole and a 10Hz sine wave cfg = []; cfg.vol = vol; % see above cfg.elec = elec; % see above cfg.dip.pos = [0 0.5 0.3]; cfg.dip.mom = [1 0 0]'; % note, it should be transposed cfg.dip.frequency = 10; cfg.ntrials = 10; cfg.triallength = 1; % seconds cfg.fsample = 250; % Hz raw1 = dipolesimulation(cfg); using headmodel specified in the configuration using electrodes specified in the configuration selected 128 electrodes computing simulated data RMS value of simulated data is 0.0746553 %%%%%%%%%%%%%%%%%%%%%%%% %%%%% Here it starts deviating from the demo script on the wiki %%%% %%%%%%%%%%%%%%%%%%%%%%%% % add a fake EMG channel, containing noise for i=1:10 raw1.trial{i}(end+1,:) = randn(1,250); end raw1.label{end+1} = 'EMG' raw1 = trial: {1x10 cell} time: {1x10 cell} elec: [1x1 struct] fsample: 250 label: {1x129 cell} cfg: [1x1 struct] cfg = [] cfg.method = 'mtmfft'; cfg.taper = 'hanning'; cfg.foilim = [2 20]; cfg.output = 'powandcsd'; cfg.channelcmb = {'all', 'all'} cfg = method: 'mtmfft' taper: 'hanning' foilim: [2 20] output: 'powandcsd' channelcmb: {'all' 'all'} freq1 = freqanalysis(cfg, raw1) WARNING: using only one taper for specified smoothing processing trial 1, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 2, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 3, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 4, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 5, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 6, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 7, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 8, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 9, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 10, nfft: 250 samples, taper length: 250 samples, 1 tapers freq1 = label: {1x129 cell} dimord: 'chan_freq' freq: [2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20] powspctrm: [129x19 double] labelcmb: {8256x2 cell} crsspctrm: [8256x19 double] elec: [1x1 struct] cfg: [1x1 struct] cfg = []; cfg.vol = vol; cfg.freq = 10; cfg.frequency = 10; cfg.method = 'dics'; cfg.refchan = 'EMG'; cfg.grid.resolution = 0.3 cfg = vol: [1x1 struct] freq: 10 frequency: 10 method: 'dics' refchan: 'EMG' grid: [1x1 struct] source1 = sourceanalysis(cfg, freq1) using headmodel specified in the configuration using electrodes specified in the data selected 128 electrodes 106 dipoles inside, 237 dipoles outside brain making tight grid 106 dipoles inside, 110 dipoles outside brain scanning repetition 1 scanning grid Warning: cross-spectral density matrix is rank deficient > In beamformer at 270 In sourceanalysis at 806 total time in sourceanalysis 75.4 seconds source1 = xgrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000] ygrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000] zgrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000] dim: [6 6 6] vol: [1x1 struct] frequency: 10 pos: [216x3 double] inside: [1x106 double] outside: [1x110 double] method: 'average' avg: [1x1 struct] cfg: [1x1 struct] diary off From floris.delange at FCDONDERS.RU.NL Fri Jul 28 13:01:00 2006 From: floris.delange at FCDONDERS.RU.NL (Floris de Lange) Date: Fri, 28 Jul 2006 13:01:00 +0200 Subject: sourcestatistics: what to compare? Message-ID: Dear Fieldtrippers, I have a question about what conditions/comparisons make most sense to statistically compare with sourcestatistics. I have 2 conditions, A and B, and each condtion has its own pre-stimulus baseline: basA and basB. Now, first I'd like to see which regions are showing stronger beta-band power during A than the baseline. So I want to compare A to basA. There's 2 ways of going about it: 1) compare (the grand average of) A.avg.pow with basA.avg.pow 2) compare (the grand average of) the neural activity index (NAI) of A with the baseline Any ideas which would be best? Or is this just an empirical issue? (i.e., take the best) To compare A and B, one has even more options: 1) compare A.avg.pow with B.avg.pow 2) compare (A.avg.pow/basA.avg.pow) with (B.avg.pow/basB.avg.pow) 3) compare NAI(A) with NAI(B) 4) compare NAI(A)/NAI(basA) with NAI(B)/NAI(basB) Is there's any principled reason for a priori picking any of the above choices? Your input is greatly appreciated, Kind regards, Floris From r.oostenveld at FCDONDERS.RU.NL Fri Jul 28 16:17:24 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 28 Jul 2006 16:17:24 +0200 Subject: sourcestatistics: what to compare? In-Reply-To: <44C9EE6C.8030003@fcdonders.ru.nl> Message-ID: Hi Floris On 28 Jul 2006, at 13:01, Floris de Lange wrote: > I have a question about what conditions/comparisons make most sense > to statistically compare with sourcestatistics. > I have 2 conditions, A and B, and each condtion has its own pre- > stimulus baseline: basA and basB. > > Now, first I'd like to see which regions are showing stronger beta- > band power during A than the baseline. So I want to compare A to > basA. There's 2 ways of going about it: > 1) compare (the grand average of) A.avg.pow with basA.avg.pow > 2) compare (the grand average of) the neural activity index (NAI) > of A with the baseline > > Any ideas which would be best? Or is this just an empirical issue? > (i.e., take the best) Both are valid, you could take the best. There are some exceptions/ predictions though that I can share with you: the NAI is power divided by estimated (projected) noise. It is inherently difficult to estimate the noise level (the default is the smallest singular value of the CSD matrix, but you can manipulate it with cfg.lambda in sourceanalysis). If you have different numbers of trials in active v.s. baseline, the noise estimate probably will be different. So then you would have NAIa = Pa/Na and NAIb = Pb/Nb, if Pa==Pb and Na~=Nb, these will be trivially different, which is not what you want (remember Pa==Pb was assumed). You can compare the projected noise in both conditions, the source- noise-estimate is uniformely scaled (i.e. on all voxels the same) with the estimated noise from the CSD. There is no reason to assume that the noise is different, so if the noise is different, you would have to explain that. > To compare A and B, one has even more options: > 1) compare A.avg.pow with B.avg.pow > 2) compare (A.avg.pow/basA.avg.pow) with (B.avg.pow/basB.avg.pow) > 3) compare NAI(A) with NAI(B) > 4) compare NAI(A)/NAI(basA) with NAI(B)/NAI(basB) > > Is there's any principled reason for a priori picking any of the > above choices? I presume that by "compare" you mean "look at the the difference". In general you should only use the NAI for plotting data if you only have one condition (and no baseline). The noise estimate that goes into the NAI is too poor to be of real value. Although sometines it looks nice in figures, the NAI tends not to be very robust (it contains global flucuations that mess up the statistic, although the figure still looks nice). The baseline is only interesting if you expect something differently to happen in the two baselines. If that is the case, you better try to get another baseline in your experimental design. If you would combine actA, basA, actB, basB into a single number, and that number would be significant, you still would not be able to tell whether the difference is betwen the active conditions, theis baselines, or some weird combination of the 4 "conditions" that you combine. Typically there is no reason to assume taht the baselines are different. So (A.avg.pow/basA.avg.pow) with (B.avg.pow/basB.avg.pow) = (A.avg.pow/basC.avg.pow) with (B.avg.pow/basC.avg.pow), where C means common = (A.avg.pow-B.avg.pow)/basC.avg.pow. I.e. you are comparing A and B directly, with a spatially normalizing for the different baseline-estimated noise at different source locations. Whether you want to spatially normalize (divide by some baseline estimated-source-power) depends on the leadfields (it is neccessary if cfg.normalize=no, if you want to do multiple comparison correction, and if you want to look at an additive effect). If you want to look at a multiplicative effect, you would look at the ratio between two conditions instead of the difference. The ratio of the conditions is best implemented with a log transform, after which you again can look at the difference between the log-transformed power estimates in both conditions (log(A/B) = log(A) - log(B)). In the ratio or log-ratio between the powers in both conditions you have also corrected for the spatial (depth) noise-bias. good luck with the stats, Robert PS as I am on holiday the next 2 weeks, you could ask Ingrid about more details on this. She is more or less at the same stage in her analysis (about to do group sourcestatistics), but I suspect that she already has more "feel" for these issues. Or ask JM. From d.vanbarneveld at STUDENT.SCIENCE.RU.NL Thu Jul 6 16:58:40 2006 From: d.vanbarneveld at STUDENT.SCIENCE.RU.NL (Denise van Barneveld) Date: Thu, 6 Jul 2006 16:58:40 +0200 Subject: problem with text in topoplot and triplot Message-ID: Dear all, since I started using the new version of Matlab (R2006a) on a mac, I have this problem with text in the figures which I generate with topoplot.m and triplot.m. The upper half of the text lines (title, colorbar, electrodes, etc) is not visible (see attached figure). Does anyone have this problem too? Especially people who are using this new version on a pc. And does anyone perhaps has a solution for this problem? I am currently looking in the code, if I can find where it goes wrong, but I wonder whether it is a problem only with the new version, or only at a mac, or only at my computer. Best regards, Denise van Barneveld -------------- next part -------------- A non-text attachment was scrubbed... Name: topo.jpg Type: application/applefile Size: 48798 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: topo.jpg Type: image/jpeg Size: 85086 bytes Desc: not available URL: From muthuraman10 at HOTMAIL.COM Fri Jul 7 12:04:26 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Fri, 7 Jul 2006 10:04:26 +0000 Subject: query on confidence limit, DICS In-Reply-To: <37FAA4DD-5DD8-4F2F-ABA6-D9F47F6AB95E@fcdonders.ru.nl> Message-ID: Hello As i am able to sucessfully use the coherence analysis using freq_mtmfft and frq_mtmwelch to calculate the coherence i would like to know is there a way to calculate the confidence limit for the coherence calculated from the freqanalysis, is there a standard code Next, i would like to follow with the source analysis 'DICS' is there a tutorial available thanking you with regards Muthuraman >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] query on CTF software!!! >Date: Fri, 23 Jun 2006 15:23:22 +0200 > >dear Muthuraman > >On 23 Jun 2006, at 12:54, Muthuraman Muthuraman wrote: >>For the Beamformer source analysis, do we need the CTF software >>because when i am trying out the tutorial in beamforming > >You do not need the ctf software to follow the tutorial. The tutorial is >based however on a ctf MEG dataset. > >>CTF_READ_RES4 [v 1.12] >>....done ( 0.67 sec) >> >>i get the error >> >>??? Error using ==> read_fcdc_header >>could not read CTF res4 header file >> >>Error in ==> preprocessing at 263 >>hdr = read_fcdc_header(cfg.headerfile); > >Based on your error I suspect that matlab/fieldtrip cannot find the >dataset that you are trying to analyze, or that you matlab path is >incorrect. The function "CTF_READ_RES4" is not supposed to be called (it >is part of the NIH ctf import routines, e.g. used in EEGLAB), since the >default private/read_ctf_res4.m function can deal with the tutorial >dataset just fine. Please look into the code of read_fcdc_header (using >the matlab debugger) to figure out what your exact problem is. > >best >Robert From r.oostenveld at FCDONDERS.RU.NL Fri Jul 7 12:36:02 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 7 Jul 2006 12:36:02 +0200 Subject: query on confidence limit, DICS In-Reply-To: Message-ID: On 7 Jul 2006, at 12:04, Muthuraman Muthuraman wrote: > As i am able to sucessfully use the coherence analysis using > freq_mtmfft and frq_mtmwelch to calculate the coherence > i would like to know is there a way to calculate the confidence > limit for the coherence calculated from the freqanalysis, is there > a standard code You can compute a jackknife estimate of the variance in the coherence using the freqdescriptives function. That requires keeptrials=yes in freqanalysis. > Next, i would like to follow with the source analysis 'DICS' is > there a tutorial available No there is no tutorial available specifically for that. You can look at the beamformer tutorial at http://www2.ru.nl/fcdonders/fieldtrip/ doku.php?id=fieldtrip:documentation:tutorial:beamformer, the relevant options are cfg.method=dics, cfg.refchan and/or cfg.refdip. Robert From j.poort at NIN.KNAW.NL Tue Jul 11 11:43:49 2006 From: j.poort at NIN.KNAW.NL (Jasper Poort) Date: Tue, 11 Jul 2006 11:43:49 +0200 Subject: Confidence intervals for evoked potentials Message-ID: Hi all, I have some questions regarding confidence intervals for timelocked data in FieldTrip. I noted that a field .var is returned by timelockanalysis line 510 timelockanalysis % compute the variance tmp1 = repmat(dofvec(:)', [nchan 1]); tmp2 = repmat(dofvec(:)', [nchan 1])-1; var = (ss - (s.^2)./tmp1) ./ tmp2; Assuming that the sampling distribution is normal I can presumably use this field for computation of confidence intervals of the .avg field? Is nonparametric estimation of variance using a bootstrap or jackknife also implemented somewhere? In general I'm just curious to know how others compute confidence intervals for evoked potentials in FieldTrip, for example to get an idea at what point in time two conditions start to differ, best regards, Jasper -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.oostenveld at FCDONDERS.RU.NL Tue Jul 11 15:50:09 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 11 Jul 2006 15:50:09 +0200 Subject: Confidence intervals for evoked potentials In-Reply-To: <017d01c6a4ce$835853e0$910b57c0@ABSYS> Message-ID: Hi Jasper, On 11 Jul 2006, at 11:43, Jasper Poort wrote: > Hi all, I have some questions regarding confidence intervals for > timelocked data in FieldTrip. I noted that a field .var is returned > by timelockanalysis > > line 510 timelockanalysis > % compute the variance > tmp1 = repmat(dofvec(:)', [nchan 1]); > tmp2 = repmat(dofvec(:)', [nchan 1])-1; > var = (ss - (s.^2)./tmp1) ./ tmp2; > > Assuming that the sampling distribution is normal I can presumably > use this field for computation of confidence intervals of the .avg > field? Yes, you can use it to compute the channel-timepoint specific standard-error of mean (SEM). > Is nonparametric estimation of variance using a bootstrap or > jackknife also implemented somewhere? In general I'm just curious > to know how others compute confidence intervals for evoked > potentials in FieldTrip, for example to get an idea at what point > in time two conditions start to differ, Bootstrap and jackknife estimates of variance are only different from teh normal variance estimate if the measure involves a nonlinear or biased estimate (i.e. coherence). The jackknife estimate of variance of the ERP is exactly the same as the normal estimate of variance, since the ERP is a plain (linear) average. The same holds for bootstrap estimates. So that means that for ERPs the jackknife and bootstrap only would be a computationally expensive methods, resulting in the same variance as usual. Therefore they are not implemented. best regards, Robert From muthuraman10 at HOTMAIL.COM Tue Jul 11 16:59:58 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Tue, 11 Jul 2006 14:59:58 +0000 Subject: DICS In-Reply-To: Message-ID: Hello Thanks for the suggestion to use the jackknife variance estimate it works thanks a lot To use the DICS method We have a 64 channel EEG measurement from (Neuroscan) and 4 EMG channels recording and also we have the 64 channel measurement in FRMI the electrode locations we have it in a file with 3 columns x,y,z for each electrode using the polhemus sensors but our own software In the Source analysis Cfg.method='DICS'; but Cfg.xgrid, ygrid and zgrid the grid values are the sensor location values or it should be the cfg.grid.pos-where i can give in the 3 values [x y z] for each electrode I am a starter in the source analysis in combining EEG-FMRI please let me know with regards muthuraman. >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] query on confidence limit, DICS >Date: Fri, 7 Jul 2006 12:36:02 +0200 > >On 7 Jul 2006, at 12:04, Muthuraman Muthuraman wrote: >>As i am able to sucessfully use the coherence analysis using freq_mtmfft >>and frq_mtmwelch to calculate the coherence >>i would like to know is there a way to calculate the confidence limit for >>the coherence calculated from the freqanalysis, is there a standard code > >You can compute a jackknife estimate of the variance in the coherence >using the freqdescriptives function. That requires keeptrials=yes in >freqanalysis. > >>Next, i would like to follow with the source analysis 'DICS' is there a >>tutorial available > >No there is no tutorial available specifically for that. You can look at >the beamformer tutorial at http://www2.ru.nl/fcdonders/fieldtrip/ >doku.php?id=fieldtrip:documentation:tutorial:beamformer, the relevant >options are cfg.method=dics, cfg.refchan and/or cfg.refdip. > >Robert From r.oostenveld at FCDONDERS.RU.NL Tue Jul 11 17:51:28 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 11 Jul 2006 17:51:28 +0200 Subject: DICS In-Reply-To: Message-ID: Dear Muthuraman On 11 Jul 2006, at 16:59, Muthuraman Muthuraman wrote: > To use the DICS method > > We have a 64 channel EEG measurement from (Neuroscan) and 4 EMG > channels recording > and also we have the 64 channel measurement in FRMI > > the electrode locations we have it in a file with 3 columns x,y,z > for each electrode > using the polhemus sensors but our own software > > In the Source analysis > Cfg.method='DICS'; > but Cfg.xgrid, ygrid and zgrid > the grid values are the sensor location values > > or it should be the > cfg.grid.pos-where i can give in the 3 values [x y z] for each > electrode in SOURCEANALYSIS you specify using cfg.xgrid/ygrid/zgrid the locations at which the _dipoles_ will be placed, it is not the position of the electrodes. At each grid location a spatial filter is constructed and the power (and coherence) is computed. If you do not want to scan on a full 3-D grid, but on only a few dipole locations of interest, you can use cfg.grid.pos to specify those dipole locations. The electrode positions are specified in the cfg.elec structure, or in the cfg.elecfile filename. You can find more details on the definition of electrode positions at http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? id=fieldtrip:documentation:frequently_asked_questions#how_are_electrodes _magnetometers_or_gradiometers_described Furthermore, you can try using the READ_FCDC_ELEC function for reading the electrode locations, but probably taht will not work since youy are using your own software for digitization. Alternatively, you can manually construct an "elec" electrode definition. best regards Robert PS please upgrade to a recent fieldtrip version, the sourceanalysis options cfg.xgrid/ygrid/zgrid have been renamed. The old options still will work, but in general it is preferable to work with a recent copy of the toolbox. From muthuraman10 at HOTMAIL.COM Thu Jul 13 13:11:35 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Thu, 13 Jul 2006 11:11:35 +0000 Subject: DICS In-Reply-To: <43B3E5A4-716B-48A0-8CE0-5F8810DC4A65@fcdonders.ru.nl> Message-ID: Hello Thankyou for the suggestions I have dowloaded the latest version now and i am working with it i have created the own elec file which is "elec1" and these are the steps i follow please go through it and reply me, why is the error -First i calculate the coherence using the freqanalysis and freqdescriptives which works perfectly -Second i calculate the Grid using Prepare_leadfield vol = []; vol.r = 12 * [0.88 0.92 1.00]; vol.c = [1 1/80 1]; vol.o = [0 0 0]; >>cfg1 = []; cfg1.elec = elec1; cfg1.vol = vol; cfg1.resolution = 2; grid = prepare_leadfield(cfg1); which also works i get the output for the Grid -Third I want use the source analysis for the DICS cfg.method='dics'; cfg.grid=grid; cfg.elecfile=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmfft); using headmodel specified in the configuration ??? Error using ==> fprintf Function is not defined for 'struct' inputs. Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 310 fprintf('reading electrodes from file %s\n', cfg.elecfile); Error in ==> sourceanalysis at 574 [vol, sens, cfg] = prepare_vol_sens(cfg, data); -I also tried grid using the freqmtmfft-which as the results for the freqanalysis vol = []; vol.r = 12 * [0.88 0.92 1.00]; vol.c = [1 1/80 1]; vol.o = [0 0 0]; >>cfg1 = []; cfg1.elec = elec1; cfg1.vol = vol; cfg1.resolution = 2; grid = prepare_leadfield(cfg1,freqmtmfft); I get error using headmodel specified in the configuration using electrodes specified in the configuration ??? Error using ==> delaunayn Not enough unique points to do tessellation. Error in ==> delaunay at 49 tri = delaunayn([x(:) y(:)]); Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 330 elec.tri = delaunay(elec.prj(:,1), elec.prj(:,2)); Error in ==> prepare_leadfield at 179 [vol, sens, cfg] = prepare_vol_sens(cfg, data); Thanking you with regards Muthuraman. >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] DICS >Date: Tue, 11 Jul 2006 17:51:28 +0200 > >Dear Muthuraman > >On 11 Jul 2006, at 16:59, Muthuraman Muthuraman wrote: >>To use the DICS method >> >>We have a 64 channel EEG measurement from (Neuroscan) and 4 EMG channels >>recording >>and also we have the 64 channel measurement in FRMI >> >>the electrode locations we have it in a file with 3 columns x,y,z for >>each electrode >>using the polhemus sensors but our own software >> >>In the Source analysis >>Cfg.method='DICS'; >>but Cfg.xgrid, ygrid and zgrid >>the grid values are the sensor location values >> >>or it should be the >>cfg.grid.pos-where i can give in the 3 values [x y z] for each electrode > >in SOURCEANALYSIS you specify using cfg.xgrid/ygrid/zgrid the locations at >which the _dipoles_ will be placed, it is not the position of the >electrodes. At each grid location a spatial filter is constructed and the >power (and coherence) is computed. If you do not want to scan on a full >3-D grid, but on only a few dipole locations of interest, you can use >cfg.grid.pos to specify those dipole locations. > >The electrode positions are specified in the cfg.elec structure, or in the >cfg.elecfile filename. You can find more details on the definition of >electrode positions at http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? >id=fieldtrip:documentation:frequently_asked_questions#how_are_electrodes >_magnetometers_or_gradiometers_described > >Furthermore, you can try using the READ_FCDC_ELEC function for reading the >electrode locations, but probably taht will not work since youy are using >your own software for digitization. Alternatively, you can manually >construct an "elec" electrode definition. > >best regards >Robert > >PS please upgrade to a recent fieldtrip version, the sourceanalysis >options cfg.xgrid/ygrid/zgrid have been renamed. The old options still >will work, but in general it is preferable to work with a recent copy of >the toolbox. From r.oostenveld at FCDONDERS.RU.NL Fri Jul 14 11:37:47 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 14 Jul 2006 11:37:47 +0200 Subject: DICS In-Reply-To: Message-ID: On 13 Jul 2006, at 13:11, Muthuraman Muthuraman wrote: > cfg.method='dics'; > cfg.grid=grid; > cfg.elecfile=elec1; > cfg.vol=vol; > [source]=sourceanalysis(cfg,freqmtmfft); > using headmodel specified in the configuration > ??? Error using ==> fprintf > Function is not defined for 'struct' inputs. > > Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 310 > fprintf('reading electrodes from file %s\n', cfg.elecfile); You should specify either cfg.elecfile with a string (filename) or cfg.elec with a structure (i.e. cfg.elec.pnt and cfg.elec.label) > I get error > > using headmodel specified in the configuration > using electrodes specified in the configuration > ??? Error using ==> delaunayn > Not enough unique points to do tessellation. > > Error in ==> delaunay at 49 > tri = delaunayn([x(:) y(:)]); > > Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 330 > elec.tri = delaunay(elec.prj(:,1), elec.prj(:,2)); > > Error in ==> prepare_leadfield at 179 > [vol, sens, cfg] = prepare_vol_sens(cfg, data); That indicates that less than 3 electrodes were selected. Probably there is a mismatch between the channel names in the data and the names of the electrodes. FT selects the channels and electrodes based on the corresponding labels, if they do not correspond then no channels+electrodes are selected. Robert From muthuraman10 at HOTMAIL.COM Mon Jul 17 16:12:14 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Mon, 17 Jul 2006 14:12:14 +0000 Subject: DICS In-Reply-To: <242E1EA4-D9FE-42D8-B23A-B689CBBF7FA8@fcdonders.ru.nl> Message-ID: Hello Thankyou for pointing out errors now i am able to calculate the Grid values but when i wanted to use the source analysis for the freqmtmwelch cfg.frequency=5; cfg.refchannel='C1'; cfg.refdip=10; cfg.method='dics'; cfg.grid=grid; cfg.elec=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmwelch); using headmodel specified in the configuration using electrodes specified in the configuration 42 dipoles inside, 18 dipoles outside brain I get the error ??? Reference to non-existent field 'cumtapcnt'. Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 Ntrials = length(freq.cumtapcnt); Error in ==> sourceanalysis at 663 [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); when i use the mtmfft i get the cumtapcnt values but not when using the mtmwelch is this a problem in the mtmwelch or i am doing something wrong Please go through it thanking you with regards muthuraman >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] DICS >Date: Fri, 14 Jul 2006 11:37:47 +0200 > >On 13 Jul 2006, at 13:11, Muthuraman Muthuraman wrote: > >>cfg.method='dics'; >>cfg.grid=grid; >>cfg.elecfile=elec1; >>cfg.vol=vol; >>[source]=sourceanalysis(cfg,freqmtmfft); >>using headmodel specified in the configuration >>??? Error using ==> fprintf >>Function is not defined for 'struct' inputs. >> >>Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 310 >> fprintf('reading electrodes from file %s\n', cfg.elecfile); > >You should specify either cfg.elecfile with a string (filename) or >cfg.elec with a structure (i.e. cfg.elec.pnt and cfg.elec.label) > >>I get error >> >>using headmodel specified in the configuration >>using electrodes specified in the configuration >>??? Error using ==> delaunayn >>Not enough unique points to do tessellation. >> >>Error in ==> delaunay at 49 >> tri = delaunayn([x(:) y(:)]); >> >>Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 330 >> elec.tri = delaunay(elec.prj(:,1), elec.prj(:,2)); >> >>Error in ==> prepare_leadfield at 179 >>[vol, sens, cfg] = prepare_vol_sens(cfg, data); > >That indicates that less than 3 electrodes were selected. Probably there >is a mismatch between the channel names in the data and the names of the >electrodes. FT selects the channels and electrodes based on the >corresponding labels, if they do not correspond then no >channels+electrodes are selected. > >Robert From floris.delange at FCDONDERS.RU.NL Tue Jul 25 10:24:18 2006 From: floris.delange at FCDONDERS.RU.NL (Floris de Lange) Date: Tue, 25 Jul 2006 10:24:18 +0200 Subject: sourcestatistics question Message-ID: Dear FieldTrippers, I have a question concerning sourcestatistics. I have calculated the source localization using DICS for 11 individual subjects. Now I would like to test for the significance of the sources using sourcestatistics. The examples I find in the tutorial are about checking for significance within one subject by shuffling the individual trials. However, what I would like to do is to do the statistics on the 2nd level (subject), and to test for the consistency of the source reconstructions across subjects. Is this possible with sourcestatistics? If so, how should I feed the data to sourcestatistics? If I say something like stats = sourcestatistics(cfg,sources{1:11}) where each source{} is a normalized source (calculated by sourceanalysis, normalized with sourceinterpolate), it complains (rightfully) that there's a reference to the non-existing field 'statistic'. Any ideas are greatly appreciated! Kind regards, Floris From muthuraman10 at HOTMAIL.COM Tue Jul 25 10:34:30 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Tue, 25 Jul 2006 08:34:30 +0000 Subject: Source anaylsis In-Reply-To: <242E1EA4-D9FE-42D8-B23A-B689CBBF7FA8@fcdonders.ru.nl> Message-ID: Hello Thankyou for pointing out errors now i am able to calculate the Grid values but when i wanted to use the source analysis for the freqmtmwelch cfg.frequency=5; cfg.refchannel='C1'; cfg.refdip=10; cfg.method='dics'; cfg.grid=grid; cfg.elec=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmwelch); using headmodel specified in the configuration using electrodes specified in the configuration 42 dipoles inside, 18 dipoles outside brain I get the error ??? Reference to non-existent field 'cumtapcnt'. Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 Ntrials = length(freq.cumtapcnt); Error in ==> sourceanalysis at 663 [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); when i use the mtmfft i get the cumtapcnt values i get a error when using the mtmfft for source analysis cfg.frequency=5; cfg.refchannel='C1'; cfg.refdip=10; cfg.method='dics'; cfg.grid=grid; cfg.elec=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmfft); using headmodel specified in the configuration using electrodes specified in the configuration 610 dipoles inside, 600 dipoles outside brain ??? Error using ==> fieldtrip-20060712\private\prepare_freq_matrices The cross-spectral-density matrix is not complete Error in ==> sourceanalysis at 663 [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); Please go through it Because for the DICS i would like to use the freqmtmwelch is this a problem with freqmtmwelch or something wrong in my inputs thanking you with regards muthuraman From r.oostenveld at FCDONDERS.RU.NL Tue Jul 25 12:18:48 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 25 Jul 2006 12:18:48 +0200 Subject: DICS In-Reply-To: Message-ID: Hi Muthuraman The cumulative number of tapers per trial is indeed not kept in mtmwelch. You should specify it manually prior to freqanalysis. I do not recall whether you use keeptrials and keeptapers but if not, then it is safe to specify freq.cumtapcnt=1. Keeping count of the number of trials and tapers in the various freqanalysis methods is not done consistenly, it is something that we will improve in the future. best regards, Robert On 17 Jul 2006, at 16:12, Muthuraman Muthuraman wrote: > I get the error > > ??? Reference to non-existent field 'cumtapcnt'. > > Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 > Ntrials = length(freq.cumtapcnt); > > Error in ==> sourceanalysis at 663 > [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); > > when i use the mtmfft i get the cumtapcnt values > but not when using the mtmwelch is this a problem in the mtmwelch > or i am doing something wrong From r.oostenveld at FCDONDERS.RU.NL Tue Jul 25 12:29:23 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 25 Jul 2006 12:29:23 +0200 Subject: sourcestatistics question In-Reply-To: <44C5D532.4020708@fcdonders.ru.nl> Message-ID: Hi Floris, On 25 Jul 2006, at 10:24, Floris de Lange wrote: > I have a question concerning sourcestatistics. > I have calculated the source localization using DICS for 11 > individual subjects. Now I would like to test for the significance > of the sources using sourcestatistics. The examples I find in the > tutorial are about checking for significance within one subject by > shuffling the individual trials. However, what I would like to do > is to do the statistics on the 2nd level (subject), and to test for > the consistency of the source reconstructions across subjects. > Is this possible with sourcestatistics? Yes, that is possible. > If so, how should I feed the data to sourcestatistics? If I say > something like stats = sourcestatistics(cfg,sources{1:11}) where > each source{} is a normalized source (calculated by sourceanalysis, > normalized with sourceinterpolate), it complains (rightfully) that > there's a reference to the non-existing field 'statistic'. Assuming you want to use a randomization test to get a Monte-Carlo estimate of the probability of your null-hypothesis (cfg.method='montecarlo'), cfg.statistic should be a string describing the statistic whose randomization distribution you want to compute. See the help of statistic_montecarlo. Furthermore, the hypothesis that you want to test is about two conditions. That means that the two conditions both should be fed into sourcestatistics, e.g. something like for i=1:11 read data from condition 1 for each subject cond1{i} = sourceanalysis(...) cond1{i} = sourceinterpolate(...) cond1{i} = volumenormalize(...) read data from condition 2 for each subject cond2{i} = sourceanalysis(...) cond2{i} = sourceinterpolate(...) cond2{i} = volumenormalize(...) end cfg = [] cfg.design = [1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 % condition number 1 2 3 4 5 ..... 1 2 3 4 5 .... ] % subject number cfg.method = 'montecarlo' cfg.statistic = 'depsamplesT' cfg.ivar = 1; % row with the independent variable (condition) in the design cfg.uvar = 2; % row with the unit of observation (subject) in the design matrix stat = sourcestatistics(cfg, cond1{:}, cond2{:}); It is also possible to do other tests, which are more in line with a 2nd level analysis (e.g. compute t-maps per subject and test over subjects). It is better to discuss those face-to-face. best regards, Robert From Jan.Schoffelen at FCDONDERS.RU.NL Tue Jul 25 12:32:38 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Tue, 25 Jul 2006 12:32:38 +0200 Subject: DICS In-Reply-To: <4442BD57-7F97-469F-990B-CD63E171E371@fcdonders.ru.nl> Message-ID: Dear Muthuraman, One little addition to the freq.cumtapcnt-story. freq.cumtapcnt should be a vector instead of a scalar: the correct way to specify it would be: freq.cumtapcnt = ones(ntrl,1) with ntrl the number of trials in your data. Yours, Jan-Mathijs -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Robert Oostenveld Sent: Tuesday, July 25, 2006 12:19 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: Re: [FIELDTRIP] DICS Hi Muthuraman The cumulative number of tapers per trial is indeed not kept in mtmwelch. You should specify it manually prior to freqanalysis. I do not recall whether you use keeptrials and keeptapers but if not, then it is safe to specify freq.cumtapcnt=1. Keeping count of the number of trials and tapers in the various freqanalysis methods is not done consistenly, it is something that we will improve in the future. best regards, Robert On 17 Jul 2006, at 16:12, Muthuraman Muthuraman wrote: > I get the error > > ??? Reference to non-existent field 'cumtapcnt'. > > Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 > Ntrials = length(freq.cumtapcnt); > > Error in ==> sourceanalysis at 663 > [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); > > when i use the mtmfft i get the cumtapcnt values > but not when using the mtmwelch is this a problem in the mtmwelch > or i am doing something wrong From r.oostenveld at FCDONDERS.RU.NL Tue Jul 25 12:32:52 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 25 Jul 2006 12:32:52 +0200 Subject: Source anaylsis In-Reply-To: Message-ID: On 25 Jul 2006, at 10:34, Muthuraman Muthuraman wrote: > ??? Error using ==> fieldtrip-20060712\private\prepare_freq_matrices > The cross-spectral-density matrix is not complete this indicates that you did not include all channel combinations (cfg.channelcmb) in freqanalysis, and that you try to use a cross spectral density matrix for DISC that is not complete (i.e. come cross-spectra are missing). You should correct your configuration for the frequencyanalysus (e.g. cfg.channelcmb = {'all' 'all'} or see the CHANNELCOMBINATION function). best regards, Robert From jciveira at UNAV.ES Tue Jul 25 14:22:36 2006 From: jciveira at UNAV.ES (Juan Civeira) Date: Tue, 25 Jul 2006 14:22:36 +0200 Subject: Source anaylsis In-Reply-To: <77E33A56-A0D4-43FC-94E0-91A3AC31197B@fcdonders.ru.nl> Message-ID: I have the same problem and I do not know how to fix it, even though I tried your solution with cfg.channelcmb. My case is : i have a set of 82 electrodes, I make freqanalysis with cfg.channelcmb = channelcombination({'all' 'all'},data.label); thus I get freq = label: {82x1 cell} dimord: 'chan_freq' freq: [14 14.4000 14.8000 15.2000 15.6000 16 16.4000 16.8000 17.2000 17.6000 18] powspctrm: [82x11 double] labelcmb: {3321x2 cell} crsspctrm: [3321x11 double] cfg: [1x1 struct] When I make sourceanalysis with a dipole as a reference and I have no problems but when I want to use a channel as a reference I always have the same error: The cross-spectral-density matrix is not complete. Can you help me? Best regards Juan Robert Oostenveld ha escrito: > On 25 Jul 2006, at 10:34, Muthuraman Muthuraman wrote: > >> ??? Error using ==> fieldtrip-20060712\private\prepare_freq_matrices >> The cross-spectral-density matrix is not complete > > this indicates that you did not include all channel combinations > (cfg.channelcmb) in freqanalysis, and that you try to use a cross > spectral density matrix for DISC that is not complete (i.e. come > cross-spectra are missing). You should correct your configuration for > the frequencyanalysus (e.g. cfg.channelcmb = {'all' 'all'} or see the > CHANNELCOMBINATION function). > > best regards, > Robert ---------------------------------------------------------------- Este mensaje ha sido enviado desde https://webmail.unav.es From stephan.bickel at ANATOM.UNIZH.CH Tue Jul 25 17:39:32 2006 From: stephan.bickel at ANATOM.UNIZH.CH (Stephan Bickel) Date: Tue, 25 Jul 2006 17:39:32 +0200 Subject: import bva time-freq data Message-ID: Hi, I try to import brainvision analyzer dat files of wavelet time-frequency decompositions into fieldtrip. I exported an average file, so it consists only of a single segment. However I have some problems with it I am not sure if it is because I define the segment wrong or if it is not possible to import this data into fieldtrip. I pasted the code and the error message below and attached the marker- and header file. I would be really glad for any suggestions. Thank you very much, Stephan This is what I tried: cfg = []; cfg.headerfile =... 'c:\HumanEEG_data\Vision_Exports\WT_all_ft_test.vhdr'; cfg.datafile =... 'c:\HumanEEG_data\Vision_Exports\WT_all_ft_test.dat'; cfg.channel = 'all'; %Trialdefinition cfg.trialdef.trgfile =... 'c:\HumanEEG_data\Vision_Exports\WT_all_ft_test.vmrk'; cfg.trialdef.stim = 'New Segment'; %cfg.trialdef.segment = 'yes'; cfg.trialdef.timezero = 'yes'; % cfg.trialdef.eventtype = 'Time 0'; cfg.trialdef.prestim = 0.500; cfg.trialdef.poststim = 1.600; [cfg] = definetrial(cfg) [raw] = preprocessing(cfg) and this is the error message: evaluating trialfunction 'trialfun_brainvision' 0 stimulus markers converted into 0 trials 0 response markers converted into 0 trials 1 segment markers converted into 0 trials 1 "Time 0" markers converted into 1 trials found 0 events created 1 trials cfg = headerfile: [1x88 char] datafile: [1x87 char] channel: 'all' trialdef: [1x1 struct] dataset: [] trialfun: 'trialfun_brainvision' event: [] trl: [1 1051 -250] version: [1x1 struct] retaining exist trial definition retaining exist event information found 0 events created 1 trials rejected 0 trials completely rejected 0 trials partially resulting 1 trials reading and preprocessing reading and preprocessing trial 1 from 1 ??? Subscripted assignment dimension mismatch. Error in ==> fieldtrip-20060330\private\read_brainvision_eeg at 65 dat(line,:) = str2num(str); Error in ==> read_fcdc_data at 419 dat = read_brainvision_eeg(datafile, hdr, begsample, endsample); Error in ==> preprocessing at 322 dat = read_fcdc_data(cfg.datafile, hdr, begsample, endsample, rawindx, iscontinuous); -------------- next part -------------- A non-text attachment was scrubbed... Name: WT_all_ft_test.vmrk Type: application/octet-stream Size: 741 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: WT_all_ft_test.vhdr Type: application/octet-stream Size: 3459 bytes Desc: not available URL: From r.oostenveld at FCDONDERS.RU.NL Wed Jul 26 09:07:03 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 26 Jul 2006 09:07:03 +0200 Subject: Source anaylsis In-Reply-To: <20060725142236.lz6o47hwkkwo4sw4@webmail.unav.es> Message-ID: On 25 Jul 2006, at 14:22, jciveira at unav.es wrote: > I have the same problem and I do not know how to fix it, even > though I tried your solution with cfg.channelcmb. > > My case is : i have a set of 82 electrodes, I make freqanalysis > with cfg.channelcmb = channelcombination({'all' > 'all'},data.label); thus I get > > freq = > > label: {82x1 cell} > dimord: 'chan_freq' > freq: [14 14.4000 14.8000 15.2000 15.6000 16 16.4000 > 16.8000 17.2000 17.6000 18] > powspctrm: [82x11 double] > labelcmb: {3321x2 cell} > crsspctrm: [3321x11 double] > cfg: [1x1 struct] > > When I make sourceanalysis with a dipole as a reference and I have > no problems but when I want to use a channel as a reference I > always have the same error: > The cross-spectral-density matrix is not complete. > > Can you help me? > > Best regards > Juan Dear Juan Do you have 82 EEG electrodes, or 81 and one EMG electrode? I would expect the latter, since computing coherence between one particular EEG electrode and sources in the brain with DICS will not lead to meaningfull results. The selected EEG electrode will pick up volume- conducted activity from all sources in the brain (as opposed to an EMG electrode) and would be referenced to the same reference electrode as all other electrodes. So there will be a huge amount of trivial coherence, whose spatial distribution in the brain will probably more reflect the volume-conduction than something physiologically interpretable. Although I have not used DICS with a reference channel on EEG data, I would expect the code to work if you follow a procedure like this: cfg = ... trial selection stuff cfg = definetrial(cfg) cfg = ... preprocessing stuff cfg.channel = list of all EEG electrodes cfg.implicitref = name of implicit reference electrode used for the EEG channels cfg.reref = 'all' % rereference all EEG electrodes to an average reference data_eeg = preprocessing(cfg) cfg = ... trial selection stuff cfg = definetrial(cfg) cfg = ... preprocessing stuff cfg.channel = list of all EMG electrodes, assuming that they are bipolar channels % cfg.reref may be used if you have two unipolar channels on the muscle of interest cfg.rectify = 'yes' % this makes the spiky nature of the EMG more visible, and improves the coherence estimate cfg.baseline = 'yes' % remove baseline prior to rectification, not neccessary but still preferable data_emg = preprocessing(cfg) % combine EEG and EMG in one dataset, both are referenced differently data = appenddata([], data_eeg, data_emg); cfg = ... frequency analysis stuff cfg.ouptu = 'powandcsd' cfg.channelcmb = {'all', 'all'} freq = freqanalysis(cfg, data); cfg = ... source specific settings cfg.refchan = one of your bipolar EMG channels cfg.channel = all your EEG channels source = sourceanalysis(cfg, freq) best regards, Robert From r.oostenveld at FCDONDERS.RU.NL Wed Jul 26 09:46:59 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 26 Jul 2006 09:46:59 +0200 Subject: import bva time-freq data In-Reply-To: Message-ID: Hi Stephan, On 25 Jul 2006, at 17:39, Stephan Bickel wrote: > I try to import brainvision analyzer dat files of wavelet time- > frequency > decompositions into fieldtrip. I exported an average file, so it > consists > only of a single segment. However I have some problems with it I am > not sure ... > cfg.trialdef.trgfile = 'c:\HumanEEG_data\Vision_Exports > \WT_all_ft_test.vmrk'; > cfg.trialdef.stim = 'New Segment'; > %cfg.trialdef.segment = 'yes'; > cfg.trialdef.timezero = 'yes'; > % cfg.trialdef.eventtype = 'Time 0'; In general I would recommend to use the trialfun_general instead of the trialfun_brainvision (but the latter should also work). The trialfun_general was written later and will work for any dataformat that is supported by read_fcdc_event, the trialfun_brainvision is only there to support old scripts (i.e. scripts that predate the read_fcdc_event function). If not specified manually as trialfun, the trialfun_general or trialfun_brainvision is selected automatically based on the cfg settings. In your case you could do cfg.trialdef.eventtype = 'New Segment' or 'Time 0' cfg.trialdef.prestim = number, latency in seconds (optional) cfg.trialdef.poststim = number, latency in seconds (optional) See teh help of DEFINETRIAL. But in your case this is not the problem. The problem lies in > cfg.trialdef.prestim = 0.500; > cfg.trialdef.poststim = 1.600; If I do event = read_fcdc_event('WT_all_ft_test.vmrk') then I see that >> event(1) ans = type: 'New Segment' value: '1' sample: 1 duration: 0 offset: [] >> event(2) ans = type: 'Time 0' value: '251' sample: 1 duration: 0 offset: [] The 'New Segment' event is at sample 1, hence you cannot select a 500ms pre-stimulus window before it (you cannot read before the beginning of the data). The alternative 'Time 0' event is also at sample 1. It specifies a value of 251, which surprises me. I would expect that event to be present at sample 251. Reading the marker file with a text editor, I see (abbreviated) the explanation Mk=,,,, , and the markers Mk1=New Segment,,1,1,0,00000000000000000000 Mk2=Time 0,,251,1,0 So Mk2 should indeed be at sample 251. With the matlab debugger in the private/read_event.m file (around line 164) I notice that the problem lies in the missing value of the second field, i.e. Mk2=Time 0,,251,1,0 is interpreted as Mk2=Time 0,251,1,0 (one comma less) All fields are shifted by one, resulting in the sample number being interpreted as the description (i.e. value). I have fixed it in read_event, by replacing line 151 from tok = tokenize(line, '='); into tok = tokenize(line, '=', 0); % do not squeeze repetitions of the seperator and by replacing line 157 from tok = tokenize(tok{2}, ','); into tok = tokenize(tok{2}, ',', 0); % do not squeeze repetitions of the seperator i.e. both calls to the tokenize function now use the third argument. You can apply the same change to your copy, but please check that you have an up to date version of tokenize that accepts 3 input arguments (tokenize is in private as well). I will include the bug fix in the upcoming nightly release of FieldTrip. Better upgrade tomorrow to the latest FT version from the FTP server. I think that sofar it was not noticed since people here at the Donders typically use triggers as markers in their Brainvision data, and in case of triggers the second field would not be empty. If I now do cfg = []; cfg.dataset = 'WT_all_ft_test.vhdr' cfg.trialdef.eventtype = 'Time 0' cfg.trialdef.prestim = 0.5000 cfg.trialdef.poststim = 1 cfg = definetrial(cfg) I get evaluating trialfunction 'trialfun_general' found 2 events created 1 trials cfg = dataset: 'WT_all_ft_test.vhdr' trialdef: [1x1 struct] datafile: [] headerfile: 'WT_all_ft_test.vhdr' trialfun: 'trialfun_general' event: [1x2 struct] trl: [1 750 -250] version: [1x1 struct] which is correct. The trial (cfg.trl) runs from sample 1 to sample 750 in the data file, and the first sample of that trial corresponds with time cfg.trl(1,3)/fsample=-0.500 seconds. Thanks for reporting the bug, Robert From stephan.bickel at ANATOM.UNIZH.CH Wed Jul 26 17:28:54 2006 From: stephan.bickel at ANATOM.UNIZH.CH (Stephan Bickel, Anatomisches Inst.) Date: Wed, 26 Jul 2006 11:28:54 -0400 Subject: import bva time-freq data In-Reply-To: <30468A0B-0B5C-41EF-9FB3-84FD50036A22@fcdonders.ru.nl> Message-ID: Hi Robert, thank you very much for your response and for fixing the bug. Reading in the trial information works fine now. Unfortunately I encounter another problem when I want to read in the data with preprocessing. I wonder if it is yet possible to read in time-frequency data from bva-dat files? Sorry for bothering you again and thank you very much in advance. Stephan So when I do: cfg = []; cfg.dataset = 'WT_all_ft_test.vhdr' cfg.trialdef.eventtype = 'Time 0' cfg.trialdef.prestim = 0.5000 cfg.trialdef.poststim = 1 cfg = definetrial(cfg) cfg.datafile = 'WT_all_ft_test.dat'; cfg.channel = 'all'; [raw] = preprocessing(cfg) I get: cfg = dataset: 'WT_all_ft_test.vhdr' trialdef: [1x1 struct] datafile: 'WT_all_ft_test.dat' headerfile: 'WT_all_ft_test.vhdr' trialfun: 'trialfun_general' event: [1x2 struct] trl: [1 750 -250] version: [1x1 struct] channel: 'all' retaining exist trial definition retaining exist event information found 2 events created 1 trials rejected 0 trials completely rejected 0 trials partially resulting 1 trials reading and preprocessing reading and preprocessing trial 1 from 1 ??? Subscripted assignment dimension mismatch. Error in ==> fieldtrip-20060725\private\read_brainvision_eeg at 65 dat(line,:) = str2num(str); Error in ==> fieldtrip-20060725\private\read_data at 239 dat = read_brainvision_eeg(filename, hdr, begsample, endsample); Error in ==> read_fcdc_data at 49 [dat] = read_data(varargin{:}); Error in ==> preprocessing at 366 dat = read_fcdc_data(cfg.datafile, hdr, begsample, endsample, rawindx, iscontinuous); On Wed, 26 Jul 2006 09:46:59 +0200 Robert Oostenveld wrote: > Hi Stephan, > > On 25 Jul 2006, at 17:39, Stephan Bickel wrote: >> I try to import brainvision analyzer dat files of wavelet time- >> frequency >> decompositions into fieldtrip. I exported an average file, so it >> consists >> only of a single segment. However I have some problems with it I am >> not sure > ... >> cfg.trialdef.trgfile = 'c:\HumanEEG_data\Vision_Exports >> \WT_all_ft_test.vmrk'; >> cfg.trialdef.stim = 'New Segment'; >> %cfg.trialdef.segment = 'yes'; >> cfg.trialdef.timezero = 'yes'; >> % cfg.trialdef.eventtype = 'Time 0'; > > In general I would recommend to use the trialfun_general instead of the >trialfun_brainvision (but the latter should also work). The > trialfun_general was written later and will work for any dataformat that >is supported by read_fcdc_event, the trialfun_brainvision is only there to >support old scripts (i.e. scripts that predate the read_fcdc_event >function). > > If not specified manually as trialfun, the trialfun_general or > trialfun_brainvision is selected automatically based on the cfg settings. >In your case you could do > cfg.trialdef.eventtype = 'New Segment' or 'Time 0' > cfg.trialdef.prestim = number, latency in seconds (optional) > cfg.trialdef.poststim = number, latency in seconds (optional) > See teh help of DEFINETRIAL. > > But in your case this is not the problem. The problem lies in >> cfg.trialdef.prestim = 0.500; >> cfg.trialdef.poststim = 1.600; > > If I do > event = read_fcdc_event('WT_all_ft_test.vmrk') > then I see that > > >> event(1) > ans = > type: 'New Segment' > value: '1' > sample: 1 > duration: 0 > offset: [] > > >> event(2) > ans = > type: 'Time 0' > value: '251' > sample: 1 > duration: 0 > offset: [] > > The 'New Segment' event is at sample 1, hence you cannot select a 500ms >pre-stimulus window before it (you cannot read before the beginning of the >data). The alternative 'Time 0' event is also at sample 1. It specifies a >value of 251, which surprises me. I would expect that event to be present >at sample 251. > > Reading the marker file with a text editor, I see (abbreviated) the > explanation > Mk=,,,, > , > and the markers > Mk1=New Segment,,1,1,0,00000000000000000000 > Mk2=Time 0,,251,1,0 > So Mk2 should indeed be at sample 251. > > With the matlab debugger in the private/read_event.m file (around line >164) I notice that the problem lies in the missing value of the second >field, i.e. > Mk2=Time 0,,251,1,0 > is interpreted as > Mk2=Time 0,251,1,0 (one comma less) > All fields are shifted by one, resulting in the sample number being > interpreted as the description (i.e. value). > > I have fixed it in read_event, by replacing line 151 from > tok = tokenize(line, '='); > into > tok = tokenize(line, '=', 0); % do not squeeze repetitions of the > seperator > and by replacing line 157 from > tok = tokenize(tok{2}, ','); > into > tok = tokenize(tok{2}, ',', 0); % do not squeeze repetitions of > the seperator > i.e. both calls to the tokenize function now use the third argument. You >can apply the same change to your copy, but please check that you have an >up to date version of tokenize that accepts 3 input arguments (tokenize is >in private as well). I will include the bug fix in the upcoming nightly >release of FieldTrip. Better upgrade tomorrow to the latest FT version >from the FTP server. > > I think that sofar it was not noticed since people here at the Donders >typically use triggers as markers in their Brainvision data, and in case >of triggers the second field would not be empty. > > If I now do > cfg = []; > cfg.dataset = 'WT_all_ft_test.vhdr' > cfg.trialdef.eventtype = 'Time 0' > cfg.trialdef.prestim = 0.5000 > cfg.trialdef.poststim = 1 > cfg = definetrial(cfg) > I get > evaluating trialfunction 'trialfun_general' > found 2 events > created 1 trials > cfg = > dataset: 'WT_all_ft_test.vhdr' > trialdef: [1x1 struct] > datafile: [] > headerfile: 'WT_all_ft_test.vhdr' > trialfun: 'trialfun_general' > event: [1x2 struct] > trl: [1 750 -250] > version: [1x1 struct] > which is correct. The trial (cfg.trl) runs from sample 1 to sample 750 in >the data file, and the first sample of that trial corresponds with time >cfg.trl(1,3)/fsample=-0.500 seconds. > > Thanks for reporting the bug, > Robert From r.oostenveld at FCDONDERS.RU.NL Thu Jul 27 09:26:26 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 27 Jul 2006 09:26:26 +0200 Subject: import bva time-freq data In-Reply-To: Message-ID: On 26 Jul 2006, at 17:28, Stephan Bickel, Anatomisches Inst. wrote: > thank you very much for your response and for fixing the bug. > Reading in the trial information works fine now. Unfortunately I > encounter another problem when I want to read in the data with > preprocessing. I wonder if it is yet possible to read in time- > frequency data from bva-dat files? ... > Error in ==> fieldtrip-20060725\private\read_brainvision_eeg at 65 > dat(line,:) = str2num(str); > > Error in ==> fieldtrip-20060725\private\read_data at 239 > dat = read_brainvision_eeg(filename, hdr, begsample, endsample); Hi Stephan, I have no idea how time-frequency data is stored in the BVA *.dat files. Even if the low-level reading function were to support it, the PREPROCESSING function at least would not be able to deal with it, since the data structure returned by preprocessing does not allow for 3D data (channelXtimeXfrequency). That type of data would have to be stored in a structure that is compatible with the output of FREQANALYSIS. The preprocessing function is made for raw continuous (or trial-based) data, and it happens to work as well for averaged ERP data, although it is not specifically made for that. For other external software (BESA, EEGLAB, LORETA) I have created xxx2fieldtrip functions, i.e. functions that import already processed data and format it into the fieldtrip structure that is most compatible with it. In this case I can imagine a BRAINVISION2FIELDTRIP function that would read your dat file and return a "freq" structure. Besides making a brainvision2fieldtrip function, it requires making either the read_brainvision_eeg smarter (or probably making a seperate read_brainvision_tfr function) and improving the detection of teh content of the BVA *.dat file. Please have a look in besa2fieldtrip to see how I approach it there. best regards, Robert From jciveira at UNAV.ES Thu Jul 27 18:54:27 2006 From: jciveira at UNAV.ES (Juan Civeira) Date: Thu, 27 Jul 2006 18:54:27 +0200 Subject: Source anaylsis In-Reply-To: <9A0AA0F8-A8AD-4958-B224-4E3547238053@FCDONDERS.RU.NL> Message-ID: Dear Robert: Thanks for your answer but my problems are still there. The main problem is that i can not use DICS with a reference channel on EEG data, no matter if the reference is an EEG channel or EMG or some other channel. I have taken my measures with 85 electrodes, some of them are EEG1010, some EOG and some other that I have placed myself. I do the freq analysis and then the source analysis. Then I can make another source analysis with refdip but there is always errors when I use refchan. I do not think is a problem of the reference , cos always the program says that the cross-spectral-density with the reference channel is not complete . I have done the freq analysis making cfg.channelcmb combinations of all channels with only one, so i make sure that the cross-spectral-density is complete,but when I make source analysis with that channel as a reference is the same. Searching in the code I have come up with the fact that the error is always the condition in line 195 of the function prepare_freq_matrices (version 2006/03/08). My idea is that there is a confussion because if we have a set of N channels and we make combinations with channelcombination, the result is N-1 combinations because we do not include the combination of the reference with itself. I hope i explain myself clear enough, anyway I am trying to fix the problem by myself but any help or suggestion will be great Juan Robert Oostenveld ha escrito: > On 25 Jul 2006, at 14:22, jciveira at unav.es wrote: >> I have the same problem and I do not know how to fix it, even >> though I tried your solution with cfg.channelcmb. >> >> My case is : i have a set of 82 electrodes, I make freqanalysis >> with cfg.channelcmb = channelcombination({'all' 'all'},data.label); >> thus I get >> >> freq = >> >> label: {82x1 cell} >> dimord: 'chan_freq' >> freq: [14 14.4000 14.8000 15.2000 15.6000 16 16.4000 >> 16.8000 17.2000 17.6000 18] >> powspctrm: [82x11 double] >> labelcmb: {3321x2 cell} >> crsspctrm: [3321x11 double] >> cfg: [1x1 struct] >> >> When I make sourceanalysis with a dipole as a reference and I have >> no problems but when I want to use a channel as a reference I >> always have the same error: >> The cross-spectral-density matrix is not complete. >> >> Can you help me? >> >> Best regards >> Juan > > Dear Juan > > Do you have 82 EEG electrodes, or 81 and one EMG electrode? I would > expect the latter, since computing coherence between one particular EEG > electrode and sources in the brain with DICS will not lead to > meaningfull results. The selected EEG electrode will pick up > volume-conducted activity from all sources in the brain (as opposed to > an EMG electrode) and would be referenced to the same reference > electrode as all other electrodes. So there will be a huge amount of > trivial coherence, whose spatial distribution in the brain will > probably more reflect the volume-conduction than something > physiologically interpretable. > > Although I have not used DICS with a reference channel on EEG data, I > would expect the code to work if you follow a procedure like this: > > cfg = ... trial selection stuff > cfg = definetrial(cfg) > cfg = ... preprocessing stuff > cfg.channel = list of all EEG electrodes > cfg.implicitref = name of implicit reference electrode used for the EEG > channels > cfg.reref = 'all' % rereference all EEG electrodes to an average reference > data_eeg = preprocessing(cfg) > > cfg = ... trial selection stuff > cfg = definetrial(cfg) > cfg = ... preprocessing stuff > cfg.channel = list of all EMG electrodes, assuming that they are > bipolar channels > % cfg.reref may be used if you have two unipolar channels on the muscle > of interest > cfg.rectify = 'yes' % this makes the spiky nature of the EMG more > visible, and improves the coherence estimate > cfg.baseline = 'yes' % remove baseline prior to rectification, not > neccessary but still preferable > data_emg = preprocessing(cfg) > > % combine EEG and EMG in one dataset, both are referenced differently > data = appenddata([], data_eeg, data_emg); > > cfg = ... frequency analysis stuff > cfg.ouptu = 'powandcsd' > cfg.channelcmb = {'all', 'all'} > freq = freqanalysis(cfg, data); > > cfg = ... source specific settings > cfg.refchan = one of your bipolar EMG channels > cfg.channel = all your EEG channels > source = sourceanalysis(cfg, freq) > > best regards, > Robert ---------------------------------------------------------------- Este mensaje ha sido enviado desde https://webmail.unav.es From r.oostenveld at FCDONDERS.RU.NL Fri Jul 28 09:49:55 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 28 Jul 2006 09:49:55 +0200 Subject: Source anaylsis In-Reply-To: <20060727185427.3r2gdy6zkk0o4og8@webmail.unav.es> Message-ID: Hi Juan > I do the freq analysis and then the source analysis. Then I can > make another source analysis with refdip but there is always errors > when I use refchan. I do not think is a problem of the reference , > cos always the program says that the cross-spectral-density with > the reference channel is not complete . > > I have done the freq analysis making cfg.channelcmb combinations of > all channels with only one, so i make sure that the > cross-spectral-density is complete,but when I make source analysis > with that channel as a reference is the same. > > Searching in the code I have come up with the fact that the error > is always the condition in line 195 of the function > prepare_freq_matrices (version 2006/03/08). My idea is that there is > a confussion because if we have a set of N channels and we make > combinations with channelcombination, the result is N-1 > combinations because we do not include the combination of the > reference with itself. Say for simplicity that you want EMG as refchan. In freqanalysis, cfg.channelcmb should be all with all. You need the CSD between all EEG channels (all EEG with all EEG), and of all EEG channels with the EMG. In prepare_freq_matrices the CSD matrix (Cf) of EEG with EEG is made (Neeg X Neeg), the CSD vector (Cr) of all EEG channels with the reference EMG channel (Neeg X 1), and the power of the reference channel (Pr). Together they could also be shaped in a (Neeg+1) X (Neeg +1) matrix in principle, but that is not done for DICS. I have tried it out myself, and cannot reproduce your problem. Please find my test script below. It uses some simulated EEG data. The beginning of the script is copied from http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? id=fieldtrip:documentation:compute_forward_simulated_data_and_apply_a_di pole_fit The initial part generates raw EEG data, then I add a EMG channel (with noise, but it is only to demonstrate that fieldtrip does not give an error), then I do freqanalysis and sourceanalysis. Please try out and compare my cfgs with yours, since I suspect your configuration to be the problem. best regards, Robert %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % create a set of electrodes, randomly placed on the sphere elec = []; elec.pnt = randn(128,3); dum = sqrt(sum(elec.pnt.^2,2)); elec.pnt = elec.pnt ./ [dum dum dum]; % scale them to a unit sphere for i=1:128 elec.label{i} = sprintf('%03d', i); end % create a concentric 3-sphere volume conductor, the radius is the same as for the electrodes vol = []; vol.r = [0.88 0.92 1.00]; % radii of spheres vol.c = [1 1/80 1]; % conductivity vol.o = [0 0 0]; % center of sphere % create a dipole simulation with one dipole and a 10Hz sine wave cfg = []; cfg.vol = vol; % see above cfg.elec = elec; % see above cfg.dip.pos = [0 0.5 0.3]; cfg.dip.mom = [1 0 0]'; % note, it should be transposed cfg.dip.frequency = 10; cfg.ntrials = 10; cfg.triallength = 1; % seconds cfg.fsample = 250; % Hz raw1 = dipolesimulation(cfg); using headmodel specified in the configuration using electrodes specified in the configuration selected 128 electrodes computing simulated data RMS value of simulated data is 0.0746553 %%%%%%%%%%%%%%%%%%%%%%%% %%%%% Here it starts deviating from the demo script on the wiki %%%% %%%%%%%%%%%%%%%%%%%%%%%% % add a fake EMG channel, containing noise for i=1:10 raw1.trial{i}(end+1,:) = randn(1,250); end raw1.label{end+1} = 'EMG' raw1 = trial: {1x10 cell} time: {1x10 cell} elec: [1x1 struct] fsample: 250 label: {1x129 cell} cfg: [1x1 struct] cfg = [] cfg.method = 'mtmfft'; cfg.taper = 'hanning'; cfg.foilim = [2 20]; cfg.output = 'powandcsd'; cfg.channelcmb = {'all', 'all'} cfg = method: 'mtmfft' taper: 'hanning' foilim: [2 20] output: 'powandcsd' channelcmb: {'all' 'all'} freq1 = freqanalysis(cfg, raw1) WARNING: using only one taper for specified smoothing processing trial 1, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 2, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 3, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 4, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 5, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 6, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 7, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 8, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 9, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 10, nfft: 250 samples, taper length: 250 samples, 1 tapers freq1 = label: {1x129 cell} dimord: 'chan_freq' freq: [2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20] powspctrm: [129x19 double] labelcmb: {8256x2 cell} crsspctrm: [8256x19 double] elec: [1x1 struct] cfg: [1x1 struct] cfg = []; cfg.vol = vol; cfg.freq = 10; cfg.frequency = 10; cfg.method = 'dics'; cfg.refchan = 'EMG'; cfg.grid.resolution = 0.3 cfg = vol: [1x1 struct] freq: 10 frequency: 10 method: 'dics' refchan: 'EMG' grid: [1x1 struct] source1 = sourceanalysis(cfg, freq1) using headmodel specified in the configuration using electrodes specified in the data selected 128 electrodes 106 dipoles inside, 237 dipoles outside brain making tight grid 106 dipoles inside, 110 dipoles outside brain scanning repetition 1 scanning grid Warning: cross-spectral density matrix is rank deficient > In beamformer at 270 In sourceanalysis at 806 total time in sourceanalysis 75.4 seconds source1 = xgrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000] ygrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000] zgrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000] dim: [6 6 6] vol: [1x1 struct] frequency: 10 pos: [216x3 double] inside: [1x106 double] outside: [1x110 double] method: 'average' avg: [1x1 struct] cfg: [1x1 struct] diary off From floris.delange at FCDONDERS.RU.NL Fri Jul 28 13:01:00 2006 From: floris.delange at FCDONDERS.RU.NL (Floris de Lange) Date: Fri, 28 Jul 2006 13:01:00 +0200 Subject: sourcestatistics: what to compare? Message-ID: Dear Fieldtrippers, I have a question about what conditions/comparisons make most sense to statistically compare with sourcestatistics. I have 2 conditions, A and B, and each condtion has its own pre-stimulus baseline: basA and basB. Now, first I'd like to see which regions are showing stronger beta-band power during A than the baseline. So I want to compare A to basA. There's 2 ways of going about it: 1) compare (the grand average of) A.avg.pow with basA.avg.pow 2) compare (the grand average of) the neural activity index (NAI) of A with the baseline Any ideas which would be best? Or is this just an empirical issue? (i.e., take the best) To compare A and B, one has even more options: 1) compare A.avg.pow with B.avg.pow 2) compare (A.avg.pow/basA.avg.pow) with (B.avg.pow/basB.avg.pow) 3) compare NAI(A) with NAI(B) 4) compare NAI(A)/NAI(basA) with NAI(B)/NAI(basB) Is there's any principled reason for a priori picking any of the above choices? Your input is greatly appreciated, Kind regards, Floris From r.oostenveld at FCDONDERS.RU.NL Fri Jul 28 16:17:24 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 28 Jul 2006 16:17:24 +0200 Subject: sourcestatistics: what to compare? In-Reply-To: <44C9EE6C.8030003@fcdonders.ru.nl> Message-ID: Hi Floris On 28 Jul 2006, at 13:01, Floris de Lange wrote: > I have a question about what conditions/comparisons make most sense > to statistically compare with sourcestatistics. > I have 2 conditions, A and B, and each condtion has its own pre- > stimulus baseline: basA and basB. > > Now, first I'd like to see which regions are showing stronger beta- > band power during A than the baseline. So I want to compare A to > basA. There's 2 ways of going about it: > 1) compare (the grand average of) A.avg.pow with basA.avg.pow > 2) compare (the grand average of) the neural activity index (NAI) > of A with the baseline > > Any ideas which would be best? Or is this just an empirical issue? > (i.e., take the best) Both are valid, you could take the best. There are some exceptions/ predictions though that I can share with you: the NAI is power divided by estimated (projected) noise. It is inherently difficult to estimate the noise level (the default is the smallest singular value of the CSD matrix, but you can manipulate it with cfg.lambda in sourceanalysis). If you have different numbers of trials in active v.s. baseline, the noise estimate probably will be different. So then you would have NAIa = Pa/Na and NAIb = Pb/Nb, if Pa==Pb and Na~=Nb, these will be trivially different, which is not what you want (remember Pa==Pb was assumed). You can compare the projected noise in both conditions, the source- noise-estimate is uniformely scaled (i.e. on all voxels the same) with the estimated noise from the CSD. There is no reason to assume that the noise is different, so if the noise is different, you would have to explain that. > To compare A and B, one has even more options: > 1) compare A.avg.pow with B.avg.pow > 2) compare (A.avg.pow/basA.avg.pow) with (B.avg.pow/basB.avg.pow) > 3) compare NAI(A) with NAI(B) > 4) compare NAI(A)/NAI(basA) with NAI(B)/NAI(basB) > > Is there's any principled reason for a priori picking any of the > above choices? I presume that by "compare" you mean "look at the the difference". In general you should only use the NAI for plotting data if you only have one condition (and no baseline). The noise estimate that goes into the NAI is too poor to be of real value. Although sometines it looks nice in figures, the NAI tends not to be very robust (it contains global flucuations that mess up the statistic, although the figure still looks nice). The baseline is only interesting if you expect something differently to happen in the two baselines. If that is the case, you better try to get another baseline in your experimental design. If you would combine actA, basA, actB, basB into a single number, and that number would be significant, you still would not be able to tell whether the difference is betwen the active conditions, theis baselines, or some weird combination of the 4 "conditions" that you combine. Typically there is no reason to assume taht the baselines are different. So (A.avg.pow/basA.avg.pow) with (B.avg.pow/basB.avg.pow) = (A.avg.pow/basC.avg.pow) with (B.avg.pow/basC.avg.pow), where C means common = (A.avg.pow-B.avg.pow)/basC.avg.pow. I.e. you are comparing A and B directly, with a spatially normalizing for the different baseline-estimated noise at different source locations. Whether you want to spatially normalize (divide by some baseline estimated-source-power) depends on the leadfields (it is neccessary if cfg.normalize=no, if you want to do multiple comparison correction, and if you want to look at an additive effect). If you want to look at a multiplicative effect, you would look at the ratio between two conditions instead of the difference. The ratio of the conditions is best implemented with a log transform, after which you again can look at the difference between the log-transformed power estimates in both conditions (log(A/B) = log(A) - log(B)). In the ratio or log-ratio between the powers in both conditions you have also corrected for the spatial (depth) noise-bias. good luck with the stats, Robert PS as I am on holiday the next 2 weeks, you could ask Ingrid about more details on this. She is more or less at the same stage in her analysis (about to do group sourcestatistics), but I suspect that she already has more "feel" for these issues. Or ask JM. From d.vanbarneveld at STUDENT.SCIENCE.RU.NL Thu Jul 6 16:58:40 2006 From: d.vanbarneveld at STUDENT.SCIENCE.RU.NL (Denise van Barneveld) Date: Thu, 6 Jul 2006 16:58:40 +0200 Subject: problem with text in topoplot and triplot Message-ID: Dear all, since I started using the new version of Matlab (R2006a) on a mac, I have this problem with text in the figures which I generate with topoplot.m and triplot.m. The upper half of the text lines (title, colorbar, electrodes, etc) is not visible (see attached figure). Does anyone have this problem too? Especially people who are using this new version on a pc. And does anyone perhaps has a solution for this problem? I am currently looking in the code, if I can find where it goes wrong, but I wonder whether it is a problem only with the new version, or only at a mac, or only at my computer. Best regards, Denise van Barneveld -------------- next part -------------- A non-text attachment was scrubbed... Name: topo.jpg Type: application/applefile Size: 48798 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: topo.jpg Type: image/jpeg Size: 85086 bytes Desc: not available URL: From muthuraman10 at HOTMAIL.COM Fri Jul 7 12:04:26 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Fri, 7 Jul 2006 10:04:26 +0000 Subject: query on confidence limit, DICS In-Reply-To: <37FAA4DD-5DD8-4F2F-ABA6-D9F47F6AB95E@fcdonders.ru.nl> Message-ID: Hello As i am able to sucessfully use the coherence analysis using freq_mtmfft and frq_mtmwelch to calculate the coherence i would like to know is there a way to calculate the confidence limit for the coherence calculated from the freqanalysis, is there a standard code Next, i would like to follow with the source analysis 'DICS' is there a tutorial available thanking you with regards Muthuraman >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] query on CTF software!!! >Date: Fri, 23 Jun 2006 15:23:22 +0200 > >dear Muthuraman > >On 23 Jun 2006, at 12:54, Muthuraman Muthuraman wrote: >>For the Beamformer source analysis, do we need the CTF software >>because when i am trying out the tutorial in beamforming > >You do not need the ctf software to follow the tutorial. The tutorial is >based however on a ctf MEG dataset. > >>CTF_READ_RES4 [v 1.12] >>....done ( 0.67 sec) >> >>i get the error >> >>??? Error using ==> read_fcdc_header >>could not read CTF res4 header file >> >>Error in ==> preprocessing at 263 >>hdr = read_fcdc_header(cfg.headerfile); > >Based on your error I suspect that matlab/fieldtrip cannot find the >dataset that you are trying to analyze, or that you matlab path is >incorrect. The function "CTF_READ_RES4" is not supposed to be called (it >is part of the NIH ctf import routines, e.g. used in EEGLAB), since the >default private/read_ctf_res4.m function can deal with the tutorial >dataset just fine. Please look into the code of read_fcdc_header (using >the matlab debugger) to figure out what your exact problem is. > >best >Robert From r.oostenveld at FCDONDERS.RU.NL Fri Jul 7 12:36:02 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 7 Jul 2006 12:36:02 +0200 Subject: query on confidence limit, DICS In-Reply-To: Message-ID: On 7 Jul 2006, at 12:04, Muthuraman Muthuraman wrote: > As i am able to sucessfully use the coherence analysis using > freq_mtmfft and frq_mtmwelch to calculate the coherence > i would like to know is there a way to calculate the confidence > limit for the coherence calculated from the freqanalysis, is there > a standard code You can compute a jackknife estimate of the variance in the coherence using the freqdescriptives function. That requires keeptrials=yes in freqanalysis. > Next, i would like to follow with the source analysis 'DICS' is > there a tutorial available No there is no tutorial available specifically for that. You can look at the beamformer tutorial at http://www2.ru.nl/fcdonders/fieldtrip/ doku.php?id=fieldtrip:documentation:tutorial:beamformer, the relevant options are cfg.method=dics, cfg.refchan and/or cfg.refdip. Robert From j.poort at NIN.KNAW.NL Tue Jul 11 11:43:49 2006 From: j.poort at NIN.KNAW.NL (Jasper Poort) Date: Tue, 11 Jul 2006 11:43:49 +0200 Subject: Confidence intervals for evoked potentials Message-ID: Hi all, I have some questions regarding confidence intervals for timelocked data in FieldTrip. I noted that a field .var is returned by timelockanalysis line 510 timelockanalysis % compute the variance tmp1 = repmat(dofvec(:)', [nchan 1]); tmp2 = repmat(dofvec(:)', [nchan 1])-1; var = (ss - (s.^2)./tmp1) ./ tmp2; Assuming that the sampling distribution is normal I can presumably use this field for computation of confidence intervals of the .avg field? Is nonparametric estimation of variance using a bootstrap or jackknife also implemented somewhere? In general I'm just curious to know how others compute confidence intervals for evoked potentials in FieldTrip, for example to get an idea at what point in time two conditions start to differ, best regards, Jasper -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.oostenveld at FCDONDERS.RU.NL Tue Jul 11 15:50:09 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 11 Jul 2006 15:50:09 +0200 Subject: Confidence intervals for evoked potentials In-Reply-To: <017d01c6a4ce$835853e0$910b57c0@ABSYS> Message-ID: Hi Jasper, On 11 Jul 2006, at 11:43, Jasper Poort wrote: > Hi all, I have some questions regarding confidence intervals for > timelocked data in FieldTrip. I noted that a field .var is returned > by timelockanalysis > > line 510 timelockanalysis > % compute the variance > tmp1 = repmat(dofvec(:)', [nchan 1]); > tmp2 = repmat(dofvec(:)', [nchan 1])-1; > var = (ss - (s.^2)./tmp1) ./ tmp2; > > Assuming that the sampling distribution is normal I can presumably > use this field for computation of confidence intervals of the .avg > field? Yes, you can use it to compute the channel-timepoint specific standard-error of mean (SEM). > Is nonparametric estimation of variance using a bootstrap or > jackknife also implemented somewhere? In general I'm just curious > to know how others compute confidence intervals for evoked > potentials in FieldTrip, for example to get an idea at what point > in time two conditions start to differ, Bootstrap and jackknife estimates of variance are only different from teh normal variance estimate if the measure involves a nonlinear or biased estimate (i.e. coherence). The jackknife estimate of variance of the ERP is exactly the same as the normal estimate of variance, since the ERP is a plain (linear) average. The same holds for bootstrap estimates. So that means that for ERPs the jackknife and bootstrap only would be a computationally expensive methods, resulting in the same variance as usual. Therefore they are not implemented. best regards, Robert From muthuraman10 at HOTMAIL.COM Tue Jul 11 16:59:58 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Tue, 11 Jul 2006 14:59:58 +0000 Subject: DICS In-Reply-To: Message-ID: Hello Thanks for the suggestion to use the jackknife variance estimate it works thanks a lot To use the DICS method We have a 64 channel EEG measurement from (Neuroscan) and 4 EMG channels recording and also we have the 64 channel measurement in FRMI the electrode locations we have it in a file with 3 columns x,y,z for each electrode using the polhemus sensors but our own software In the Source analysis Cfg.method='DICS'; but Cfg.xgrid, ygrid and zgrid the grid values are the sensor location values or it should be the cfg.grid.pos-where i can give in the 3 values [x y z] for each electrode I am a starter in the source analysis in combining EEG-FMRI please let me know with regards muthuraman. >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] query on confidence limit, DICS >Date: Fri, 7 Jul 2006 12:36:02 +0200 > >On 7 Jul 2006, at 12:04, Muthuraman Muthuraman wrote: >>As i am able to sucessfully use the coherence analysis using freq_mtmfft >>and frq_mtmwelch to calculate the coherence >>i would like to know is there a way to calculate the confidence limit for >>the coherence calculated from the freqanalysis, is there a standard code > >You can compute a jackknife estimate of the variance in the coherence >using the freqdescriptives function. That requires keeptrials=yes in >freqanalysis. > >>Next, i would like to follow with the source analysis 'DICS' is there a >>tutorial available > >No there is no tutorial available specifically for that. You can look at >the beamformer tutorial at http://www2.ru.nl/fcdonders/fieldtrip/ >doku.php?id=fieldtrip:documentation:tutorial:beamformer, the relevant >options are cfg.method=dics, cfg.refchan and/or cfg.refdip. > >Robert From r.oostenveld at FCDONDERS.RU.NL Tue Jul 11 17:51:28 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 11 Jul 2006 17:51:28 +0200 Subject: DICS In-Reply-To: Message-ID: Dear Muthuraman On 11 Jul 2006, at 16:59, Muthuraman Muthuraman wrote: > To use the DICS method > > We have a 64 channel EEG measurement from (Neuroscan) and 4 EMG > channels recording > and also we have the 64 channel measurement in FRMI > > the electrode locations we have it in a file with 3 columns x,y,z > for each electrode > using the polhemus sensors but our own software > > In the Source analysis > Cfg.method='DICS'; > but Cfg.xgrid, ygrid and zgrid > the grid values are the sensor location values > > or it should be the > cfg.grid.pos-where i can give in the 3 values [x y z] for each > electrode in SOURCEANALYSIS you specify using cfg.xgrid/ygrid/zgrid the locations at which the _dipoles_ will be placed, it is not the position of the electrodes. At each grid location a spatial filter is constructed and the power (and coherence) is computed. If you do not want to scan on a full 3-D grid, but on only a few dipole locations of interest, you can use cfg.grid.pos to specify those dipole locations. The electrode positions are specified in the cfg.elec structure, or in the cfg.elecfile filename. You can find more details on the definition of electrode positions at http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? id=fieldtrip:documentation:frequently_asked_questions#how_are_electrodes _magnetometers_or_gradiometers_described Furthermore, you can try using the READ_FCDC_ELEC function for reading the electrode locations, but probably taht will not work since youy are using your own software for digitization. Alternatively, you can manually construct an "elec" electrode definition. best regards Robert PS please upgrade to a recent fieldtrip version, the sourceanalysis options cfg.xgrid/ygrid/zgrid have been renamed. The old options still will work, but in general it is preferable to work with a recent copy of the toolbox. From muthuraman10 at HOTMAIL.COM Thu Jul 13 13:11:35 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Thu, 13 Jul 2006 11:11:35 +0000 Subject: DICS In-Reply-To: <43B3E5A4-716B-48A0-8CE0-5F8810DC4A65@fcdonders.ru.nl> Message-ID: Hello Thankyou for the suggestions I have dowloaded the latest version now and i am working with it i have created the own elec file which is "elec1" and these are the steps i follow please go through it and reply me, why is the error -First i calculate the coherence using the freqanalysis and freqdescriptives which works perfectly -Second i calculate the Grid using Prepare_leadfield vol = []; vol.r = 12 * [0.88 0.92 1.00]; vol.c = [1 1/80 1]; vol.o = [0 0 0]; >>cfg1 = []; cfg1.elec = elec1; cfg1.vol = vol; cfg1.resolution = 2; grid = prepare_leadfield(cfg1); which also works i get the output for the Grid -Third I want use the source analysis for the DICS cfg.method='dics'; cfg.grid=grid; cfg.elecfile=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmfft); using headmodel specified in the configuration ??? Error using ==> fprintf Function is not defined for 'struct' inputs. Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 310 fprintf('reading electrodes from file %s\n', cfg.elecfile); Error in ==> sourceanalysis at 574 [vol, sens, cfg] = prepare_vol_sens(cfg, data); -I also tried grid using the freqmtmfft-which as the results for the freqanalysis vol = []; vol.r = 12 * [0.88 0.92 1.00]; vol.c = [1 1/80 1]; vol.o = [0 0 0]; >>cfg1 = []; cfg1.elec = elec1; cfg1.vol = vol; cfg1.resolution = 2; grid = prepare_leadfield(cfg1,freqmtmfft); I get error using headmodel specified in the configuration using electrodes specified in the configuration ??? Error using ==> delaunayn Not enough unique points to do tessellation. Error in ==> delaunay at 49 tri = delaunayn([x(:) y(:)]); Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 330 elec.tri = delaunay(elec.prj(:,1), elec.prj(:,2)); Error in ==> prepare_leadfield at 179 [vol, sens, cfg] = prepare_vol_sens(cfg, data); Thanking you with regards Muthuraman. >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] DICS >Date: Tue, 11 Jul 2006 17:51:28 +0200 > >Dear Muthuraman > >On 11 Jul 2006, at 16:59, Muthuraman Muthuraman wrote: >>To use the DICS method >> >>We have a 64 channel EEG measurement from (Neuroscan) and 4 EMG channels >>recording >>and also we have the 64 channel measurement in FRMI >> >>the electrode locations we have it in a file with 3 columns x,y,z for >>each electrode >>using the polhemus sensors but our own software >> >>In the Source analysis >>Cfg.method='DICS'; >>but Cfg.xgrid, ygrid and zgrid >>the grid values are the sensor location values >> >>or it should be the >>cfg.grid.pos-where i can give in the 3 values [x y z] for each electrode > >in SOURCEANALYSIS you specify using cfg.xgrid/ygrid/zgrid the locations at >which the _dipoles_ will be placed, it is not the position of the >electrodes. At each grid location a spatial filter is constructed and the >power (and coherence) is computed. If you do not want to scan on a full >3-D grid, but on only a few dipole locations of interest, you can use >cfg.grid.pos to specify those dipole locations. > >The electrode positions are specified in the cfg.elec structure, or in the >cfg.elecfile filename. You can find more details on the definition of >electrode positions at http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? >id=fieldtrip:documentation:frequently_asked_questions#how_are_electrodes >_magnetometers_or_gradiometers_described > >Furthermore, you can try using the READ_FCDC_ELEC function for reading the >electrode locations, but probably taht will not work since youy are using >your own software for digitization. Alternatively, you can manually >construct an "elec" electrode definition. > >best regards >Robert > >PS please upgrade to a recent fieldtrip version, the sourceanalysis >options cfg.xgrid/ygrid/zgrid have been renamed. The old options still >will work, but in general it is preferable to work with a recent copy of >the toolbox. From r.oostenveld at FCDONDERS.RU.NL Fri Jul 14 11:37:47 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 14 Jul 2006 11:37:47 +0200 Subject: DICS In-Reply-To: Message-ID: On 13 Jul 2006, at 13:11, Muthuraman Muthuraman wrote: > cfg.method='dics'; > cfg.grid=grid; > cfg.elecfile=elec1; > cfg.vol=vol; > [source]=sourceanalysis(cfg,freqmtmfft); > using headmodel specified in the configuration > ??? Error using ==> fprintf > Function is not defined for 'struct' inputs. > > Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 310 > fprintf('reading electrodes from file %s\n', cfg.elecfile); You should specify either cfg.elecfile with a string (filename) or cfg.elec with a structure (i.e. cfg.elec.pnt and cfg.elec.label) > I get error > > using headmodel specified in the configuration > using electrodes specified in the configuration > ??? Error using ==> delaunayn > Not enough unique points to do tessellation. > > Error in ==> delaunay at 49 > tri = delaunayn([x(:) y(:)]); > > Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 330 > elec.tri = delaunay(elec.prj(:,1), elec.prj(:,2)); > > Error in ==> prepare_leadfield at 179 > [vol, sens, cfg] = prepare_vol_sens(cfg, data); That indicates that less than 3 electrodes were selected. Probably there is a mismatch between the channel names in the data and the names of the electrodes. FT selects the channels and electrodes based on the corresponding labels, if they do not correspond then no channels+electrodes are selected. Robert From muthuraman10 at HOTMAIL.COM Mon Jul 17 16:12:14 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Mon, 17 Jul 2006 14:12:14 +0000 Subject: DICS In-Reply-To: <242E1EA4-D9FE-42D8-B23A-B689CBBF7FA8@fcdonders.ru.nl> Message-ID: Hello Thankyou for pointing out errors now i am able to calculate the Grid values but when i wanted to use the source analysis for the freqmtmwelch cfg.frequency=5; cfg.refchannel='C1'; cfg.refdip=10; cfg.method='dics'; cfg.grid=grid; cfg.elec=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmwelch); using headmodel specified in the configuration using electrodes specified in the configuration 42 dipoles inside, 18 dipoles outside brain I get the error ??? Reference to non-existent field 'cumtapcnt'. Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 Ntrials = length(freq.cumtapcnt); Error in ==> sourceanalysis at 663 [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); when i use the mtmfft i get the cumtapcnt values but not when using the mtmwelch is this a problem in the mtmwelch or i am doing something wrong Please go through it thanking you with regards muthuraman >From: Robert Oostenveld >Reply-To: FieldTrip discussion list >To: FIELDTRIP at NIC.SURFNET.NL >Subject: Re: [FIELDTRIP] DICS >Date: Fri, 14 Jul 2006 11:37:47 +0200 > >On 13 Jul 2006, at 13:11, Muthuraman Muthuraman wrote: > >>cfg.method='dics'; >>cfg.grid=grid; >>cfg.elecfile=elec1; >>cfg.vol=vol; >>[source]=sourceanalysis(cfg,freqmtmfft); >>using headmodel specified in the configuration >>??? Error using ==> fprintf >>Function is not defined for 'struct' inputs. >> >>Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 310 >> fprintf('reading electrodes from file %s\n', cfg.elecfile); > >You should specify either cfg.elecfile with a string (filename) or >cfg.elec with a structure (i.e. cfg.elec.pnt and cfg.elec.label) > >>I get error >> >>using headmodel specified in the configuration >>using electrodes specified in the configuration >>??? Error using ==> delaunayn >>Not enough unique points to do tessellation. >> >>Error in ==> delaunay at 49 >> tri = delaunayn([x(:) y(:)]); >> >>Error in ==> fieldtrip-20060712\private\prepare_vol_sens at 330 >> elec.tri = delaunay(elec.prj(:,1), elec.prj(:,2)); >> >>Error in ==> prepare_leadfield at 179 >>[vol, sens, cfg] = prepare_vol_sens(cfg, data); > >That indicates that less than 3 electrodes were selected. Probably there >is a mismatch between the channel names in the data and the names of the >electrodes. FT selects the channels and electrodes based on the >corresponding labels, if they do not correspond then no >channels+electrodes are selected. > >Robert From floris.delange at FCDONDERS.RU.NL Tue Jul 25 10:24:18 2006 From: floris.delange at FCDONDERS.RU.NL (Floris de Lange) Date: Tue, 25 Jul 2006 10:24:18 +0200 Subject: sourcestatistics question Message-ID: Dear FieldTrippers, I have a question concerning sourcestatistics. I have calculated the source localization using DICS for 11 individual subjects. Now I would like to test for the significance of the sources using sourcestatistics. The examples I find in the tutorial are about checking for significance within one subject by shuffling the individual trials. However, what I would like to do is to do the statistics on the 2nd level (subject), and to test for the consistency of the source reconstructions across subjects. Is this possible with sourcestatistics? If so, how should I feed the data to sourcestatistics? If I say something like stats = sourcestatistics(cfg,sources{1:11}) where each source{} is a normalized source (calculated by sourceanalysis, normalized with sourceinterpolate), it complains (rightfully) that there's a reference to the non-existing field 'statistic'. Any ideas are greatly appreciated! Kind regards, Floris From muthuraman10 at HOTMAIL.COM Tue Jul 25 10:34:30 2006 From: muthuraman10 at HOTMAIL.COM (Muthuraman Muthuraman) Date: Tue, 25 Jul 2006 08:34:30 +0000 Subject: Source anaylsis In-Reply-To: <242E1EA4-D9FE-42D8-B23A-B689CBBF7FA8@fcdonders.ru.nl> Message-ID: Hello Thankyou for pointing out errors now i am able to calculate the Grid values but when i wanted to use the source analysis for the freqmtmwelch cfg.frequency=5; cfg.refchannel='C1'; cfg.refdip=10; cfg.method='dics'; cfg.grid=grid; cfg.elec=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmwelch); using headmodel specified in the configuration using electrodes specified in the configuration 42 dipoles inside, 18 dipoles outside brain I get the error ??? Reference to non-existent field 'cumtapcnt'. Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 Ntrials = length(freq.cumtapcnt); Error in ==> sourceanalysis at 663 [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); when i use the mtmfft i get the cumtapcnt values i get a error when using the mtmfft for source analysis cfg.frequency=5; cfg.refchannel='C1'; cfg.refdip=10; cfg.method='dics'; cfg.grid=grid; cfg.elec=elec1; cfg.vol=vol; [source]=sourceanalysis(cfg,freqmtmfft); using headmodel specified in the configuration using electrodes specified in the configuration 610 dipoles inside, 600 dipoles outside brain ??? Error using ==> fieldtrip-20060712\private\prepare_freq_matrices The cross-spectral-density matrix is not complete Error in ==> sourceanalysis at 663 [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); Please go through it Because for the DICS i would like to use the freqmtmwelch is this a problem with freqmtmwelch or something wrong in my inputs thanking you with regards muthuraman From r.oostenveld at FCDONDERS.RU.NL Tue Jul 25 12:18:48 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 25 Jul 2006 12:18:48 +0200 Subject: DICS In-Reply-To: Message-ID: Hi Muthuraman The cumulative number of tapers per trial is indeed not kept in mtmwelch. You should specify it manually prior to freqanalysis. I do not recall whether you use keeptrials and keeptapers but if not, then it is safe to specify freq.cumtapcnt=1. Keeping count of the number of trials and tapers in the various freqanalysis methods is not done consistenly, it is something that we will improve in the future. best regards, Robert On 17 Jul 2006, at 16:12, Muthuraman Muthuraman wrote: > I get the error > > ??? Reference to non-existent field 'cumtapcnt'. > > Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 > Ntrials = length(freq.cumtapcnt); > > Error in ==> sourceanalysis at 663 > [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); > > when i use the mtmfft i get the cumtapcnt values > but not when using the mtmwelch is this a problem in the mtmwelch > or i am doing something wrong From r.oostenveld at FCDONDERS.RU.NL Tue Jul 25 12:29:23 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 25 Jul 2006 12:29:23 +0200 Subject: sourcestatistics question In-Reply-To: <44C5D532.4020708@fcdonders.ru.nl> Message-ID: Hi Floris, On 25 Jul 2006, at 10:24, Floris de Lange wrote: > I have a question concerning sourcestatistics. > I have calculated the source localization using DICS for 11 > individual subjects. Now I would like to test for the significance > of the sources using sourcestatistics. The examples I find in the > tutorial are about checking for significance within one subject by > shuffling the individual trials. However, what I would like to do > is to do the statistics on the 2nd level (subject), and to test for > the consistency of the source reconstructions across subjects. > Is this possible with sourcestatistics? Yes, that is possible. > If so, how should I feed the data to sourcestatistics? If I say > something like stats = sourcestatistics(cfg,sources{1:11}) where > each source{} is a normalized source (calculated by sourceanalysis, > normalized with sourceinterpolate), it complains (rightfully) that > there's a reference to the non-existing field 'statistic'. Assuming you want to use a randomization test to get a Monte-Carlo estimate of the probability of your null-hypothesis (cfg.method='montecarlo'), cfg.statistic should be a string describing the statistic whose randomization distribution you want to compute. See the help of statistic_montecarlo. Furthermore, the hypothesis that you want to test is about two conditions. That means that the two conditions both should be fed into sourcestatistics, e.g. something like for i=1:11 read data from condition 1 for each subject cond1{i} = sourceanalysis(...) cond1{i} = sourceinterpolate(...) cond1{i} = volumenormalize(...) read data from condition 2 for each subject cond2{i} = sourceanalysis(...) cond2{i} = sourceinterpolate(...) cond2{i} = volumenormalize(...) end cfg = [] cfg.design = [1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 % condition number 1 2 3 4 5 ..... 1 2 3 4 5 .... ] % subject number cfg.method = 'montecarlo' cfg.statistic = 'depsamplesT' cfg.ivar = 1; % row with the independent variable (condition) in the design cfg.uvar = 2; % row with the unit of observation (subject) in the design matrix stat = sourcestatistics(cfg, cond1{:}, cond2{:}); It is also possible to do other tests, which are more in line with a 2nd level analysis (e.g. compute t-maps per subject and test over subjects). It is better to discuss those face-to-face. best regards, Robert From Jan.Schoffelen at FCDONDERS.RU.NL Tue Jul 25 12:32:38 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Tue, 25 Jul 2006 12:32:38 +0200 Subject: DICS In-Reply-To: <4442BD57-7F97-469F-990B-CD63E171E371@fcdonders.ru.nl> Message-ID: Dear Muthuraman, One little addition to the freq.cumtapcnt-story. freq.cumtapcnt should be a vector instead of a scalar: the correct way to specify it would be: freq.cumtapcnt = ones(ntrl,1) with ntrl the number of trials in your data. Yours, Jan-Mathijs -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Robert Oostenveld Sent: Tuesday, July 25, 2006 12:19 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: Re: [FIELDTRIP] DICS Hi Muthuraman The cumulative number of tapers per trial is indeed not kept in mtmwelch. You should specify it manually prior to freqanalysis. I do not recall whether you use keeptrials and keeptapers but if not, then it is safe to specify freq.cumtapcnt=1. Keeping count of the number of trials and tapers in the various freqanalysis methods is not done consistenly, it is something that we will improve in the future. best regards, Robert On 17 Jul 2006, at 16:12, Muthuraman Muthuraman wrote: > I get the error > > ??? Reference to non-existent field 'cumtapcnt'. > > Error in ==> fieldtrip-20060712\private\prepare_freq_matrices at 124 > Ntrials = length(freq.cumtapcnt); > > Error in ==> sourceanalysis at 663 > [Cf, Cr, Pr, Ntrials, cfg] = prepare_freq_matrices(cfg, data); > > when i use the mtmfft i get the cumtapcnt values > but not when using the mtmwelch is this a problem in the mtmwelch > or i am doing something wrong From r.oostenveld at FCDONDERS.RU.NL Tue Jul 25 12:32:52 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Tue, 25 Jul 2006 12:32:52 +0200 Subject: Source anaylsis In-Reply-To: Message-ID: On 25 Jul 2006, at 10:34, Muthuraman Muthuraman wrote: > ??? Error using ==> fieldtrip-20060712\private\prepare_freq_matrices > The cross-spectral-density matrix is not complete this indicates that you did not include all channel combinations (cfg.channelcmb) in freqanalysis, and that you try to use a cross spectral density matrix for DISC that is not complete (i.e. come cross-spectra are missing). You should correct your configuration for the frequencyanalysus (e.g. cfg.channelcmb = {'all' 'all'} or see the CHANNELCOMBINATION function). best regards, Robert From jciveira at UNAV.ES Tue Jul 25 14:22:36 2006 From: jciveira at UNAV.ES (Juan Civeira) Date: Tue, 25 Jul 2006 14:22:36 +0200 Subject: Source anaylsis In-Reply-To: <77E33A56-A0D4-43FC-94E0-91A3AC31197B@fcdonders.ru.nl> Message-ID: I have the same problem and I do not know how to fix it, even though I tried your solution with cfg.channelcmb. My case is : i have a set of 82 electrodes, I make freqanalysis with cfg.channelcmb = channelcombination({'all' 'all'},data.label); thus I get freq = label: {82x1 cell} dimord: 'chan_freq' freq: [14 14.4000 14.8000 15.2000 15.6000 16 16.4000 16.8000 17.2000 17.6000 18] powspctrm: [82x11 double] labelcmb: {3321x2 cell} crsspctrm: [3321x11 double] cfg: [1x1 struct] When I make sourceanalysis with a dipole as a reference and I have no problems but when I want to use a channel as a reference I always have the same error: The cross-spectral-density matrix is not complete. Can you help me? Best regards Juan Robert Oostenveld ha escrito: > On 25 Jul 2006, at 10:34, Muthuraman Muthuraman wrote: > >> ??? Error using ==> fieldtrip-20060712\private\prepare_freq_matrices >> The cross-spectral-density matrix is not complete > > this indicates that you did not include all channel combinations > (cfg.channelcmb) in freqanalysis, and that you try to use a cross > spectral density matrix for DISC that is not complete (i.e. come > cross-spectra are missing). You should correct your configuration for > the frequencyanalysus (e.g. cfg.channelcmb = {'all' 'all'} or see the > CHANNELCOMBINATION function). > > best regards, > Robert ---------------------------------------------------------------- Este mensaje ha sido enviado desde https://webmail.unav.es From stephan.bickel at ANATOM.UNIZH.CH Tue Jul 25 17:39:32 2006 From: stephan.bickel at ANATOM.UNIZH.CH (Stephan Bickel) Date: Tue, 25 Jul 2006 17:39:32 +0200 Subject: import bva time-freq data Message-ID: Hi, I try to import brainvision analyzer dat files of wavelet time-frequency decompositions into fieldtrip. I exported an average file, so it consists only of a single segment. However I have some problems with it I am not sure if it is because I define the segment wrong or if it is not possible to import this data into fieldtrip. I pasted the code and the error message below and attached the marker- and header file. I would be really glad for any suggestions. Thank you very much, Stephan This is what I tried: cfg = []; cfg.headerfile =... 'c:\HumanEEG_data\Vision_Exports\WT_all_ft_test.vhdr'; cfg.datafile =... 'c:\HumanEEG_data\Vision_Exports\WT_all_ft_test.dat'; cfg.channel = 'all'; %Trialdefinition cfg.trialdef.trgfile =... 'c:\HumanEEG_data\Vision_Exports\WT_all_ft_test.vmrk'; cfg.trialdef.stim = 'New Segment'; %cfg.trialdef.segment = 'yes'; cfg.trialdef.timezero = 'yes'; % cfg.trialdef.eventtype = 'Time 0'; cfg.trialdef.prestim = 0.500; cfg.trialdef.poststim = 1.600; [cfg] = definetrial(cfg) [raw] = preprocessing(cfg) and this is the error message: evaluating trialfunction 'trialfun_brainvision' 0 stimulus markers converted into 0 trials 0 response markers converted into 0 trials 1 segment markers converted into 0 trials 1 "Time 0" markers converted into 1 trials found 0 events created 1 trials cfg = headerfile: [1x88 char] datafile: [1x87 char] channel: 'all' trialdef: [1x1 struct] dataset: [] trialfun: 'trialfun_brainvision' event: [] trl: [1 1051 -250] version: [1x1 struct] retaining exist trial definition retaining exist event information found 0 events created 1 trials rejected 0 trials completely rejected 0 trials partially resulting 1 trials reading and preprocessing reading and preprocessing trial 1 from 1 ??? Subscripted assignment dimension mismatch. Error in ==> fieldtrip-20060330\private\read_brainvision_eeg at 65 dat(line,:) = str2num(str); Error in ==> read_fcdc_data at 419 dat = read_brainvision_eeg(datafile, hdr, begsample, endsample); Error in ==> preprocessing at 322 dat = read_fcdc_data(cfg.datafile, hdr, begsample, endsample, rawindx, iscontinuous); -------------- next part -------------- A non-text attachment was scrubbed... Name: WT_all_ft_test.vmrk Type: application/octet-stream Size: 741 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: WT_all_ft_test.vhdr Type: application/octet-stream Size: 3459 bytes Desc: not available URL: From r.oostenveld at FCDONDERS.RU.NL Wed Jul 26 09:07:03 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 26 Jul 2006 09:07:03 +0200 Subject: Source anaylsis In-Reply-To: <20060725142236.lz6o47hwkkwo4sw4@webmail.unav.es> Message-ID: On 25 Jul 2006, at 14:22, jciveira at unav.es wrote: > I have the same problem and I do not know how to fix it, even > though I tried your solution with cfg.channelcmb. > > My case is : i have a set of 82 electrodes, I make freqanalysis > with cfg.channelcmb = channelcombination({'all' > 'all'},data.label); thus I get > > freq = > > label: {82x1 cell} > dimord: 'chan_freq' > freq: [14 14.4000 14.8000 15.2000 15.6000 16 16.4000 > 16.8000 17.2000 17.6000 18] > powspctrm: [82x11 double] > labelcmb: {3321x2 cell} > crsspctrm: [3321x11 double] > cfg: [1x1 struct] > > When I make sourceanalysis with a dipole as a reference and I have > no problems but when I want to use a channel as a reference I > always have the same error: > The cross-spectral-density matrix is not complete. > > Can you help me? > > Best regards > Juan Dear Juan Do you have 82 EEG electrodes, or 81 and one EMG electrode? I would expect the latter, since computing coherence between one particular EEG electrode and sources in the brain with DICS will not lead to meaningfull results. The selected EEG electrode will pick up volume- conducted activity from all sources in the brain (as opposed to an EMG electrode) and would be referenced to the same reference electrode as all other electrodes. So there will be a huge amount of trivial coherence, whose spatial distribution in the brain will probably more reflect the volume-conduction than something physiologically interpretable. Although I have not used DICS with a reference channel on EEG data, I would expect the code to work if you follow a procedure like this: cfg = ... trial selection stuff cfg = definetrial(cfg) cfg = ... preprocessing stuff cfg.channel = list of all EEG electrodes cfg.implicitref = name of implicit reference electrode used for the EEG channels cfg.reref = 'all' % rereference all EEG electrodes to an average reference data_eeg = preprocessing(cfg) cfg = ... trial selection stuff cfg = definetrial(cfg) cfg = ... preprocessing stuff cfg.channel = list of all EMG electrodes, assuming that they are bipolar channels % cfg.reref may be used if you have two unipolar channels on the muscle of interest cfg.rectify = 'yes' % this makes the spiky nature of the EMG more visible, and improves the coherence estimate cfg.baseline = 'yes' % remove baseline prior to rectification, not neccessary but still preferable data_emg = preprocessing(cfg) % combine EEG and EMG in one dataset, both are referenced differently data = appenddata([], data_eeg, data_emg); cfg = ... frequency analysis stuff cfg.ouptu = 'powandcsd' cfg.channelcmb = {'all', 'all'} freq = freqanalysis(cfg, data); cfg = ... source specific settings cfg.refchan = one of your bipolar EMG channels cfg.channel = all your EEG channels source = sourceanalysis(cfg, freq) best regards, Robert From r.oostenveld at FCDONDERS.RU.NL Wed Jul 26 09:46:59 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 26 Jul 2006 09:46:59 +0200 Subject: import bva time-freq data In-Reply-To: Message-ID: Hi Stephan, On 25 Jul 2006, at 17:39, Stephan Bickel wrote: > I try to import brainvision analyzer dat files of wavelet time- > frequency > decompositions into fieldtrip. I exported an average file, so it > consists > only of a single segment. However I have some problems with it I am > not sure ... > cfg.trialdef.trgfile = 'c:\HumanEEG_data\Vision_Exports > \WT_all_ft_test.vmrk'; > cfg.trialdef.stim = 'New Segment'; > %cfg.trialdef.segment = 'yes'; > cfg.trialdef.timezero = 'yes'; > % cfg.trialdef.eventtype = 'Time 0'; In general I would recommend to use the trialfun_general instead of the trialfun_brainvision (but the latter should also work). The trialfun_general was written later and will work for any dataformat that is supported by read_fcdc_event, the trialfun_brainvision is only there to support old scripts (i.e. scripts that predate the read_fcdc_event function). If not specified manually as trialfun, the trialfun_general or trialfun_brainvision is selected automatically based on the cfg settings. In your case you could do cfg.trialdef.eventtype = 'New Segment' or 'Time 0' cfg.trialdef.prestim = number, latency in seconds (optional) cfg.trialdef.poststim = number, latency in seconds (optional) See teh help of DEFINETRIAL. But in your case this is not the problem. The problem lies in > cfg.trialdef.prestim = 0.500; > cfg.trialdef.poststim = 1.600; If I do event = read_fcdc_event('WT_all_ft_test.vmrk') then I see that >> event(1) ans = type: 'New Segment' value: '1' sample: 1 duration: 0 offset: [] >> event(2) ans = type: 'Time 0' value: '251' sample: 1 duration: 0 offset: [] The 'New Segment' event is at sample 1, hence you cannot select a 500ms pre-stimulus window before it (you cannot read before the beginning of the data). The alternative 'Time 0' event is also at sample 1. It specifies a value of 251, which surprises me. I would expect that event to be present at sample 251. Reading the marker file with a text editor, I see (abbreviated) the explanation Mk=,,,, , and the markers Mk1=New Segment,,1,1,0,00000000000000000000 Mk2=Time 0,,251,1,0 So Mk2 should indeed be at sample 251. With the matlab debugger in the private/read_event.m file (around line 164) I notice that the problem lies in the missing value of the second field, i.e. Mk2=Time 0,,251,1,0 is interpreted as Mk2=Time 0,251,1,0 (one comma less) All fields are shifted by one, resulting in the sample number being interpreted as the description (i.e. value). I have fixed it in read_event, by replacing line 151 from tok = tokenize(line, '='); into tok = tokenize(line, '=', 0); % do not squeeze repetitions of the seperator and by replacing line 157 from tok = tokenize(tok{2}, ','); into tok = tokenize(tok{2}, ',', 0); % do not squeeze repetitions of the seperator i.e. both calls to the tokenize function now use the third argument. You can apply the same change to your copy, but please check that you have an up to date version of tokenize that accepts 3 input arguments (tokenize is in private as well). I will include the bug fix in the upcoming nightly release of FieldTrip. Better upgrade tomorrow to the latest FT version from the FTP server. I think that sofar it was not noticed since people here at the Donders typically use triggers as markers in their Brainvision data, and in case of triggers the second field would not be empty. If I now do cfg = []; cfg.dataset = 'WT_all_ft_test.vhdr' cfg.trialdef.eventtype = 'Time 0' cfg.trialdef.prestim = 0.5000 cfg.trialdef.poststim = 1 cfg = definetrial(cfg) I get evaluating trialfunction 'trialfun_general' found 2 events created 1 trials cfg = dataset: 'WT_all_ft_test.vhdr' trialdef: [1x1 struct] datafile: [] headerfile: 'WT_all_ft_test.vhdr' trialfun: 'trialfun_general' event: [1x2 struct] trl: [1 750 -250] version: [1x1 struct] which is correct. The trial (cfg.trl) runs from sample 1 to sample 750 in the data file, and the first sample of that trial corresponds with time cfg.trl(1,3)/fsample=-0.500 seconds. Thanks for reporting the bug, Robert From stephan.bickel at ANATOM.UNIZH.CH Wed Jul 26 17:28:54 2006 From: stephan.bickel at ANATOM.UNIZH.CH (Stephan Bickel, Anatomisches Inst.) Date: Wed, 26 Jul 2006 11:28:54 -0400 Subject: import bva time-freq data In-Reply-To: <30468A0B-0B5C-41EF-9FB3-84FD50036A22@fcdonders.ru.nl> Message-ID: Hi Robert, thank you very much for your response and for fixing the bug. Reading in the trial information works fine now. Unfortunately I encounter another problem when I want to read in the data with preprocessing. I wonder if it is yet possible to read in time-frequency data from bva-dat files? Sorry for bothering you again and thank you very much in advance. Stephan So when I do: cfg = []; cfg.dataset = 'WT_all_ft_test.vhdr' cfg.trialdef.eventtype = 'Time 0' cfg.trialdef.prestim = 0.5000 cfg.trialdef.poststim = 1 cfg = definetrial(cfg) cfg.datafile = 'WT_all_ft_test.dat'; cfg.channel = 'all'; [raw] = preprocessing(cfg) I get: cfg = dataset: 'WT_all_ft_test.vhdr' trialdef: [1x1 struct] datafile: 'WT_all_ft_test.dat' headerfile: 'WT_all_ft_test.vhdr' trialfun: 'trialfun_general' event: [1x2 struct] trl: [1 750 -250] version: [1x1 struct] channel: 'all' retaining exist trial definition retaining exist event information found 2 events created 1 trials rejected 0 trials completely rejected 0 trials partially resulting 1 trials reading and preprocessing reading and preprocessing trial 1 from 1 ??? Subscripted assignment dimension mismatch. Error in ==> fieldtrip-20060725\private\read_brainvision_eeg at 65 dat(line,:) = str2num(str); Error in ==> fieldtrip-20060725\private\read_data at 239 dat = read_brainvision_eeg(filename, hdr, begsample, endsample); Error in ==> read_fcdc_data at 49 [dat] = read_data(varargin{:}); Error in ==> preprocessing at 366 dat = read_fcdc_data(cfg.datafile, hdr, begsample, endsample, rawindx, iscontinuous); On Wed, 26 Jul 2006 09:46:59 +0200 Robert Oostenveld wrote: > Hi Stephan, > > On 25 Jul 2006, at 17:39, Stephan Bickel wrote: >> I try to import brainvision analyzer dat files of wavelet time- >> frequency >> decompositions into fieldtrip. I exported an average file, so it >> consists >> only of a single segment. However I have some problems with it I am >> not sure > ... >> cfg.trialdef.trgfile = 'c:\HumanEEG_data\Vision_Exports >> \WT_all_ft_test.vmrk'; >> cfg.trialdef.stim = 'New Segment'; >> %cfg.trialdef.segment = 'yes'; >> cfg.trialdef.timezero = 'yes'; >> % cfg.trialdef.eventtype = 'Time 0'; > > In general I would recommend to use the trialfun_general instead of the >trialfun_brainvision (but the latter should also work). The > trialfun_general was written later and will work for any dataformat that >is supported by read_fcdc_event, the trialfun_brainvision is only there to >support old scripts (i.e. scripts that predate the read_fcdc_event >function). > > If not specified manually as trialfun, the trialfun_general or > trialfun_brainvision is selected automatically based on the cfg settings. >In your case you could do > cfg.trialdef.eventtype = 'New Segment' or 'Time 0' > cfg.trialdef.prestim = number, latency in seconds (optional) > cfg.trialdef.poststim = number, latency in seconds (optional) > See teh help of DEFINETRIAL. > > But in your case this is not the problem. The problem lies in >> cfg.trialdef.prestim = 0.500; >> cfg.trialdef.poststim = 1.600; > > If I do > event = read_fcdc_event('WT_all_ft_test.vmrk') > then I see that > > >> event(1) > ans = > type: 'New Segment' > value: '1' > sample: 1 > duration: 0 > offset: [] > > >> event(2) > ans = > type: 'Time 0' > value: '251' > sample: 1 > duration: 0 > offset: [] > > The 'New Segment' event is at sample 1, hence you cannot select a 500ms >pre-stimulus window before it (you cannot read before the beginning of the >data). The alternative 'Time 0' event is also at sample 1. It specifies a >value of 251, which surprises me. I would expect that event to be present >at sample 251. > > Reading the marker file with a text editor, I see (abbreviated) the > explanation > Mk=,,,, > , > and the markers > Mk1=New Segment,,1,1,0,00000000000000000000 > Mk2=Time 0,,251,1,0 > So Mk2 should indeed be at sample 251. > > With the matlab debugger in the private/read_event.m file (around line >164) I notice that the problem lies in the missing value of the second >field, i.e. > Mk2=Time 0,,251,1,0 > is interpreted as > Mk2=Time 0,251,1,0 (one comma less) > All fields are shifted by one, resulting in the sample number being > interpreted as the description (i.e. value). > > I have fixed it in read_event, by replacing line 151 from > tok = tokenize(line, '='); > into > tok = tokenize(line, '=', 0); % do not squeeze repetitions of the > seperator > and by replacing line 157 from > tok = tokenize(tok{2}, ','); > into > tok = tokenize(tok{2}, ',', 0); % do not squeeze repetitions of > the seperator > i.e. both calls to the tokenize function now use the third argument. You >can apply the same change to your copy, but please check that you have an >up to date version of tokenize that accepts 3 input arguments (tokenize is >in private as well). I will include the bug fix in the upcoming nightly >release of FieldTrip. Better upgrade tomorrow to the latest FT version >from the FTP server. > > I think that sofar it was not noticed since people here at the Donders >typically use triggers as markers in their Brainvision data, and in case >of triggers the second field would not be empty. > > If I now do > cfg = []; > cfg.dataset = 'WT_all_ft_test.vhdr' > cfg.trialdef.eventtype = 'Time 0' > cfg.trialdef.prestim = 0.5000 > cfg.trialdef.poststim = 1 > cfg = definetrial(cfg) > I get > evaluating trialfunction 'trialfun_general' > found 2 events > created 1 trials > cfg = > dataset: 'WT_all_ft_test.vhdr' > trialdef: [1x1 struct] > datafile: [] > headerfile: 'WT_all_ft_test.vhdr' > trialfun: 'trialfun_general' > event: [1x2 struct] > trl: [1 750 -250] > version: [1x1 struct] > which is correct. The trial (cfg.trl) runs from sample 1 to sample 750 in >the data file, and the first sample of that trial corresponds with time >cfg.trl(1,3)/fsample=-0.500 seconds. > > Thanks for reporting the bug, > Robert From r.oostenveld at FCDONDERS.RU.NL Thu Jul 27 09:26:26 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 27 Jul 2006 09:26:26 +0200 Subject: import bva time-freq data In-Reply-To: Message-ID: On 26 Jul 2006, at 17:28, Stephan Bickel, Anatomisches Inst. wrote: > thank you very much for your response and for fixing the bug. > Reading in the trial information works fine now. Unfortunately I > encounter another problem when I want to read in the data with > preprocessing. I wonder if it is yet possible to read in time- > frequency data from bva-dat files? ... > Error in ==> fieldtrip-20060725\private\read_brainvision_eeg at 65 > dat(line,:) = str2num(str); > > Error in ==> fieldtrip-20060725\private\read_data at 239 > dat = read_brainvision_eeg(filename, hdr, begsample, endsample); Hi Stephan, I have no idea how time-frequency data is stored in the BVA *.dat files. Even if the low-level reading function were to support it, the PREPROCESSING function at least would not be able to deal with it, since the data structure returned by preprocessing does not allow for 3D data (channelXtimeXfrequency). That type of data would have to be stored in a structure that is compatible with the output of FREQANALYSIS. The preprocessing function is made for raw continuous (or trial-based) data, and it happens to work as well for averaged ERP data, although it is not specifically made for that. For other external software (BESA, EEGLAB, LORETA) I have created xxx2fieldtrip functions, i.e. functions that import already processed data and format it into the fieldtrip structure that is most compatible with it. In this case I can imagine a BRAINVISION2FIELDTRIP function that would read your dat file and return a "freq" structure. Besides making a brainvision2fieldtrip function, it requires making either the read_brainvision_eeg smarter (or probably making a seperate read_brainvision_tfr function) and improving the detection of teh content of the BVA *.dat file. Please have a look in besa2fieldtrip to see how I approach it there. best regards, Robert From jciveira at UNAV.ES Thu Jul 27 18:54:27 2006 From: jciveira at UNAV.ES (Juan Civeira) Date: Thu, 27 Jul 2006 18:54:27 +0200 Subject: Source anaylsis In-Reply-To: <9A0AA0F8-A8AD-4958-B224-4E3547238053@FCDONDERS.RU.NL> Message-ID: Dear Robert: Thanks for your answer but my problems are still there. The main problem is that i can not use DICS with a reference channel on EEG data, no matter if the reference is an EEG channel or EMG or some other channel. I have taken my measures with 85 electrodes, some of them are EEG1010, some EOG and some other that I have placed myself. I do the freq analysis and then the source analysis. Then I can make another source analysis with refdip but there is always errors when I use refchan. I do not think is a problem of the reference , cos always the program says that the cross-spectral-density with the reference channel is not complete . I have done the freq analysis making cfg.channelcmb combinations of all channels with only one, so i make sure that the cross-spectral-density is complete,but when I make source analysis with that channel as a reference is the same. Searching in the code I have come up with the fact that the error is always the condition in line 195 of the function prepare_freq_matrices (version 2006/03/08). My idea is that there is a confussion because if we have a set of N channels and we make combinations with channelcombination, the result is N-1 combinations because we do not include the combination of the reference with itself. I hope i explain myself clear enough, anyway I am trying to fix the problem by myself but any help or suggestion will be great Juan Robert Oostenveld ha escrito: > On 25 Jul 2006, at 14:22, jciveira at unav.es wrote: >> I have the same problem and I do not know how to fix it, even >> though I tried your solution with cfg.channelcmb. >> >> My case is : i have a set of 82 electrodes, I make freqanalysis >> with cfg.channelcmb = channelcombination({'all' 'all'},data.label); >> thus I get >> >> freq = >> >> label: {82x1 cell} >> dimord: 'chan_freq' >> freq: [14 14.4000 14.8000 15.2000 15.6000 16 16.4000 >> 16.8000 17.2000 17.6000 18] >> powspctrm: [82x11 double] >> labelcmb: {3321x2 cell} >> crsspctrm: [3321x11 double] >> cfg: [1x1 struct] >> >> When I make sourceanalysis with a dipole as a reference and I have >> no problems but when I want to use a channel as a reference I >> always have the same error: >> The cross-spectral-density matrix is not complete. >> >> Can you help me? >> >> Best regards >> Juan > > Dear Juan > > Do you have 82 EEG electrodes, or 81 and one EMG electrode? I would > expect the latter, since computing coherence between one particular EEG > electrode and sources in the brain with DICS will not lead to > meaningfull results. The selected EEG electrode will pick up > volume-conducted activity from all sources in the brain (as opposed to > an EMG electrode) and would be referenced to the same reference > electrode as all other electrodes. So there will be a huge amount of > trivial coherence, whose spatial distribution in the brain will > probably more reflect the volume-conduction than something > physiologically interpretable. > > Although I have not used DICS with a reference channel on EEG data, I > would expect the code to work if you follow a procedure like this: > > cfg = ... trial selection stuff > cfg = definetrial(cfg) > cfg = ... preprocessing stuff > cfg.channel = list of all EEG electrodes > cfg.implicitref = name of implicit reference electrode used for the EEG > channels > cfg.reref = 'all' % rereference all EEG electrodes to an average reference > data_eeg = preprocessing(cfg) > > cfg = ... trial selection stuff > cfg = definetrial(cfg) > cfg = ... preprocessing stuff > cfg.channel = list of all EMG electrodes, assuming that they are > bipolar channels > % cfg.reref may be used if you have two unipolar channels on the muscle > of interest > cfg.rectify = 'yes' % this makes the spiky nature of the EMG more > visible, and improves the coherence estimate > cfg.baseline = 'yes' % remove baseline prior to rectification, not > neccessary but still preferable > data_emg = preprocessing(cfg) > > % combine EEG and EMG in one dataset, both are referenced differently > data = appenddata([], data_eeg, data_emg); > > cfg = ... frequency analysis stuff > cfg.ouptu = 'powandcsd' > cfg.channelcmb = {'all', 'all'} > freq = freqanalysis(cfg, data); > > cfg = ... source specific settings > cfg.refchan = one of your bipolar EMG channels > cfg.channel = all your EEG channels > source = sourceanalysis(cfg, freq) > > best regards, > Robert ---------------------------------------------------------------- Este mensaje ha sido enviado desde https://webmail.unav.es From r.oostenveld at FCDONDERS.RU.NL Fri Jul 28 09:49:55 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 28 Jul 2006 09:49:55 +0200 Subject: Source anaylsis In-Reply-To: <20060727185427.3r2gdy6zkk0o4og8@webmail.unav.es> Message-ID: Hi Juan > I do the freq analysis and then the source analysis. Then I can > make another source analysis with refdip but there is always errors > when I use refchan. I do not think is a problem of the reference , > cos always the program says that the cross-spectral-density with > the reference channel is not complete . > > I have done the freq analysis making cfg.channelcmb combinations of > all channels with only one, so i make sure that the > cross-spectral-density is complete,but when I make source analysis > with that channel as a reference is the same. > > Searching in the code I have come up with the fact that the error > is always the condition in line 195 of the function > prepare_freq_matrices (version 2006/03/08). My idea is that there is > a confussion because if we have a set of N channels and we make > combinations with channelcombination, the result is N-1 > combinations because we do not include the combination of the > reference with itself. Say for simplicity that you want EMG as refchan. In freqanalysis, cfg.channelcmb should be all with all. You need the CSD between all EEG channels (all EEG with all EEG), and of all EEG channels with the EMG. In prepare_freq_matrices the CSD matrix (Cf) of EEG with EEG is made (Neeg X Neeg), the CSD vector (Cr) of all EEG channels with the reference EMG channel (Neeg X 1), and the power of the reference channel (Pr). Together they could also be shaped in a (Neeg+1) X (Neeg +1) matrix in principle, but that is not done for DICS. I have tried it out myself, and cannot reproduce your problem. Please find my test script below. It uses some simulated EEG data. The beginning of the script is copied from http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? id=fieldtrip:documentation:compute_forward_simulated_data_and_apply_a_di pole_fit The initial part generates raw EEG data, then I add a EMG channel (with noise, but it is only to demonstrate that fieldtrip does not give an error), then I do freqanalysis and sourceanalysis. Please try out and compare my cfgs with yours, since I suspect your configuration to be the problem. best regards, Robert %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % create a set of electrodes, randomly placed on the sphere elec = []; elec.pnt = randn(128,3); dum = sqrt(sum(elec.pnt.^2,2)); elec.pnt = elec.pnt ./ [dum dum dum]; % scale them to a unit sphere for i=1:128 elec.label{i} = sprintf('%03d', i); end % create a concentric 3-sphere volume conductor, the radius is the same as for the electrodes vol = []; vol.r = [0.88 0.92 1.00]; % radii of spheres vol.c = [1 1/80 1]; % conductivity vol.o = [0 0 0]; % center of sphere % create a dipole simulation with one dipole and a 10Hz sine wave cfg = []; cfg.vol = vol; % see above cfg.elec = elec; % see above cfg.dip.pos = [0 0.5 0.3]; cfg.dip.mom = [1 0 0]'; % note, it should be transposed cfg.dip.frequency = 10; cfg.ntrials = 10; cfg.triallength = 1; % seconds cfg.fsample = 250; % Hz raw1 = dipolesimulation(cfg); using headmodel specified in the configuration using electrodes specified in the configuration selected 128 electrodes computing simulated data RMS value of simulated data is 0.0746553 %%%%%%%%%%%%%%%%%%%%%%%% %%%%% Here it starts deviating from the demo script on the wiki %%%% %%%%%%%%%%%%%%%%%%%%%%%% % add a fake EMG channel, containing noise for i=1:10 raw1.trial{i}(end+1,:) = randn(1,250); end raw1.label{end+1} = 'EMG' raw1 = trial: {1x10 cell} time: {1x10 cell} elec: [1x1 struct] fsample: 250 label: {1x129 cell} cfg: [1x1 struct] cfg = [] cfg.method = 'mtmfft'; cfg.taper = 'hanning'; cfg.foilim = [2 20]; cfg.output = 'powandcsd'; cfg.channelcmb = {'all', 'all'} cfg = method: 'mtmfft' taper: 'hanning' foilim: [2 20] output: 'powandcsd' channelcmb: {'all' 'all'} freq1 = freqanalysis(cfg, raw1) WARNING: using only one taper for specified smoothing processing trial 1, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 2, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 3, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 4, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 5, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 6, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 7, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 8, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 9, nfft: 250 samples, taper length: 250 samples, 1 tapers processing trial 10, nfft: 250 samples, taper length: 250 samples, 1 tapers freq1 = label: {1x129 cell} dimord: 'chan_freq' freq: [2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20] powspctrm: [129x19 double] labelcmb: {8256x2 cell} crsspctrm: [8256x19 double] elec: [1x1 struct] cfg: [1x1 struct] cfg = []; cfg.vol = vol; cfg.freq = 10; cfg.frequency = 10; cfg.method = 'dics'; cfg.refchan = 'EMG'; cfg.grid.resolution = 0.3 cfg = vol: [1x1 struct] freq: 10 frequency: 10 method: 'dics' refchan: 'EMG' grid: [1x1 struct] source1 = sourceanalysis(cfg, freq1) using headmodel specified in the configuration using electrodes specified in the data selected 128 electrodes 106 dipoles inside, 237 dipoles outside brain making tight grid 106 dipoles inside, 110 dipoles outside brain scanning repetition 1 scanning grid Warning: cross-spectral density matrix is rank deficient > In beamformer at 270 In sourceanalysis at 806 total time in sourceanalysis 75.4 seconds source1 = xgrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000] ygrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000] zgrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000] dim: [6 6 6] vol: [1x1 struct] frequency: 10 pos: [216x3 double] inside: [1x106 double] outside: [1x110 double] method: 'average' avg: [1x1 struct] cfg: [1x1 struct] diary off From floris.delange at FCDONDERS.RU.NL Fri Jul 28 13:01:00 2006 From: floris.delange at FCDONDERS.RU.NL (Floris de Lange) Date: Fri, 28 Jul 2006 13:01:00 +0200 Subject: sourcestatistics: what to compare? Message-ID: Dear Fieldtrippers, I have a question about what conditions/comparisons make most sense to statistically compare with sourcestatistics. I have 2 conditions, A and B, and each condtion has its own pre-stimulus baseline: basA and basB. Now, first I'd like to see which regions are showing stronger beta-band power during A than the baseline. So I want to compare A to basA. There's 2 ways of going about it: 1) compare (the grand average of) A.avg.pow with basA.avg.pow 2) compare (the grand average of) the neural activity index (NAI) of A with the baseline Any ideas which would be best? Or is this just an empirical issue? (i.e., take the best) To compare A and B, one has even more options: 1) compare A.avg.pow with B.avg.pow 2) compare (A.avg.pow/basA.avg.pow) with (B.avg.pow/basB.avg.pow) 3) compare NAI(A) with NAI(B) 4) compare NAI(A)/NAI(basA) with NAI(B)/NAI(basB) Is there's any principled reason for a priori picking any of the above choices? Your input is greatly appreciated, Kind regards, Floris From r.oostenveld at FCDONDERS.RU.NL Fri Jul 28 16:17:24 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 28 Jul 2006 16:17:24 +0200 Subject: sourcestatistics: what to compare? In-Reply-To: <44C9EE6C.8030003@fcdonders.ru.nl> Message-ID: Hi Floris On 28 Jul 2006, at 13:01, Floris de Lange wrote: > I have a question about what conditions/comparisons make most sense > to statistically compare with sourcestatistics. > I have 2 conditions, A and B, and each condtion has its own pre- > stimulus baseline: basA and basB. > > Now, first I'd like to see which regions are showing stronger beta- > band power during A than the baseline. So I want to compare A to > basA. There's 2 ways of going about it: > 1) compare (the grand average of) A.avg.pow with basA.avg.pow > 2) compare (the grand average of) the neural activity index (NAI) > of A with the baseline > > Any ideas which would be best? Or is this just an empirical issue? > (i.e., take the best) Both are valid, you could take the best. There are some exceptions/ predictions though that I can share with you: the NAI is power divided by estimated (projected) noise. It is inherently difficult to estimate the noise level (the default is the smallest singular value of the CSD matrix, but you can manipulate it with cfg.lambda in sourceanalysis). If you have different numbers of trials in active v.s. baseline, the noise estimate probably will be different. So then you would have NAIa = Pa/Na and NAIb = Pb/Nb, if Pa==Pb and Na~=Nb, these will be trivially different, which is not what you want (remember Pa==Pb was assumed). You can compare the projected noise in both conditions, the source- noise-estimate is uniformely scaled (i.e. on all voxels the same) with the estimated noise from the CSD. There is no reason to assume that the noise is different, so if the noise is different, you would have to explain that. > To compare A and B, one has even more options: > 1) compare A.avg.pow with B.avg.pow > 2) compare (A.avg.pow/basA.avg.pow) with (B.avg.pow/basB.avg.pow) > 3) compare NAI(A) with NAI(B) > 4) compare NAI(A)/NAI(basA) with NAI(B)/NAI(basB) > > Is there's any principled reason for a priori picking any of the > above choices? I presume that by "compare" you mean "look at the the difference". In general you should only use the NAI for plotting data if you only have one condition (and no baseline). The noise estimate that goes into the NAI is too poor to be of real value. Although sometines it looks nice in figures, the NAI tends not to be very robust (it contains global flucuations that mess up the statistic, although the figure still looks nice). The baseline is only interesting if you expect something differently to happen in the two baselines. If that is the case, you better try to get another baseline in your experimental design. If you would combine actA, basA, actB, basB into a single number, and that number would be significant, you still would not be able to tell whether the difference is betwen the active conditions, theis baselines, or some weird combination of the 4 "conditions" that you combine. Typically there is no reason to assume taht the baselines are different. So (A.avg.pow/basA.avg.pow) with (B.avg.pow/basB.avg.pow) = (A.avg.pow/basC.avg.pow) with (B.avg.pow/basC.avg.pow), where C means common = (A.avg.pow-B.avg.pow)/basC.avg.pow. I.e. you are comparing A and B directly, with a spatially normalizing for the different baseline-estimated noise at different source locations. Whether you want to spatially normalize (divide by some baseline estimated-source-power) depends on the leadfields (it is neccessary if cfg.normalize=no, if you want to do multiple comparison correction, and if you want to look at an additive effect). If you want to look at a multiplicative effect, you would look at the ratio between two conditions instead of the difference. The ratio of the conditions is best implemented with a log transform, after which you again can look at the difference between the log-transformed power estimates in both conditions (log(A/B) = log(A) - log(B)). In the ratio or log-ratio between the powers in both conditions you have also corrected for the spatial (depth) noise-bias. good luck with the stats, Robert PS as I am on holiday the next 2 weeks, you could ask Ingrid about more details on this. She is more or less at the same stage in her analysis (about to do group sourcestatistics), but I suspect that she already has more "feel" for these issues. Or ask JM.