From P.PRAAMSTRA at BHAM.AC.UK Sun Oct 1 14:08:41 2006 From: P.PRAAMSTRA at BHAM.AC.UK (Peter Praamstra) Date: Sun, 1 Oct 2006 13:08:41 +0100 Subject: clusterrandanalysis Message-ID: Dear Robert / other fieldtrippers, I´m looking for advice on the following. I´m trying to do clusterrandanalysis on TFR data with the cfg. statistic=´actvsblT´ option. The tutorial `Cluster-level randomization tests´ gives an example in which separate TFRs are calculated for activation and baseline data. The clusterrandanalysis.m documentation also states that two datasets must be passed. However, I´d like to make the activation vs baseline comparison work for baseline and activation TF windows identified in single TFRs that include a prestimulus and a poststimulus period. To do so, I used cfg. latency, cfg. frequency and cfg. keepindividual with freqgrandaverage to create separate datastructures for the baseline and activation timefrequency windows of interest. Unfortunately, this doesn´t work. I get an error message: ??? Error using ==> clusterrandanalysis Not all time points in the first data set are in the activation (post-stimulus) period. This is probably due to clusterrandanalysis expecting a positive time axis for the activation data and a negative time axis for the baseline data. Hence, although I defined TF windows of equal length for activation and baseline, it looks like Fieldtrip is unable to ignore the original, but irrelevant, time axis definition. I considered reading in the same data twice (through freqgrandaverage) with different definitions of the time axes. However, this would still require clusterrandanalysis to deal with activation and baseline TF windows that are not matched in time on the time axes of their respective datastructures. So I suspect it would still not work. Any advice on how I could work around this would be greatly appreciated. Best wishes, Peter Praamstra -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.siegel at UKE.UNI-HAMBURG.DE Mon Oct 2 09:59:01 2006 From: m.siegel at UKE.UNI-HAMBURG.DE (Markus Siegel) Date: Mon, 2 Oct 2006 09:59:01 +0200 Subject: freqanalysis_wltconvol.m In-Reply-To: <6.1.2.0.2.20060929123621.059feec0@email.med.yale.edu> Message-ID: Dear Brian, cfg.width determines in cycles the width of the Morlet-wavelet as the standard deviation of the underlying gaussian (often termed "q"). One can either use a fixed q for all frequencies by giving only one number in cfg.width, or one can use a different q for each frequency of interest with a vector in cfg.width of the same length as cfg.foi. "help freqanalysis_wltconvol" gives you the relationship between cfg.width (width) , the frequency of interest (f0) and the standard- deviation (resolution) of the wavelet-transform in the temporal (st) and spectral (sf) domain: The standard deviation in the frequency domain (sf) at frequency f0 is defined as: sf = f0/width The standard deviation in the temporal domain (st) at frequency f0 is defined as: st = width/f0 = 1/sf The spectral bandwidth (in standard deviations, Hz) of the time- frequency transform can thus be computed as: bw = cfg.foi ./ cfg.width; The parameter cfg.gwidth determines the length of the wavelet-kernel used in standard deviations of the underlying gaussian. In other words, it specifies over how many standard deviations the gaussian is estimated for the morlet-wavelet in both directions. This does in principle not influence the spectro-temporal resolution of the transform, but determines its precision because the gaussian is non- zero at the edges. Therefore, small values (e.g. <2) lead to edge effects in the transform. The full length of the 'longest' wavelet at the lowest frequency cfg.foi(1) is thus computed as: 2 * cfg.gwidth (cfg.width(1) ./ cfg.foi(1)) In freqanalysis_wltconvol, the wavelet transform is implemented by multiplication in the frequency domain which is computationally more efficient than convolution in the temporal domain. However, technically the transform is well described as a convolution of the time-series with a complex Morlet-wavelet (complex sinusoid with a gaussian envelope) as e.g. provided in Tallon-Baudry et al., J Neurosci 1997. Best, Markus Am 29.09.2006 um 18:52 schrieb Brian Roach: > Dear FieldTrip users, > > I have been playing with the freqanalysis_wltconvol function in > hopes of using the morlet wavelet time frequency analysis on some > eeg data. I have been able to get it running, and I find that it > works very quickly, which is great. However, I am hoping some > users or F.T. programmers can explain some of the function inputs > and processing. The cfg example is as follows: > > % cfg.method = 'wltconvol'; > % cfg.foi = 1:1:100; > % cfg.width = 7; > % or > % cfg.width = linspace(5,10,length(cfg.foi)); > % cfg.toi = 0:0.1:2; > % cfg.gwidth = 3; > > I believe that the cfg.width specifies the number of wave cycles > used in each frequency's wavelet analysis (so at 2Hz, 7 cycles > spans 3500ms of data, right?). Maybe this is not correct, because > I do not seem to get the frequencies as low as I would expect given > my data epoch length. Perhaps this has to do with the cfg.gwidth > parameter, which I do not think I completely understand - what is it? > > Also, we do not have the matlab wavelet toolbox, and it appears > that it is not required, but how is the morlet wavelet > implemented? As I look through the code I see calls to fft, ifft, > and fftshift, but I wonder how I can give a good technical > description of this process if I find results in a larger data set. > > Finally, is there a function or a way to compute the frequency > bandwidth based on the cfg inputs, or is there a fix frequency > bandwith for each foi here? I am sure I am confusing a number of > things here, so no response is too simple. > > Thanks for any advice, please let me know if there is more > information I can give or if I can clarify my questions. > > Brian > From r.oostenveld at FCDONDERS.RU.NL Mon Oct 2 21:03:53 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 2 Oct 2006 21:03:53 +0200 Subject: clusterrandanalysis In-Reply-To: <451FBDD9.31055.628453@P.PRAAMSTRA.Bham.ac.uk> Message-ID: Hi Peter > I’m trying to do clusterrandanalysis on TFR data with the cfg. > statistic=’actvsblT’ option. The tutorial ‘Cluster-level > randomization tests’ gives an example in which separate TFRs are > calculated for activation and baseline data. The > clusterrandanalysis.m documentation also states that two datasets > must be passed. I am not that familiar with comparing activation versus baseline using the actvsblT statistic (it was implemented by Eric) but as I understand it, the rationale behind it is that all timepoints in the baseline are equivalent to all timepoints in the activation period. I.e. there is no intrinsic reason to compare one specific baseline timepoint with one specific timepoint in the active period, hence it implements a comparison in which all timepoints in the baseline are collapsed/averaged, and the active period is compared to this average. From the FT homepage documentation (http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? id=fieldtrip:documentation:tutorial:clusterrandanalysis) >> With cfg.statistic=’actvsblT’, we choose the so-called activation- >> versus-baseline T-statistic. By means of this statistic, we >> compare the power in every (channel, frequency, time)-element in >> the activation period with the corresponding average power >> (average over time) in the baseline period. The comparison of the >> activation and the average baseline power is performed by means of >> a pairwise T-statistic, with the pairs corresponding to the trials. However, the approach that I usually take (and also explain to other people here) for comparing two time windows in the same dataset is to copy the dataset into a dummy dataset and shift the timeaxis of the dummy dataset. E.g. dat = preprocessing(..) avg = timelockanalysis(..) % with keeptrials act = avg; bas = avg; bas.time = bas.time + 0.500; % shift the time axis, here the sample corresponding with -500ms is shifted to 0ms stat = clusterrandanalysis(cfg, bas, act) The statistisc then becomes a regular depsamplesT (i.e. paired data in the baseline and activation window). E.g. in the above example you could do figure plot(act.time, act.avg, 'r'); % in red hold on plot(act.time, act.avg, 'b'); % in blue and you would see the two ERPs shifted in time. This plot also makes it easy to identify the timewindow in which to do the statistical test (default is to take all overlapping time that is present in the input data). > However, I’d like to make the activation vs baseline comparison > work for baseline and activation TF windows identified in single > TFRs that include a prestimulus and a poststimulus period. To do > so, I used cfg. latency, cfg. frequency and cfg. keepindividual > with freqgrandaverage to create separate datastructures for the > baseline and activation timefrequency windows of interest. Here I cannot follow you. You have two conditions, each with a baseline and an active period. What is the comparison taht you want to make? I would presume that you do not expect differences in the baseline. If there were an a priori difference in the baseline, then a difference in the active period would seem trivial to me. So to me teh logical assumption would be that the baselines are the same and that you want to compare either the whole time interval or (equally valid) only the active period. I can also imagine that you want to compare the TFR data in the active window after correcting for eventual differences in the baseline. This would involve first doing a (single trial) baseline correction (expressing the power in each trial as relative number compared to the average in the baseline). In FT we have the freqbaseline function, however, that function sofar did not support single-trial baseline coprrections (only averaged powspctrm would be corrected). Please find attached a freqbaseline that will also do it on single trial powspectra. hope this helps, Robert -------------- next part -------------- A non-text attachment was scrubbed... Name: freqbaseline.m Type: application/octet-stream Size: 9714 bytes Desc: not available URL: From maris at NICI.RU.NL Mon Oct 2 21:28:03 2006 From: maris at NICI.RU.NL (Eric Maris) Date: Mon, 2 Oct 2006 21:28:03 +0200 Subject: clusterrandanalysis In-Reply-To: <451FBDD9.31055.628453@P.PRAAMSTRA.Bham.ac.uk> Message-ID: Hi Peter, I'm trying to do clusterrandanalysis on TFR data with the cfg. statistic='actvsblT' option. The tutorial 'Cluster-level randomization tests' gives an example in which separate TFRs are calculated for activation and baseline data. The clusterrandanalysis.m documentation also states that two datasets must be passed. However, I'd like to make the activation vs baseline comparison work for baseline and activation TF windows identified in single TFRs that include a prestimulus and a poststimulus period. To do so, I used cfg. latency, cfg. frequency and cfg. keepindividual with freqgrandaverage to create separate datastructures for the baseline and activation timefrequency windows of interest. This I don't understand. In my terminology, "baseline" and "prestimulus" are synonymous, as are "activation" and "poststimulus". The activation-versus-baseline statistic identifies samples (i.e., (sensor,frequency,time)-elements) in the activation/poststimulus period that are different from the time-average of the corresponding samples in the baseline/prestimulus period. If you use freqgrandaverage to create an activation and a baseline datastructure of the same size (with a positive time-axis for the activation period, and a negative time-axis for the baseline period), then clusterrandanalysis should do the job. Greetings, Eric Maris -------------- next part -------------- An HTML attachment was scrubbed... URL: From P.PRAAMSTRA at BHAM.AC.UK Tue Oct 3 14:13:02 2006 From: P.PRAAMSTRA at BHAM.AC.UK (Peter Praamstra) Date: Tue, 3 Oct 2006 13:13:02 +0100 Subject: clusterrandanalysis Message-ID: Hi Robert, Eric, many thanks for your helpful comments. Robert's was especially useful. Implementing the suggestion to shift the time axis revealed a glitch in besa2fieldtrip that I should have spotted earlier. It doesn't convert ms in s. As a result, cfg.latency or cfg.toilim statements using seconds as time unit don't work properly. This peculiarity concerns BESA TFR data; I don't know about other BESA data formats. Best regards, Peter From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 10:37:32 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 10:37:32 +0200 Subject: attention: default changed for MEG leadfields Message-ID: Dear fieldtrippers, I want to bring to your attention that I just changed the default value for the option cfg.reducerank in the SOURCANALYSIS and the PREPARE_LEADFIELD functions. The old default was 'no', the new default depends on the type of data that you are working with. In case of EEG, the new default is 3. This basically is the same as 'no', since the intrinsic rank of the EEG leadfield for a dipole is 3. So effectively nothing changed here. In case of MEG, the new default is 2. This was the value that I always recommend when someone would ask me for it. To prevent people from accidentally forgetting to set it to 2, we now decided to change the default. The change is immediate for people within the Donders, and for the external users it will become visible in the daily fieldtrip version on the FTP server this evening. Background: The cfg.reducerank option relates to how the leadfields are computed, and is only relevant for MEG in combination with realistic (localspheres, singleshell) volume conduction models for the head. In Fieldtrip, we always work with dipoles that can be oriented in x, y, and z direction. The dipole orientation and strenghth together form the dipole mooment. There is one particular [x,y,z] direction for the dipole for which it points to the surface of the head, i.e. that is the radial component. The magnetic field for that radial component is zero (in a single sphere model), or almost zero (in a realistic model). Since sources that are almost zero pick up a lot of noise in the beamformer method, it is desirable to explicitely set the leadfield in that direction to exactly zero. That is done by the reducerank option, which ensures that the leadfield will only contain the two tangential components and which makes the radial component zero. best regards, Robert From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 10:44:10 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 10:44:10 +0200 Subject: clusterrandanalysis In-Reply-To: <452261DE.19934.F0AE74@P.PRAAMSTRA.Bham.ac.uk> Message-ID: Hi Peter On 3 Oct 2006, at 14:13, Peter Praamstra wrote: > Implementing the suggestion to shift the time > axis revealed a glitch in besa2fieldtrip that I should have spotted > earlier. It > doesn't convert ms in s. As a result, cfg.latency or cfg.toilim > statements > using seconds as time unit don't work properly. > > This peculiarity concerns BESA TFR data; I don't know about other BESA > data formats. There are many variations of the BESA format, which makes them difficult to support. Every couple of months, someone will contact me with yet another BESA file that is not fully supported :-( Fieldtrip always works with seconds and not with ms, hence it should be fixed. I expect the problem to be on line 141 of besa2fieldtrip, which now reads data = []; data.time = Time; data.freq = Frequency; and probably this should read data = []; data.time = Time * 1e-3; % convert to seconds data.freq = Frequency; Can you confirm this? best, Robert From MZvyagintsev at UKAACHEN.DE Wed Oct 4 12:38:00 2006 From: MZvyagintsev at UKAACHEN.DE (Mikhail Zvyagintsev) Date: Wed, 4 Oct 2006 12:38:00 +0200 Subject: MEG realign In-Reply-To: <2093A833-C89D-4DB0-9D53-FB43A9DAF4A2@fcdonders.ru.nl> Message-ID: Dear Robert / other fieldtrippers, I have a question regarding MEG realign procedure. I actually found it very useful and trying to learn how to deal with it. I am using 4 D Neuroimaging mashine (BTi), and, therefore, I had to change the routine a bit - at least change settings, concerning the sensors name. In my particular case I got the message 'mean distance towards template gradiometers is 25.45 mm'. (I actually attached a picture regarding sensors' position's difference derived from Matlab, but probably it is not so easy to recognize what is what on this picture - points are sensors and different colors - positions in different sessions, the view is from front). And later in this routine I use the approach based on calculation of brain surface from headshape. As a headshape we use here points from bridge (of nose) to nape (of the neck). I get 644 dipoles from it 'prunedinv' subfunction gives me 'pruning 49 out of 148 singular values' (so, we use 148 channels mashine). After calculation of realign matrix and applying it for 'realigning trial' the residual variance (RV) which I get for one trial is arround 30%. I have a feelling that it is rather to much, or might be it's normal, becouse difference between sensors is rather big one. Because in case 'mean distance towards template gradiometers' was 6.48 mm - residual variances were arround 5-6%. So, distance RV 6.48 mm 5-6% 25.45 mm ~30%. My question is - is such RV difference correspondent to the difference distance I have and how many points should be like a 'control value' for 'prunedinv' routine? Thank you in advance, Mikhail Zvyagintsev -- __________________________________________________________________ Mikhail Zvyagintsev MD, BSc Klinik für Psychiatrie & Psychotherapie UK Aachen Pauwelsstr. 30 D-52074 Aachen tel +49-0241-80 85580 FAX +49-0241-80 82401 MZvyagintsev at UKAachen.de -------------- next part -------------- A non-text attachment was scrubbed... Name: session 1 and 3 positions.tif Type: image/tiff Size: 706680 bytes Desc: not available URL: From P.PRAAMSTRA at BHAM.AC.UK Wed Oct 4 13:40:16 2006 From: P.PRAAMSTRA at BHAM.AC.UK (Peter Praamstra) Date: Wed, 4 Oct 2006 12:40:16 +0100 Subject: clusterrandanalysis In-Reply-To: Message-ID: hoi Robert, dat doet de truc natuurlijk. groeten, peter On 4 Oct 2006 at 10:44, Robert Oostenveld wrote: > Hi Peter > > On 3 Oct 2006, at 14:13, Peter Praamstra wrote: > > Implementing the suggestion to shift the time > > axis revealed a glitch in besa2fieldtrip that I should have > spotted > > earlier. It > > doesn't convert ms in s. As a result, cfg.latency or cfg.toilim > > statements > > using seconds as time unit don't work properly. > > > > This peculiarity concerns BESA TFR data; I don't know about other > BESA > > data formats. > > There are many variations of the BESA format, which makes them > difficult to support. Every couple of months, someone will contact > me > with yet another BESA file that is not fully supported :-( > > Fieldtrip always works with seconds and not with ms, hence it should > be fixed. I expect the problem to be on line 141 of besa2fieldtrip, > which now reads > data = []; > data.time = Time; > data.freq = Frequency; > and probably this should read > data = []; > data.time = Time * 1e-3; % convert to seconds > data.freq = Frequency; > > Can you confirm this? > > best, > Robert ###################################### Peter Praamstra, MD, PhD Reader in Cognitive Neurophysiology Honorary Consultant Neurology Behavioural Brain Sciences Centre School of Psychology, University of Birmingham Birmingham, B15 2TT tel. 0121 414 7211 fax 0121 414 4897 From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 14:36:09 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 14:36:09 +0200 Subject: MEG realign In-Reply-To: <45238F08.3060006@UKAachen.de> Message-ID: Hi Mikhail On 4 Oct 2006, at 12:38, Mikhail Zvyagintsev wrote: > I am using 4 D Neuroimaging mashine (BTi), and, therefore, I had to > change the routine a bit - at least change settings, concerning the > sensors name. Yes, I can imagine that, since it is using some pre-defined sensor names to construct the averaged template helmet position. Could you send me the change (private mail), then I will include it in FT. > (I actually attached a picture regarding sensors' position's > difference derived from Matlab, but probably it is not so easy to > recognize what is what on this picture - points are sensors and > different colors - positions in different sessions, the view is > from front). There is an option in MEGREALIGN that you can use for plotting something similar (cfg.plot3d=yes) > And later in this routine I use the approach based on calculation > of brain surface from headshape. As a headshape we use here points > from bridge (of nose) to nape (of the neck). You should ensure that the points, when shifted inwards with cfg.inwardshift (units are the same as your units of the volume an dgradiometer system, in case of CTF that is in cm), that they more or less ly in the gray matter, i.e. approx 0.5-1cm inward from the brain surafce. If your head surface includes ears and a nose, you will have weird effects. You could change teh plot3d option in such a way that the dipole grid positions are also plotted (you should plot the pos variable). > I get 644 dipoles from it 'prunedinv' subfunction gives me 'pruning > 49 out of 148 singular values' (so, we use 148 channels mashine). That seems a rather large reduction. The issue here is that you need 148 sources (i.e. a dipole onsists of an x, y and z source, and in case of a spherical headmodel the radial component will be zero) to be able to completely describe the data. But if there is noise (a small and spatially shart amplitude contribution), then that noise will also project to teh sourcespace. Hence, the noise will also project outward again to the new sensor array. By "pruning" the leadfield matrix, the N spatially strongest components are selected, where a component is then not a dipole any more, but a combination of dipoles. I.e. a SVD is done on the leadfield, and the smallest contributing components are removed. By default all source components smaller than 0.001 times the largest component will be removed (note that this is independent of data). In your case there are 49 of the 148 removed. You have 644 sources, each with 3 orientations -> those are compressed into 148-49=99 spatial topographies. > After calculation of realign matrix and applying it for 'realigning > trial' the residual variance (RV) which I get for one trial is > arround 30%. I have a feelling that it is rather to much, or might > be it's normal, becouse difference between sensors is rather big one. > Because in case 'mean distance towards template gradiometers' was > 6.48 mm - residual variances were arround 5-6%. > So, > distance RV > 6.48 mm 5-6% > 25.45 mm ~30%. > My question is - is such RV difference correspondent to the > difference distance I have and how many points should be like a > 'control value' for 'prunedinv' routine? The RV is not the incorrectness of the projection, but the difference between the original and realigned data (i.e. before and after). If it were zero, then realigning would not have an effect. So "RV" is not a good name, it is "before-after difference". A large helmet shift probably fits with a large before-after difference. Various differences can be shown, i.e. "original->brain->original" and "original->brain->template", and also "original->brain->template- >brain->original". I hope that these numbers are now more clear. I cannot tell you what a good value is for the cfg.pruneration option. You can set it between 0 (no pruning) and 1 (all except the largest component will be pruned/removed). Perhaps other people on the FT list can tell you about their experience with this setting. best regards, Robert From litvak at TX.TECHNION.AC.IL Wed Oct 4 15:15:41 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Wed, 4 Oct 2006 14:15:41 +0100 Subject: Signal2 format import In-Reply-To: <2093A833-C89D-4DB0-9D53-FB43A9DAF4A2@fcdonders.ru.nl> Message-ID: Hi Robert and everyone, I am starting a new project and I'd like to import to FT data in Signal (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab library that can read the files but I wonder whether anybody has implemented the conversion all the way to FT or at least close to it. Maybe Biosig can read it (I haven't tried yet)? Any thoughts would be appreciated. Thanks, Vladimir From litvak at TX.TECHNION.AC.IL Wed Oct 4 18:11:08 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Wed, 4 Oct 2006 17:11:08 +0100 Subject: Signal2 format import In-Reply-To: <001901c6e7b7$3125cc70$ec463ec1@sobell.ion.ucl.ac.uk> Message-ID: A correction to my previous post. The files come with extension *.SMR and not *.CED. Vladimir -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Vladimir Litvak Sent: Wednesday, October 04, 2006 2:16 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: [FIELDTRIP] Signal2 format import Hi Robert and everyone, I am starting a new project and I'd like to import to FT data in Signal (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab library that can read the files but I wonder whether anybody has implemented the conversion all the way to FT or at least close to it. Maybe Biosig can read it (I haven't tried yet)? Any thoughts would be appreciated. Thanks, Vladimir From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 18:19:38 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 18:19:38 +0200 Subject: Signal2 format import In-Reply-To: <001901c6e7b7$3125cc70$ec463ec1@sobell.ion.ucl.ac.uk> Message-ID: Hi Vladimir, On 4 Oct 2006, at 15:15, Vladimir Litvak wrote: > I am starting a new project and I'd like to import to FT data in > Signal > (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab > library that can read the files but I wonder whether anybody has > implemented > the conversion all the way to FT or at least close to it. Maybe > Biosig can > read it (I haven't tried yet)? Any thoughts would be appreciated. Gijs van Elswijk contributed code to FT for reading continuous channels (are required to all have the same sampling rate) from a system manufactured by "Cambridge Electronic Design" (CED), and the documentation that I got specifies that the files are from the 'Spike2 SON filing system'. In the FT private/filetype function, those are referred to as being type 'ced_son'. However, those files are assumed to have the extension *.smr. I am not sure whether those are the same files, but it sounds like it could be related. Gijs' code is basically the private/read_ced_son.m file, which uses the Neuroshare library (see http://neuroshare.sourceforge.net). There are matlab bindings to the Neuroshare library, i.e. system specific mex files that you have to add to your Matlab path. I hope this helps. If not, then I also know another library for reading SON2 files. But then, I am not yet sure whether that really corresponds to the dataformat that you now have. Robert From litvak at TX.TECHNION.AC.IL Wed Oct 4 20:21:39 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Wed, 4 Oct 2006 19:21:39 +0100 Subject: Signal2 format import In-Reply-To: <3202C65B-3F02-40BC-8403-A52F470BB6A8@fcdonders.ru.nl> Message-ID: Thanks a lot. It works perfectly (at least from the first glance). Best, Vladimir -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Robert Oostenveld Sent: Wednesday, October 04, 2006 5:20 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: Re: [FIELDTRIP] Signal2 format import Hi Vladimir, On 4 Oct 2006, at 15:15, Vladimir Litvak wrote: > I am starting a new project and I'd like to import to FT data in > Signal > (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab > library that can read the files but I wonder whether anybody has > implemented > the conversion all the way to FT or at least close to it. Maybe > Biosig can > read it (I haven't tried yet)? Any thoughts would be appreciated. Gijs van Elswijk contributed code to FT for reading continuous channels (are required to all have the same sampling rate) from a system manufactured by "Cambridge Electronic Design" (CED), and the documentation that I got specifies that the files are from the 'Spike2 SON filing system'. In the FT private/filetype function, those are referred to as being type 'ced_son'. However, those files are assumed to have the extension *.smr. I am not sure whether those are the same files, but it sounds like it could be related. Gijs' code is basically the private/read_ced_son.m file, which uses the Neuroshare library (see http://neuroshare.sourceforge.net). There are matlab bindings to the Neuroshare library, i.e. system specific mex files that you have to add to your Matlab path. I hope this helps. If not, then I also know another library for reading SON2 files. But then, I am not yet sure whether that really corresponds to the dataformat that you now have. Robert From G.vanElswijk at NEURO.UMCN.NL Wed Oct 4 20:38:24 2006 From: G.vanElswijk at NEURO.UMCN.NL (Gijs van Elswijk) Date: Wed, 4 Oct 2006 20:38:24 +0200 Subject: Signal2 format import Message-ID: Hi Vladimir and Robert, The "read_ced_son" code has not been tested with non-continuous Spike2 files. However, recently a colleague of mine has used the Fieldtrip routines to read his non-continuous Spike2 data. It seems to work fine. I have not tested any Signal data files (which are always non-continuous as far as I know). I believe Signal also uses the "CED SON filing system", which means that those files should be readable with the current FT routines. I was planning to add a few small updates to the current code at some point. If necessary, I could combine it with testing/implementing the support for non-continuous Signal/Spike data. Gijs -----Original Message----- From: FieldTrip discussion list on behalf of Vladimir Litvak Sent: Wed 10/4/2006 8:21 PM To: FIELDTRIP at NIC.SURFNET.NL Cc: Subject: Re: [FIELDTRIP] Signal2 format import Thanks a lot. It works perfectly (at least from the first glance). Best, Vladimir -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Robert Oostenveld Sent: Wednesday, October 04, 2006 5:20 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: Re: [FIELDTRIP] Signal2 format import Hi Vladimir, On 4 Oct 2006, at 15:15, Vladimir Litvak wrote: > I am starting a new project and I'd like to import to FT data in > Signal > (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab > library that can read the files but I wonder whether anybody has > implemented > the conversion all the way to FT or at least close to it. Maybe > Biosig can > read it (I haven't tried yet)? Any thoughts would be appreciated. Gijs van Elswijk contributed code to FT for reading continuous channels (are required to all have the same sampling rate) from a system manufactured by "Cambridge Electronic Design" (CED), and the documentation that I got specifies that the files are from the 'Spike2 SON filing system'. In the FT private/filetype function, those are referred to as being type 'ced_son'. However, those files are assumed to have the extension *.smr. I am not sure whether those are the same files, but it sounds like it could be related. Gijs' code is basically the private/read_ced_son.m file, which uses the Neuroshare library (see http://neuroshare.sourceforge.net). There are matlab bindings to the Neuroshare library, i.e. system specific mex files that you have to add to your Matlab path. I hope this helps. If not, then I also know another library for reading SON2 files. But then, I am not yet sure whether that really corresponds to the dataformat that you now have. Robert From r.oostenveld at FCDONDERS.RU.NL Thu Oct 5 11:05:42 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 5 Oct 2006 11:05:42 +0200 Subject: Signal2 format import In-Reply-To: <87F49DED9808BB438F539227CB809111179417@exchange_smtp.umcn.nl> Message-ID: Hi Gijs and Vladimir, On 4 Oct 2006, at 20:38, Gijs van Elswijk wrote: > The "read_ced_son" code has not been tested with non-continuous > Spike2 files. However, recently a colleague of mine has used the > Fieldtrip routines to read his non-continuous Spike2 data. It seems > to work fine. I have not tested any Signal data files (which are > always non-continuous as far as I know). The preprocessing function of Fieldtrip always assumes that data is continuous, i.e. all data samples are numbered as if they were continuous. The definetrial function has to take care of trial boundaries, and definetrial (or your own trialfun) should ensure that the datasegments of interest do not cross trial boundaries. However, if you use filter padding in preprocessing, then your segments of interest (i.e. the "trl" matrix from definetrial) are extended on both sides, and then it may happen that the padded segment extends over a trial boun. To catch those situations, the read_fcdc_data function will check whether the requested data extends over trial boundaries in a discontinuous file (and give an error if it does). So by default in the case of real non-continuous data, the read_fcdc_data function should catch situations where it tries to read data that crosses a trial boundary. However, that will only work if the header (obtained from read_fcdc_header) correctly specifies it that the data is trial based. You may want to check that in the read_ced_con importer. In some cases, trial-based data can also be interpreted as continuous, e.g. when you acquire CTF data in pseudo-continuous mode. The file then contains trials, but there are no holes between them. In that case, you should use cfg.datatype='continuous' in preprocessing (and in the artifact detection functions). That option tells the read_fcdc_data function that it should NOT do the trial boundary check. best Robert From roel.willems at FCDONDERS.RU.NL Fri Oct 6 11:03:50 2006 From: roel.willems at FCDONDERS.RU.NL (Roel Willems) Date: Fri, 6 Oct 2006 11:03:50 +0200 Subject: two way anova Message-ID: Dear all, I've got a quick and easy question: Is there a straightforward way of doing a 2 way anova (e.g. with factors regions of interest (grouped electrodes) and conditions) of freq data using the new statistics_stats function? All the best, Roel -- Roel Willems, PhD student Radboud University Nijmegen F.C. Donders Centre for Cognitive Neuroimaging Kapittelweg 29 6525 EK Nijmegen tel. +31243668065 www.fcdonders.ru.nl From r.oostenveld at FCDONDERS.RU.NL Fri Oct 6 15:53:53 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 6 Oct 2006 15:53:53 +0200 Subject: two way anova In-Reply-To: <45261BF6.2070002@fcdonders.ru.nl> Message-ID: Hi Roel, On 6 Oct 2006, at 11:03, Roel Willems wrote: > Is there a straightforward way of doing a 2 way anova (e.g. with > factors regions of interest (grouped electrodes) and conditions) of > freq data using the new statistics_stats function? No, the statistics_montecarlo, analytic annd stats function all implement a massive univariate statistic (with multiple comparison correction). So ROIs (channels) cannot be used as factor. You can use the matlab anova2 or anovaN function on the command line. However, you should be aware that power spectra do not always mix linearly, depending on what the underlying assumption is over the generators. Hence you cannot always test for interactions (main effects is not a problem). There are workarounds, we could discuss that next week. best Robert From Brian.Roach at YALE.EDU Sat Oct 7 00:04:01 2006 From: Brian.Roach at YALE.EDU (Brian Roach) Date: Fri, 6 Oct 2006 18:04:01 -0400 Subject: freqanalysis_wltconvol.m In-Reply-To: Message-ID: Markus, I appreciate this answer, but I would like to clarify some of your points to be sure I have completely absorbed them. Here is my example: 1000Hz sample rate for the acquired data 4000ms epochs centered on an event (-2000ms before the event to 1999 after the event) cfg = output: 'pow' method: 'wltconvol' foi: [1x60 double] width: 6 gwidth: 3 toi: [1x1000 double] where foi is 1 to 60Hz (in 1Hz steps), and toi is -.5s to .5s (in 1ms steps) I like that 1Hz is not plotted (NaN) values, since you cannot get 6 cycles of 1Hz data in my 4s epoch size. Having run this, I am still uncertain about how gwidth influences the data. Does a smaller gwidth just widen the bell curve of the gaussian envelope? Is there a trend, such as the higher the gwidth, the better the time resolution (because the wavelet has a sharper rise and fall time)? In my case, does sf = 2Hz/6Hz or 1/3Hz? I don't think I have these values right, and since they influence temporal domain and spectral bandwidth, it is important that I know what is right. It seems like if my interpretation of your e-mail is correct, then each frequency bin consists of that frequency +/-.167 or (1/6) Hz. In my example above, my 2Hz value would then consist of data from 1.8333 to 2.1667Hz. This would mean that there are gaps in the spectral data and a smaller number of cycles or smaller width would lead to larger bandwidth (i.e. decreasing frequency resolution). What do you think? Also, does fieldtrip have a function that gives "phase locking factor" or inter-trial coherence (ITC)? Thank you very much for your help. Brian At 03:59 AM 10/2/2006, Markus Siegel wrote: >Dear Brian, > >cfg.width determines in cycles the width of the Morlet-wavelet as the >standard deviation of the underlying gaussian (often termed "q"). One >can either use a fixed q for all frequencies by giving only one >number in cfg.width, or one can use a different q for each frequency >of interest with a vector in cfg.width of the same length as cfg.foi. >"help freqanalysis_wltconvol" gives you the relationship between >cfg.width (width) , the frequency of interest (f0) and the standard- >deviation (resolution) of the wavelet-transform in the temporal (st) >and spectral (sf) domain: > >The standard deviation in the frequency domain (sf) at frequency f0 is >defined as: sf = f0/width >The standard deviation in the temporal domain (st) at frequency f0 is >defined as: st = width/f0 = 1/sf > >The spectral bandwidth (in standard deviations, Hz) of the time- frequency >transform can thus be computed as: >bw = cfg.foi ./ cfg.width; > >The parameter cfg.gwidth determines the length of the wavelet-kernel >used in standard deviations of the underlying gaussian. In other >words, it specifies over how many standard deviations the gaussian is >estimated for the morlet-wavelet in both directions. This does in >principle not influence the spectro-temporal resolution of the >transform, but determines its precision because the gaussian is non- zero >at the edges. Therefore, small values (e.g. <2) lead to edge >effects in the transform. The full length of the 'longest' wavelet at >the lowest frequency cfg.foi(1) is thus computed as: > >2 * cfg.gwidth (cfg.width(1) ./ cfg.foi(1)) > >In freqanalysis_wltconvol, the wavelet transform is implemented by >multiplication in the frequency domain which is computationally more >efficient than convolution in the temporal domain. However, >technically the transform is well described as a convolution of the >time-series with a complex Morlet-wavelet (complex sinusoid with a >gaussian envelope) as e.g. provided in Tallon-Baudry et al., J >Neurosci 1997. > >Best, >Markus > >Am 29.09.2006 um 18:52 schrieb Brian Roach: > > >>Dear FieldTrip users, >> >>I have been playing with the freqanalysis_wltconvol function in >>hopes of using the morlet wavelet time frequency analysis on some >>eeg data. I have been able to get it running, and I find that it >>works very quickly, which is great. However, I am hoping some >>users or F.T. programmers can explain some of the function inputs >>and processing. The cfg example is as follows: >> >>% cfg.method = 'wltconvol'; >>% cfg.foi = 1:1:100; >>% cfg.width = 7; >>% or >>% cfg.width = linspace(5,10,length(cfg.foi)); >>% cfg.toi = 0:0.1:2; >>% cfg.gwidth = 3; >> >>I believe that the cfg.width specifies the number of wave cycles >>used in each frequency's wavelet analysis (so at 2Hz, 7 cycles >>spans 3500ms of data, right?). Maybe this is not correct, because >>I do not seem to get the frequencies as low as I would expect given >>my data epoch length. Perhaps this has to do with the cfg.gwidth >>parameter, which I do not think I completely understand - what is it? >> >>Also, we do not have the matlab wavelet toolbox, and it appears >>that it is not required, but how is the morlet wavelet >>implemented? As I look through the code I see calls to fft, ifft, >>and fftshift, but I wonder how I can give a good technical >>description of this process if I find results in a larger data set. >> >>Finally, is there a function or a way to compute the frequency >>bandwidth based on the cfg inputs, or is there a fix frequency >>bandwith for each foi here? I am sure I am confusing a number of >>things here, so no response is too simple. >> >>Thanks for any advice, please let me know if there is more >>information I can give or if I can clarify my questions. >> >>Brian > From Jan.Schoffelen at FCDONDERS.RU.NL Mon Oct 9 08:31:58 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Mon, 9 Oct 2006 08:31:58 +0200 Subject: Fieldtrip question from Piers C In-Reply-To: <4523.144.32.162.118.1160130197.squirrel@psycix.york.ac.uk> Message-ID: Dear Piers, Since I am not a big wavelet-analysis expert, I forward this reply to the fieldtrip-mailinglist. Recently there has been a thread concerning this type of analysis. (To subscribe, please have a look at: http://www.ru.nl/fcdonders/fieldtrip/, and follow the links to the discussion list; there's a thread on freqanalysis_wltconvol) I'd like to give you a global idea of what's going on with your analysis, for the details I'd like to refer to Markus' and Brian's discussion. The NaNs in your spectrogram are the consequence of your configuration-settings, and your data length. Only at frequencies and time-points where the wavelet-kernel completely covers your data, an estimate is returned. You could play around a bit with your cfg.width, and cfg.gwidth parameters to change this. Yours, Jan-Mathijs -----Original Message----- From: p.cornelissen at psych.york.ac.uk [mailto:p.cornelissen at psych.york.ac.uk] Sent: Friday, October 06, 2006 12:23 PM To: Jan Mathijs Schoffelen Subject: RE: Fieldtrip question from Piers C Dear Jan-Mathijs Thanks for this advice. It turns out that there is an easy solution in the form of a commandline programme called newDS (this is either a CTF thing, or something written by the team at Aston) which allows one to incorporate a virtual electrode dataset (defined by a SAM weights file) into a DS file. Then, when reading into Fieldtrip, you have to include the 'V0' in the line: cfg.channel = {'MEG' 'STIM' 'V0'}; However, I have a new question. I ran the following wavelet analysis on a virtual electrode channel dataset: cfg1 = []; cfg1.output = 'pow'; cfg1.sgn = 'MEG'; cfg1.method = 'wltconvol'; cfg1.channel = 'V0'; cfg1.width = 5; % Width of wavelet cfg1.gwidth = 5; cfg1.foi = 1:1:50; cfg1.toi = -0.2:0.01:0.7; WVLT = freqanalysis(cfg1, raw); Created a suingle plot as follows. cfg2 = []; cfg2.baseline = [-0.2 0.0]; cfg2.baselinetype = 'relative'; %cfg2.baseline = 'no'; %cfg2.baselinetype = 'absolute'; cfg2.zlim = 'maxmin'; cfg2.xlim = [-0.2 0.7]; cfg2.ylim = [1 35]; cfg2.channel = 'V0'; singleplotTFR(cfg2, WVLT); ... and obtained the result that is attached as a PNG file to this email. It seems as if the plot has been thresholded/masked in a way to exclude values that are (probably) poorly estimated - or something like that. So, please can you advise what rules govern this exclusion/masking, and how they can either be switched off, or the analysis/data collection carried out in such a way that they are not invoked. Thanks very much again Piers > Dear Piers, > > First of all, I took the liberty to include as a CC to this mail the > FieldTrip discussion list. It might be that some of its members could > positively contribute to answering your questions. You can subscribe to > this > list on the fieldtrip-website. > > Anyway, currently there is no support for reading in SAM weights files > into > fieldtrip. The most important reason for us not having implemented it, is > that we do our source estimation in fieldtrip directly. Perhaps anyone > already has an implementation to directly read in your SAM weights into > matlab (hence the cc to the discussion list). As soon as those weights are > available, it is pretty straightforward to create virtual channel data and > do the subsequent analysis within fieldtrip. > Otherwise a reading routine for SAM weights would be a valuable > contribution > to the code. > > Another approach would be to use fieldtrip's beamforming algorithm to > create > your virtual channels. The 'lcmv'-algorithm is not all too different from > SAM, so you could try this on your specified voxels of interest. > > There is a tutorial on the frequency-domain beamformer on the web-site. > The > time-domain beamformer needs a slightly different configuration and > input-data. > > 1 you should use timelockanalysis to compute the covariance of your > bandpass-filtered data. > 2 then you can call sourceanalysis, with the output of timelockanalysis as > an input, in combination with a configuration-structure. > > Key-elements of this configuration would be: > cfg.method = 'lcmv'; > cfg.pos = Nx3 matrix with x,y,z coordinates of your virtual channels > cfg.reducerank = 2; (necessary for comparability with SAM, and also to > give > reasonable results in the first place) > cfg.hdmfile = .hdm file specifying the forward model used > > ...and I guess some other stuff as well. > > Yours, > > Jan-Mathijs > > > > -----Original Message----- > From: p.cornelissen at psych.york.ac.uk > [mailto:p.cornelissen at psych.york.ac.uk] > > Sent: Friday, September 15, 2006 2:54 PM > To: Jan.Schoffelen at fcdonders.ru.nl > Subject: Fieldtrip ? from Piers C > > > Dear Fieldtrip team, > > First - thanks for your excellent software! > > I hope its OK for me to ask you a Fieldtrip question. > > We have data from an experiment using Aston (UK) universitie's old 151 > channel CTF system, and we have used the CTF tools to extract a set of > virtual electrodes, selected on the basis of a robust group SAM analysis. > What we would really like to do is to use our SAM weights files for these > virtual electrodes, to define specific channels in Fieldtrip so that we > can create and compare time*frequency plots from the virtual electrodes in > Fieldtrip. > > Any advice on how to do this (preferably by way of example code)would be > deeply appreciated > > Regards > > Piers Cornelissen > > > > > > > > > > > > > > From m.siegel at UKE.UNI-HAMBURG.DE Mon Oct 9 11:05:27 2006 From: m.siegel at UKE.UNI-HAMBURG.DE (Markus Siegel) Date: Mon, 9 Oct 2006 11:05:27 +0200 Subject: freqanalysis_wltconvol.m In-Reply-To: <6.1.2.0.2.20061006142513.01c9ecf0@email.med.yale.edu> Message-ID: Hi Brian, On Oct 7, 2006, at 12:04 AM, Brian Roach wrote: > Here is my example: > 1000Hz sample rate for the acquired data > 4000ms epochs centered on an event (-2000ms before the event to > 1999 after the event) > > cfg = > > output: 'pow' > method: 'wltconvol' > foi: [1x60 double] > width: 6 > gwidth: 3 > toi: [1x1000 double] > > where foi is 1 to 60Hz (in 1Hz steps), and toi is -.5s to .5s (in > 1ms steps) > > I like that 1Hz is not plotted (NaN) values, since you cannot get 6 > cycles of 1Hz data in my 4s epoch size. Having run this, I am > still uncertain about how gwidth influences the data. Does a > smaller gwidth just widen the bell curve of the gaussian envelope? > Is there a trend, such as the higher the gwidth, the better the > time resolution (because the wavelet has a sharper rise and fall > time)? cfg.gwidth does not influence the width of the gaussian envelope and thus does not have an effect on the temporal or spectral resolution. The cfg.gwidth parameter determines the length of the morlet-wavelet but not its shape. The gaussian envelope implies that the wavelet tails converge towards zero but are not really zero at the edges. Thus one has to decide where to crop the wavelet-kernel. The gwidth parameter determines the cropped length in standard deviations of the gaussian envelope. For cfg.gwidth = 3 the morlet-wavelet is thus estimated for the central +/- 3 standard deviations of the gaussian envelope. Hence, smaller gwidth parameter lead to edges of the wavelets that become more "non-zero" which lead to stronger edge effects and more noisy picture of your time-frequency transform. Run your analysis with the above parameters but cfg.gwidth = 1. If you compare the output to that of cfg.gwidth = 3 this effect should become clear. > In my case, does sf = 2Hz/6Hz or 1/3Hz? I don't think I have these > values right, and since they influence temporal domain and spectral > bandwidth, it is important that I know what is right. It seems > like if my interpretation of your e-mail is correct, then each > frequency bin consists of that frequency +/-.167 or (1/6) Hz. In > my example above, my 2Hz value would then consist of data from > 1.8333 to 2.1667Hz. This would mean that there are gaps in the > spectral data and a smaller number of cycles or smaller width would > lead to larger bandwidth (i.e. decreasing frequency resolution). > What do you think? The spectral bandwidth of your time-frequency tranform is not constant but a function of frequency. For your example, the spectral bandwidth (in standard deviations, Hz) is computed as: bandwidth = cfg.foi ./ cfg.width; For a constant cfg.width, the spectral bandwidth increases linearly with the frequency of interest. While at 18 Hz you have a spectral bandwidth of 3 Hz, the bandwidth at 60 Hz is 10 Hz. > Also, does fieldtrip have a function that gives "phase locking > factor" or inter-trial coherence (ITC)? Not that I know. However, you could compute ITC yourself based on the complex output from freqanalysis_mtmconvol run with cfg.output = 'fourier'. Best, Markus From jaredvs at GMAIL.COM Tue Oct 10 22:38:53 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Tue, 10 Oct 2006 22:38:53 +0200 Subject: Incorrect coordinates? Message-ID: Hi there, I've been analyzing the output of BESA's multiple source beamformer (MEG data) using Fieldtrip, and it appears that there is a problem with the coordinate system. The results of volumewrite, when overlayed with the spm T1.img, appear to be substantially outside of the brain, and in oddly shaped patterns that suggest an error in assigning statical values to the correct coordinates. The analysis protocol used was as follows (we only had MRI's for 2 subjects, one of these was used for all subject who did not have MRI's--for convenience I simply use one mri for all subjects in the example below): mri=read_fcdc_mri('mri.img'); fdir=pwd; files=dir([fdir filesep '*.dat']); %these are the BESA .dat files sinterp_cfg.interpmethod='cubic'; sinterp_cfg.sourceunits='mm'; norm_cfg.template=which('T1.mnc'); norm_cfg.parameter='all'; norm_cfg.coordinates='spm'; norm_cfg.name='high_alpha_beamformer_normed'; for k=1:length(files) src(k)=besa2fieldtrip([fdir filesep files(k).name]); interp(k)=sourceinterpolate(sinterp_cfg,src(k),mri); volume(k)=volumenormalise(norm_cfg,interp(k)); end grav_cfg.parameter='pow'; grav_cfg.keepindividual='yes'; grandavg=sourcegrandaverage(grav_cfg,volume(1),volume(2),volume(3),volume (4),volume(5),volume(6),volume(7),volume(8),volume(9),volume(10),volume (11),volume(12)); stat_cfg.parameter='pow'; stat_cfg.method='parametric'; stat_cfg.statistic = 'zero-baseline'; stat_cfg.bonferoni = 'no'; stat_cfg.threshold=0.01; stat=sourcestatistics_parametric(stat_cfg,grandavg); write_cfg.parameter='tscore'; write_cfg.filename='alpha'; write_cfg.filetype='spm'; write_cfg.coordinates='spm'; write_cfg.scaling='no'; volumewrite(write_cfg,stat) When I overlay the .img on the MNI T1.img using MRICro, there's a lot of data outside of the brain. Any suggestions as to where something may have gone wrong would be greatly appreciated. I would happily provide the resulting alpha.img and alpha.hdr, though as the .img is 55MB I won't attach it to this message. Thanks very much, Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 From r.oostenveld at FCDONDERS.RU.NL Wed Oct 11 09:36:07 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 11 Oct 2006 09:36:07 +0200 Subject: Incorrect coordinates? In-Reply-To: Message-ID: Hi Jared, On 10 Oct 2006, at 22:38, Jared Van Snellenberg wrote: > I've been analyzing the output of BESA's multiple source beamformer > (MEG > data) using Fieldtrip, and it appears that there is a problem with the > coordinate system. The results of volumewrite, when overlayed with > the spm > T1.img, appear to be substantially outside of the brain, and in oddly > shaped patterns that suggest an error in assigning statical values > to the > correct coordinates. I suspect a misalignment between your functional and anatomical data. > mri=read_fcdc_mri('mri.img'); read_fcdc_mri does not do automatic alignment, but just returns the data with the coordinate system as defined in the mri file. Do you know what the coordinate system is to which the anatomical MRI is aligned? I.e. where is the origin [0,0,0] in anatomical terms? > for k=1:length(files) > src(k)=besa2fieldtrip([fdir filesep files(k).name]); > interp(k)=sourceinterpolate(sinterp_cfg,src(k),mri); > volume(k)=volumenormalise(norm_cfg,interp(k)); > end And what is the coorrdinate system in which the functional source data is described? I.e. at which location in the head would a dipole at the coordinate [0 0 0] be? For sourceinterpolate the two input arguments (functional + anatomical data) should be defined w.r.t. the same coordinate system. I suggest that you use sourceplot for debugging, e.g. something like cfg =[] cfg.funparameyter = 'pow' % don't know how the functional data in src is called, probably 'pow' cfg.location = 'interactive' % or try [0 0 0] sourceplot(cfg, src(1)); % there is no anatomy, only functional data and cfg =[] cfg.funparameyter = [] % no functional data, only anatomy cfg.location = 'interactive' % or try [0 0 0] sourceplot(cfg, mri); that should give you both volumes (in seperate windows) and you can compare whether they seem to be aligned. You could use the volumerealign(*) function for manual realignment of the anatomical MRI. Or you can use MRIcro. Also have a look at http://www2.ru.nl/fcdonders/fieldtrip/doku.php? id=fieldtrip:documentation:frequently_asked_questions#how_are_the_differ ent_head_and_mri_coordinate_systems_defined I hope this helps. Robert *) that is a completely new function that was added yesterdays to fieldtrip, hence you should fetch the latest version from ftp From jaredvs at GMAIL.COM Wed Oct 11 19:16:47 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Wed, 11 Oct 2006 13:16:47 -0400 Subject: Incorrect coordinates? In-Reply-To: <901A6BEF-A31F-41ED-8311-BA17061BED47@fcdonders.ru.nl> Message-ID: Hi Robert, Thanks very much, it looks like you're right. While plotting the src data just came up with an empty image, BESA is supposed to output coordinates according to the Talairach atlas, so [0 0 0] should be on the anterior commisure. Plotting the structural MRI shows that [0 0 0] is clearly *not*on the AC, so it needs to be realigned. I'll try volumerealign now. -Jared On 10/11/06, Robert Oostenveld wrote: > > Hi Jared, > > On 10 Oct 2006, at 22:38, Jared Van Snellenberg wrote: > > I've been analyzing the output of BESA's multiple source beamformer > > (MEG > > data) using Fieldtrip, and it appears that there is a problem with the > > coordinate system. The results of volumewrite, when overlayed with > > the spm > > T1.img, appear to be substantially outside of the brain, and in oddly > > shaped patterns that suggest an error in assigning statical values > > to the > > correct coordinates. > > I suspect a misalignment between your functional and anatomical data. > > > mri=read_fcdc_mri('mri.img'); > > read_fcdc_mri does not do automatic alignment, but just returns the > data with the coordinate system as defined in the mri file. > > Do you know what the coordinate system is to which the anatomical MRI > is aligned? I.e. where is the origin [0,0,0] in anatomical terms? > > > for k=1:length(files) > > src(k)=besa2fieldtrip([fdir filesep files(k).name]); > > interp(k)=sourceinterpolate(sinterp_cfg,src(k),mri); > > volume(k)=volumenormalise(norm_cfg,interp(k)); > > end > > And what is the coorrdinate system in which the functional source > data is described? I.e. at which location in the head would a dipole > at the coordinate [0 0 0] be? > > For sourceinterpolate the two input arguments (functional + > anatomical data) should be defined w.r.t. the same coordinate system. > > I suggest that you use sourceplot for debugging, e.g. something like > > cfg =[] > cfg.funparameyter = 'pow' % don't know how the functional > data in src is called, probably 'pow' > cfg.location = 'interactive' % or try [0 0 0] > sourceplot(cfg, src(1)); % there is no anatomy, only > functional data > > and > > cfg =[] > cfg.funparameyter = [] % no functional data, only anatomy > cfg.location = 'interactive' % or try [0 0 0] > sourceplot(cfg, mri); > > that should give you both volumes (in seperate windows) and you can > compare whether they seem to be aligned. You could use the > volumerealign(*) function for manual realignment of the anatomical > MRI. Or you can use MRIcro. Also have a look at > http://www2.ru.nl/fcdonders/fieldtrip/doku.php? > id=fieldtrip:documentation:frequently_asked_questions#how_are_the_differ > ent_head_and_mri_coordinate_systems_defined > > I hope this helps. > Robert > > *) that is a completely new function that was added yesterdays to > fieldtrip, hence you should fetch the latest version from ftp > -- Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.oostenveld at FCDONDERS.RU.NL Thu Oct 12 09:21:08 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 12 Oct 2006 09:21:08 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610111016y5bae7549o382682194f7e034b@mail.gmail.com> Message-ID: On 11 Oct 2006, at 19:16, Jared Van Snellenberg wrote: > Thanks very much, it looks like you're right. good. > While plotting the src data just came up with an empty image In sourceplot cfg.funparameter should specify the parameter that should be plotted, and that should work without anatomy as well. Looking back at your own cfg in the previous mail, I do think that it should be 'pow'. However, I made a typo in my previous reply (cfg.funparameyter). Robert From marco.buiatti at GMAIL.COM Fri Oct 13 19:03:36 2006 From: marco.buiatti at GMAIL.COM (Marco Buiatti) Date: Fri, 13 Oct 2006 19:03:36 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: <82A11B61-8049-432A-B1CF-43764D723ED3@fcdonders.ru.nl> Message-ID: Dear Robert and Eric (and dear FieldTrippers), thank you for your efficient response on my summer question. I followed your advices and tried to use the function timelockstatistics starting from the canonical comparison of ERPs within subjects but I had some problems. Here I report my attempt to perform cluster randomization analysis on ERPs relative to two conditions (W and PW). For simplicity I took just 2 subjects. I report here all the steps from loading eeglab datasets to computing cluster randomization analysis to be sure that I am following the correct procedure. The problem is ??? Undefined variable "data" or class "data.biol". I used yesterday's FieldTrip version 20061012. Can you help me with this? Thank you in advance, Marco % Loading eeglab datasets EEG50PW_s2 = pop_loadset( '02_ev_hpf0.2_lpf35_ep_soa50PW.set', '/home/Pinserm/people/joachim/analysis/02/'); EEG50W_s2 = pop_loadset( '02_ev_hpf0.2_lpf35_ep_soa50W.set', '/home/Pinserm/people/joachim/analysis/02/'); EEG50PW_s4 = pop_loadset( '04_ev_hpf0.2_lpf35_ep_soa50PW.set', '/home/Pinserm/people/joachim/analysis/04/'); EEG50W_s4 = pop_loadset( '04_ev_hpf0.2_lpf35_ep_soa50W.set', '/home/Pinserm/people/joachim/analysis/04/'); % Transform to FieldTrip format data50PW_s2 = eeglab2fieldtrip( EEG50PW_s2, 'timelockanalysis' ); >> data50PW_s2 data50PW_s2 = label: {129x1 cell} fsample: 250 elec: [1x1 struct] avg: [129x523 single] var: [129x523 single] time: [1x523 double] dimord: 'chan_time' cfg: [1x1 struct] data50W_s2 = eeglab2fieldtrip( EEG50W_s2, 'timelockanalysis' ); data50W_s4 = eeglab2fieldtrip( EEG50W_s4, 'timelockanalysis' ); data50PW_s4 = eeglab2fieldtrip( EEG50PW_s4, 'timelockanalysis' ); % Computing grandaverage for each condition cfg =[]; cfg.keepindividual = 'yes'; GA_50PW = timelockgrandaverage(cfg,data50PW_s2,data50PW_s4); GA_50W = timelockgrandaverage(cfg,data50W_s2,data50W_s4) GA_50W = label: {129x1 cell} fsample: 250 avg: [129x523 double] var: [129x523 double] time: [1x523 double] individual: [2x129x523 double] dimord: 'subj_chan_time' cfg: [1x1 struct] % Loading channel names and positions data = eeglab2fieldtrip(EEG50PW_s2,'chanloc'); GA_50W.elec=data.elec; GA_50PW.elec=data.elec; % Setting cfg for timelockstatistics cfg=[]; cfg.statistic='depsamplesT'; cfg.numrandomization = 500; cfg.alpha=0.05; cfg.clusterstatistics='maxsum'; cfg.clusterthreshold = 'parametric'; cfg.clusteralpha = 0.05; cfg.neighbourdist=4; cfg.neighbours = neighbourselection(cfg,GA_50PW); cfg.latency=[0 0.5]; cfg.method = 'montecarlo'; stat = timelockstatistics(cfg,GA_50W,GA_50PW); Using the electrode configuration from the dataset. there are on average 128.0 neighbours per channel selected 129 channels selected 126 time bins selected 1 frequency bins ??? Undefined variable "data" or class "data.biol". Error in ==> fieldtrip-20061012/private/prepare_design at 92 nrepl=size(data.biol,1); Error in ==> fieldtrip-20061012/private/statistics_wrapper at 212 [cfg] = prepare_design(cfg); Error in ==> timelockstatistics at 50 [stat] = statistics_wrapper(cfg, varargin{:}); On 8/29/06, Robert Oostenveld wrote: > Dear Marco > > On 23 Aug 2006, at 14:53, Eric Maris wrote: > >> 2) Is there a way to compute the null distribution by considering > >> all possible reassignments of the conditions instead of the Monte > >> Carlo approximation - in this case it would be feasible because > >> all possible reassignments should be 2^9, right? > > This is not possible with clusterrandanalysis. However, this is > > possible with one of the new statistics functions in Fieldtrip that > > will replace both clusterrandanalysis and sourcestatistics. The > > function of interest for you is timelockstatistics, and you should > > have a look at the help information for the lower-level function > > statistics_montecarlo (which is called by timelockstatistics). > > However, provided that you use more than 500 draws from the > > permutation distribution, don't expect major changes in the output. > We have an in-house version of fieldtrip, and an external FTP > version. The in-house version is always slightly more advanced than > the external version. Even though the timelockstatistics function was > already included in recent external fieldtrip versions (the daily zip > files) on the Donders FTP server, I just noticed that the underlying > statistics_montecarlo function that Eric is referring to was still > missing from the zip file. I have now also tagged that function (and > some further subfunctions on which it depends) to be released in the > external fieldtrip release. You should be able to use the > timelockstatistics function with both the montecarlo and the complete > permutation (cfg.numrandomization='all') based estimaes for the > cluster statistics. > > I hope it works with the new function, if not then don't hesitate to > contact us. > > Robert > > > > -- Marco Buiatti - Post Doc ************************************************************** Cognitive Neuroimaging Unit - INSERM U562 Service Hospitalier Frederic Joliot, CEA/DRM/DSV 4 Place du general Leclerc, 91401 Orsay cedex, France Telephone: +33 1 69 86 77 65 Fax: +33 1 69 86 78 16 E-mail: marco.buiatti at gmail.com Web: www.unicog.org *************************************************************** From jaredvs at GMAIL.COM Sun Oct 15 00:12:48 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Sat, 14 Oct 2006 18:12:48 -0400 Subject: Incorrect coordinates? In-Reply-To: <8528858E-5C8B-46FA-B12B-461539BA59C3@fcdonders.ru.nl> Message-ID: Hi Robert, I've rerun the analysis with mri's that were reoriented to MNI, and the same problem has emerged. The typo you noted in your last email was indeed the reason for the empty src plot. Plotting src, interp, volume, and grandavg, everything looks ok. The 'pow' parameter values all appear within the brain. The tscore and p values in stat, however, are all messed up. I've attached .bmp's from using sourceplot on grandavg and stat to this email. The quality is poor (matlab's figure window doesn't ever save bmp's very well), but it should demonstrate the problem clearly. Note all the large values outside of the brain. Any comments you have would be greatly appreciated. I've considered just masking out everything that's not in the brain, but I'm not confident that the within-brain values are accurate. Thanks, -Jared On 10/12/06, Robert Oostenveld wrote: > > On 11 Oct 2006, at 19:16, Jared Van Snellenberg wrote: > > Thanks very much, it looks like you're right. > good. > > > While plotting the src data just came up with an empty image > > In sourceplot cfg.funparameter should specify the parameter that > should be plotted, and that should work without anatomy as well. > Looking back at your own cfg in the previous mail, I do think that it > should be 'pow'. However, I made a typo in my previous reply > (cfg.funparameyter). > > Robert > -- Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: grandavg.bmp Type: image/bmp Size: 236278 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: stat.bmp Type: image/bmp Size: 236278 bytes Desc: not available URL: From r.oostenveld at FCDONDERS.RU.NL Mon Oct 16 20:16:37 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 16 Oct 2006 20:16:37 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610141512j638067d0g70039058904b6e6@mail.gmail.com> Message-ID: Hi Jared, On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > I've rerun the analysis with mri's that were reoriented to MNI, and > the same problem has emerged. I would guess that the anatomical MRIs themselves do not influence the coordinate system of the source reconstruction. That would influence the interpolation though. If you do source = besa2fieldtrip(filename1) and mri = read_fcdc_mri(filename) then the source structure is defined using the source.pos field that describes the position of each source. SInce in this case the positions are on a regular 3D grid, there is additional structure in the arrangement of source.pos, which is described using source.xgrid, source.ygrid, source.zgrid. If you do tmp = reshape(source.avg.pow, source.dim) you will get a 3D array with along the first dimension the voxels along the x-axis, etc. The 1..Nth voxels along the xasix have the X coordinates source.xgrid(1)..source.xgrid(N). Similar for the Y and Z coordinates. That allows you to determine the coordinate of each voxel. Since the anatomical MRI is typically of much higher resolution, you can use sourceinterpolate which interpolates the source (or stat) volumes onto the voxel locations that are in the anatomical MRI. I.e. sourceinterpolate upsamples the functional data to the anatomical MRI. Normally you would do sourceinterpolate AFTER calling sourcestatistics, since the source positions in all subjects are all based on the same standard realistic head moidel in BESA and hence the source positions in all subjects are the same (please check whether positions are all the same over subjects/conditions). If you work with MEG or with EEG individual headmodels, the source positions in all subjects are all different, which requires sourceanalysis->sourceinterpolate->volumenormalize as shown in the schema for http://www2.ru.nl/fcdonders/fieldtrip/doku.php? id=fieldtrip:documentation:analysis_protocols#source_reconstruction_for_ multiple_subjects > The typo you noted in your last email was indeed the reason for the > empty src plot. Plotting src, interp, volume, and grandavg, > everything looks ok. The 'pow' parameter values all appear within > the brain. The tscore and p values in stat, however, are all messed > up. I've attached .bmp's from using sourceplot on grandavg and stat > to this email. The quality is poor (matlab's figure window doesn't > ever save bmp's very well), but it should demonstrate the problem > clearly. Note all the large values outside of the brain. In your case you should be able to do besa2fieldtrip -> sourcestatistics, and then the source positions with the statistical data on them should stll be the same as the positions with the original functional data on them. After doing the statistics (or after doing sourcegrandaverage), you can interpolate the functional/ statistical data onto the MRI. But since the statistical data and the functional (beamed power) data are on the same coordinates, there should not be a difference between them. > Any comments you have would be greatly appreciated. I've considered > just masking out everything that's not in the brain, but I'm not > confident that the within-brain values are accurate. Looking at the bitmaps, I cannot see teh anatomy, but I do see a brain-shaped outline with some blobs in them. I cannot recognise the problem from these figures, to me they seem ok. The only problem that I can see is the one that you also mention, and that is for the masking. In the original source data (i.e. output from besa2fieldtrip) there is an source.inside and source.outside field. Those should contain the indices of the voxels (linear indices, so voxel [1 1 1] has index 1 and voxel [2 1 1] has index 2...) of the sources that are inside the brain and outside the brain. Only the inside voxels are considered for sourcestatistics and for sourceinterpolation. However, the problem with BESA data is that it does not describe the inside/outside voxels and therefoer by default all voxels are marked as inside. Perhaps you can determine the inside/ outside voxels manually, e.g. source.inside = find(source.avg.pow(:)>eps); source.outside = find(source.avg.pow(:) Message-ID: Hi Marco Your script looks ok. On 13 Oct 2006, at 19:03, Marco Buiatti wrote: > ??? Undefined variable "data" or class "data.biol". > > Error in ==> fieldtrip-20061012/private/prepare_design at 92 > nrepl=size(data.biol,1); > > Error in ==> fieldtrip-20061012/private/statistics_wrapper at 212 > [cfg] = prepare_design(cfg); > > Error in ==> timelockstatistics at 50 > [stat] = statistics_wrapper(cfg, varargin{:}); Yep, that is a known problem (sorry about that). The function prepare_design is not working properly. I suggest to make a design matrix in cfg.design by hand (similar to, but not completely the same as in SPM). It is not difficult, and it will also make you more clear how it works. Please have a look at https://listserv.surfnet.nl/scripts/wa.exe? A2=ind0607&L=FIELDTRIP&P=R3192&I=-3&X=77C04E25A87526C2B4 or if that URL does not work, then search the fieldtrip discussion list archive for the string "cfg.design". best regards, Robert PS note that you can also use timelockstatistics on the 'componentanalysis' part of the EEGLAB data, in that case you cannot use channel clustering, but you still can use timepoint clustering (so cfg.neighbours should be []). You shoudl only do that if the ICA components in the different EEG datasets are spatially the same (or sufficiently similar, e.g. after clustering over subjects in the new EEGLAB). From r.oostenveld at FCDONDERS.RU.NL Mon Oct 16 20:31:15 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 16 Oct 2006 20:31:15 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610141512j638067d0g70039058904b6e6@mail.gmail.com> Message-ID: On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > The quality is poor (matlab's figure window doesn't ever save bmp's > very well), Just a suggestion: instead of exporting to a BMP bitmap (large files with poor quality) or a JPG (lossy, not suited for line drawings), you can export to a PNG bitmap, which is high quality (lossless+full color) and also compressed (small). Try print -dpng filename.png see "help print" for details Robert From Brian.Roach at YALE.EDU Tue Oct 17 23:44:29 2006 From: Brian.Roach at YALE.EDU (Brian Roach) Date: Tue, 17 Oct 2006 17:44:29 -0400 Subject: freqanalysis_wltconvol.m In-Reply-To: <1A240DDA-7643-4C16-820B-B6C0A69BB5DF@uke.uni-hamburg.de> Message-ID: Markus, Thanks for your reply. I believe I am getting a better handle on this function. Regarding phase-locking factor/ITC, couldn't I try to use the complex data within the freqanalysis_wltconvol to calculate these data in a similar method to that in the Tallon-Baudry et. al. '97 gamma paper? The wltconvol function is so similar to that paper's analysis already, it seems like I would only need to divide the complex data by its absolute value. The paper refers to taking the "modulus of this complex value," where the complex value is: Pi(f,f0) = w(t,f0) X si(t,f0)/ | w(t,f0) X si(t,f0) I read this as the dividing the imaginary, sine wave, portion of the wavelet (representing phase angle) at any given time and frequency by its absolute value. Does modulus have the same functionality/meaning as the C++ mod or matlab rem function? Is there interest in phase-locking values in the FieldTrip user community? I am interested in trying to implement what is described above, but it would be nice to have others see the code and test it to be sure I have calculated phase-locking values correctly. Anyone have any thoughts/feelings about this? Thanks, Brian At 05:05 AM 10/9/2006, you wrote: >Hi Brian, > >On Oct 7, 2006, at 12:04 AM, Brian Roach wrote: > >>Here is my example: >>1000Hz sample rate for the acquired data >>4000ms epochs centered on an event (-2000ms before the event to >>1999 after the event) >> >>cfg = >> >> output: 'pow' >> method: 'wltconvol' >> foi: [1x60 double] >> width: 6 >> gwidth: 3 >> toi: [1x1000 double] >> >>where foi is 1 to 60Hz (in 1Hz steps), and toi is -.5s to .5s (in >>1ms steps) >> >>I like that 1Hz is not plotted (NaN) values, since you cannot get 6 >>cycles of 1Hz data in my 4s epoch size. Having run this, I am >>still uncertain about how gwidth influences the data. Does a >>smaller gwidth just widen the bell curve of the gaussian envelope? >>Is there a trend, such as the higher the gwidth, the better the >>time resolution (because the wavelet has a sharper rise and fall >>time)? > >cfg.gwidth does not influence the width of the gaussian envelope and >thus does not have an effect on the temporal or spectral resolution. >The cfg.gwidth parameter determines the length of the morlet-wavelet >but not its shape. The gaussian envelope implies that the wavelet >tails converge towards zero but are not really zero at the edges. >Thus one has to decide where to crop the wavelet-kernel. The gwidth >parameter determines the cropped length in standard deviations of the >gaussian envelope. For cfg.gwidth = 3 the morlet-wavelet is thus >estimated for the central +/- 3 standard deviations of the gaussian >envelope. Hence, smaller gwidth parameter lead to edges of the >wavelets that become more "non-zero" which lead to stronger edge >effects and more noisy picture of your time-frequency transform. Run >your analysis with the above parameters but cfg.gwidth = 1. If you >compare the output to that of cfg.gwidth = 3 this effect should >become clear. > >>In my case, does sf = 2Hz/6Hz or 1/3Hz? I don't think I have these >>values right, and since they influence temporal domain and spectral >>bandwidth, it is important that I know what is right. It seems >>like if my interpretation of your e-mail is correct, then each >>frequency bin consists of that frequency +/-.167 or (1/6) Hz. In >>my example above, my 2Hz value would then consist of data from >>1.8333 to 2.1667Hz. This would mean that there are gaps in the >>spectral data and a smaller number of cycles or smaller width would >>lead to larger bandwidth (i.e. decreasing frequency resolution). >>What do you think? > >The spectral bandwidth of your time-frequency tranform is not >constant but a function of frequency. For your example, the spectral >bandwidth (in standard deviations, Hz) is computed as: > >bandwidth = cfg.foi ./ cfg.width; > >For a constant cfg.width, the spectral bandwidth increases linearly >with the frequency of interest. While at 18 Hz you have a spectral >bandwidth of 3 Hz, the bandwidth at 60 Hz is 10 Hz. > >>Also, does fieldtrip have a function that gives "phase locking >>factor" or inter-trial coherence (ITC)? > >Not that I know. However, you could compute ITC yourself based on the >complex output from freqanalysis_mtmconvol run with cfg.output = >'fourier'. > >Best, >Markus > From Jan.Schoffelen at FCDONDERS.RU.NL Wed Oct 18 09:47:45 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Wed, 18 Oct 2006 09:47:45 +0200 Subject: freqanalysis_wltconvol.m In-Reply-To: <6.1.2.0.2.20061017173241.01def4e0@email.med.yale.edu> Message-ID: Dear Brian, >Regarding phase-locking factor/ITC, couldn't I try to use the complex data >within the freqanalysis_wltconvol to calculate these data in a similar >method to that in the Tallon-Baudry et. al. '97 gamma paper? The wltconvol >function is so similar to that paper's analysis already, it seems like I >would only need to divide the complex data by its absolute value. The >paper refers to taking the "modulus of this complex value," where the >complex value is: >Pi(f,f0) = w(t,f0) X si(t,f0)/ | w(t,f0) X si(t,f0) I would implement the ITC as follows: itc = abs(mean(x./abs(x))); in which x is a vector of complex numbers representing your single-trial observations (in a single channel and a single frequencybin). Markus pointed out that you could use freqanalysis_mtmfft with cfg.output = 'fourier' to obtain these complex numbers, but apparently freqanalysis_wltconvol gives you a complex output as well. The above formula is how it is for example done in Tallon-Baudry '97 >I read this as the dividing the imaginary, sine wave, portion of the >wavelet (representing phase angle) at any given time and frequency by its >absolute value. Beware: a complex number can be represented as: B(cos*x+isin*x), or as A*exp(phi*i). The imaginary part you refer to is indeed the 'sine wave' but is not the whole story about the phase. The phase phi is determined both by the sine part and the cosine part. By normalizing with the absolute value, you divide the complete complex number by its amplitude, i.e. also the cosine part. If you think of it as a polar notation (A*exp(phi*i)), you divide the number by A, leaving a unit vector pointing in a particular direction (as determined by phi). >Does modulus have the same functionality/meaning as the >C++ mod or matlab rem function? The modulus of a complex number is its absolute, i.e. |x|, the corresponding matlab-function is abs(). The functions mod (also exists in matlab) and rem, are concerned with remainders after division, and modulo-stuff, which is similar to remainders >Is there interest in phase-locking values in the FieldTrip user community? >I am interested in trying to implement what is described above, but it >would be nice to have others see the code and test it to be sure I have >calculated phase-locking values correctly. I guess so, hopefully you now have a handle of doing it yourself. Yours, Jan-Mathijs From esther.meeuwissen at FCDONDERS.RU.NL Wed Oct 18 13:04:07 2006 From: esther.meeuwissen at FCDONDERS.RU.NL (Esther Meeuwissen) Date: Wed, 18 Oct 2006 13:04:07 +0200 Subject: cfg.highlight in topoplot Message-ID: Dear Fieldtrip users, Does anyone have suggestions how I can define two different cfg.highlights for 1 topoplot? For instance, to get a topoplot is an ERP diffence wave with channels in positive clusters marked red and channels in negative clusters marked blue. Thanks you in advance. Esther Meeuwissen From marco.buiatti at GMAIL.COM Thu Oct 19 12:13:18 2006 From: marco.buiatti at GMAIL.COM (Marco Buiatti) Date: Thu, 19 Oct 2006 12:13:18 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: Message-ID: Dear Robert, I followed your advice again, and made a (hopefully correct!) design matrix (I agree it clarifies what I am really computing). Now timelockstatistics starts to compute the statistics on the correct number of permutations, but as you can see from the results below, I still had some problems that I do not understand. This time I took three subjects instead of two, but the result does not depend on the subject's number. I also checked that I did not pick up any two identical datasets, and that ERPs are pretty standard (I expect no difference on N1, and difference on P300). Thank you in advance for your help, Marco % loading data from eeglab datasets EEG50PW_s2 = pop_loadset( '02_ev_ep_soa50PW.set','F:\joachim\'); EEG50W_s2 = pop_loadset( '02_ev_ep_soa50W.set','F:\joachim\'); EEG50PW_s4 = pop_loadset( '04_ev_ep_soa50PW.set','F:\joachim\'); EEG50W_s4 = pop_loadset( '04_ev_ep_soa50W.set','F:\joachim\'); EEG50PW_s5 = pop_loadset( '05_ev_ep_soa50PW.set','F:\joachim\'); EEG50W_s5 = pop_loadset( '05_ev_ep_soa50W.set','F:\joachim\'); % Transform to FieldTrip format data50PW{1} = eeglab2fieldtrip( EEG50PW_s2, 'timelockanalysis' ); data50W{1} = eeglab2fieldtrip( EEG50W_s2, 'timelockanalysis' ); data50W{2} = eeglab2fieldtrip( EEG50W_s4, 'timelockanalysis' ); data50PW{2} = eeglab2fieldtrip( EEG50PW_s4, 'timelockanalysis' ); data50W{3} = eeglab2fieldtrip( EEG50W_s5, 'timelockanalysis' ); data50PW{3} = eeglab2fieldtrip( EEG50PW_s5, 'timelockanalysis' ); % Loading channel names and positions data = eeglab2fieldtrip(EEG50PW_s2,'chanloc'); for i=1:3 data50W{i}.elec=data.elec; data50PW{i}.elec=data.elec; end; >> data50PW data50PW = [1x1 struct] [1x1 struct] [1x1 struct] >> data50PW{1} ans = label: {129x1 cell} fsample: 250 elec: [1x1 struct] avg: [129x523 single] var: [129x523 single] time: [1x523 double] dimord: 'chan_time' cfg: [1x1 struct] % designing design matrix cfg = [] cfg.design = [1 1 1 2 2 2; 1 2 3 1 2 3]; 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 % Setting cfg for timelockstatistics cfg.statistic='depsamplesT'; cfg.numrandomization = 'all'; cfg.alpha=0.05; cfg.clusterstatistics='maxsum'; cfg.clusterthreshold = 'parametric'; cfg.clusteralpha = 0.05; cfg.neighbourdist=4; cfg.neighbours = neighbourselection(cfg,data50PW{1}); cfg.latency=[0 0.5]; cfg.method = 'montecarlo'; cfg.correctm = 'cluster'; cfg = [] Using the electrode configuration from the dataset. there are on average 128.0 neighbours per channel stat = timelockstatistics(cfg,data50W{:},data50PW{:}); selected 129 channels selected 126 time bins selected 1 frequency bins using "statistics_montecarlo" for the statistical testing using "statfun_depsamplesT" for the single-sample statistics constructing randomized design total number of measurements = 6 total number of variables = 2 number of independent variables = 1 number of unit variables = 1 number of control variables = 0 number of within-block variables = 0 repeated measurement in variable 2 over 3 levels number of repeated measurements in each level is 2 2 2 creating all possible permutations (8) computing a parmetric threshold for clustering computing statistic Warning: Divide by zero. > In fieldtrip-20061016\private\statfun_depsamplesT at 106 In statistics_montecarlo at 249 In fieldtrip-20061016\private\statistics_wrapper at 233 In timelockstatistics at 50 estimated time per randomization is 0 seconds computing statistic 1 from 8 Warning: Divide by zero. > In fieldtrip-20061016\private\statfun_depsamplesT at 106 In statistics_montecarlo at 278 In fieldtrip-20061016\private\statistics_wrapper at 233 In timelockstatistics at 50 computing statistic 2 from 8 Warning: Divide by zero. > In fieldtrip-20061016\private\statfun_depsamplesT at 106 In statistics_montecarlo at 278 In fieldtrip-20061016\private\statistics_wrapper at 233 In timelockstatistics at 50 ... same output up to statistic 8 and then ??? Attempted to access (2); index out of bounds because numel()=1. Error in ==> fieldtrip-20061016\private\clusterstat at 65 postailcritval = cfg.clustercritval(2); Error in ==> statistics_montecarlo at 305 stat = clusterstat(cfg, statrand, statobs); Error in ==> fieldtrip-20061016\private\statistics_wrapper at 233 [stat, cfg] = statmethod(cfg, dat, cfg.design); Error in ==> timelockstatistics at 50 [stat] = statistics_wrapper(cfg, varargin{:}); On 10/16/06, Robert Oostenveld wrote: > Hi Marco > > Your script looks ok. > > On 13 Oct 2006, at 19:03, Marco Buiatti wrote: > > ??? Undefined variable "data" or class "data.biol". > > > > Error in ==> fieldtrip-20061012/private/prepare_design at 92 > > nrepl=size(data.biol,1); > > > > Error in ==> fieldtrip-20061012/private/statistics_wrapper at 212 > > [cfg] = prepare_design(cfg); > > > > Error in ==> timelockstatistics at 50 > > [stat] = statistics_wrapper(cfg, varargin{:}); > > Yep, that is a known problem (sorry about that). The function > prepare_design is not working properly. I suggest to make a design > matrix in cfg.design by hand (similar to, but not completely the same > as in SPM). It is not difficult, and it will also make you more clear > how it works. Please have a look at > https://listserv.surfnet.nl/scripts/wa.exe? > A2=ind0607&L=FIELDTRIP&P=R3192&I=-3&X=77C04E25A87526C2B4 > or if that URL does not work, then search the fieldtrip discussion > list archive for the string "cfg.design". > > best regards, > Robert > > PS note that you can also use timelockstatistics on the > 'componentanalysis' part of the EEGLAB data, in that case you cannot > use channel clustering, but you still can use timepoint clustering > (so cfg.neighbours should be []). You shoudl only do that if the ICA > components in the different EEG datasets are spatially the same (or > sufficiently similar, e.g. after clustering over subjects in the new > EEGLAB). > -- Marco Buiatti - Post Doc ************************************************************** Cognitive Neuroimaging Unit - INSERM U562 Service Hospitalier Frederic Joliot, CEA/DRM/DSV 4 Place du general Leclerc, 91401 Orsay cedex, France Telephone: +33 1 69 86 77 65 Fax: +33 1 69 86 78 16 E-mail: marco.buiatti at gmail.com Web: www.unicog.org *************************************************************** From r.oostenveld at FCDONDERS.RU.NL Thu Oct 19 16:39:17 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 19 Oct 2006 16:39:17 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: <22f732b0610190313y30ab9dd5p9ce335337184d8a2@mail.gmail.com> Message-ID: Dear Marco On 19 Oct 2006, at 12:13, Marco Buiatti wrote: > computing statistic 1 from 8 > Warning: Divide by zero. >> In fieldtrip-20061016\private\statfun_depsamplesT at 106 > In statistics_montecarlo at 278 > In fieldtrip-20061016\private\statistics_wrapper at 233 > In timelockstatistics at 50 > computing statistic 2 from 8 > Warning: Divide by zero. >> In fieldtrip-20061016\private\statfun_depsamplesT at 106 > In statistics_montecarlo at 278 > In fieldtrip-20061016\private\statistics_wrapper at 233 > In timelockstatistics at 50 > > ... same output up to statistic 8 and then Hmm, to me this seems to indicate that you have samples at which you do not have any variance, i.e. the computation of the t-score is mean_difference/pooled_variance, and since variance is zero, you have someting divided by zero, probably resulting in "Inf", i.e. infinite numbers. Could it be that you have baseline corrected data that is corrected to only one sample (i.e. the sample at time t=0), and that hence one sample in the data is always zero? I don't know how a t-score of Inf will affect the other computations. But the actual problem is > ??? Attempted to access (2); index out of bounds because numel()=1. > > Error in ==> fieldtrip-20061016\private\clusterstat at 65 > postailcritval = cfg.clustercritval(2); > > Error in ==> statistics_montecarlo at 305 > stat = clusterstat(cfg, statrand, statobs); > > Error in ==> fieldtrip-20061016\private\statistics_wrapper at 233 > [stat, cfg] = statmethod(cfg, dat, cfg.design); > > Error in ==> timelockstatistics at 50 > [stat] = statistics_wrapper(cfg, varargin{:}); That problem is NOT due to the warning above (i.e. the potential t- value of inf), but just a small programming error. The sequence of if- statements in that section of code was the wrong way around. Please find a corrected version of clusterstat.m attached to this mail. Actually, looking further into the code, I am surprised that you get this error. It means that the low level statfun_depsamplesT is using a cfg.tail=1 (that corresponds to cfg.clustertail in statistics_montecarlo itself). But from your cfg I do not see that you explicitely define a positive-tailed test, and the default set at the level of statistics_montecarlo should be two-tailed. Do you have any ideas about this yourself? best regards, Robert --- PS you can type dbstop if error on the matlab promt to start using the matlab debugger, and dbclear all to get rid of it again. That will help a lot in diagnosing problems like these. See "help dbstop" -------------- next part -------------- A non-text attachment was scrubbed... Name: clusterstat.m Type: application/octet-stream Size: 26868 bytes Desc: not available URL: From marco.buiatti at GMAIL.COM Fri Oct 20 19:02:08 2006 From: marco.buiatti at GMAIL.COM (Marco Buiatti) Date: Fri, 20 Oct 2006 19:02:08 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: <7BCCB2F0-B1B5-458A-8B2B-7E97FAFE1103@fcdonders.ru.nl> Message-ID: Thank you Robert, now EVERYTHING WORKS!!! More in detail: On 10/19/06, Robert Oostenveld wrote: > > computing statistic 2 from 8 > > Warning: Divide by zero. > >> In fieldtrip-20061016\private\statfun_depsamplesT at 106 > > In statistics_montecarlo at 278 > > In fieldtrip-20061016\private\statistics_wrapper at 233 > > In timelockstatistics at 50 > > > > ... same output up to statistic 8 and then > > Hmm, to me this seems to indicate that you have samples at which you > do not have any variance, i.e. the computation of the t-score is > mean_difference/pooled_variance, and since variance is zero, you have > someting divided by zero, probably resulting in "Inf", i.e. infinite > numbers. Could it be that you have baseline corrected data that is > corrected to only one sample (i.e. the sample at time t=0), and that > hence one sample in the data is always zero? You were right, and the reason for this was even more trivial: I had included the reference channel, which is always zero by definition. Now data are in average reference. > > I don't know how a t-score of Inf will affect the other computations. > But the actual problem is > > > ??? Attempted to access (2); index out of bounds because numel()=1. > > > > Error in ==> fieldtrip-20061016\private\clusterstat at 65 > > postailcritval = cfg.clustercritval(2); > > > > Error in ==> statistics_montecarlo at 305 > > stat = clusterstat(cfg, statrand, statobs); > > > > Error in ==> fieldtrip-20061016\private\statistics_wrapper at 233 > > [stat, cfg] = statmethod(cfg, dat, cfg.design); > > > > Error in ==> timelockstatistics at 50 > > [stat] = statistics_wrapper(cfg, varargin{:}); > > That problem is NOT due to the warning above (i.e. the potential t- > value of inf), but just a small programming error. The sequence of if- > statements in that section of code was the wrong way around. Please > find a corrected version of clusterstat.m attached to this mail. > > Actually, looking further into the code, I am surprised that you get > this error. It means that the low level statfun_depsamplesT is using > a cfg.tail=1 (that corresponds to cfg.clustertail in > statistics_montecarlo itself). But from your cfg I do not see that > you explicitely define a positive-tailed test, and the default set at > the level of statistics_montecarlo should be two-tailed. Do you have > any ideas about this yourself? Everything works now with the new clusterstat.m! Here you are my cfg at the point where it crashed before: cfg = design: [2x6 double] ivar: 1 uvar: 2 statistic: 'depsamplesT' numrandomization: 'all' alpha: 0.0500 clusterstatistics: 'maxsum' clusterthreshold: 'parametric' clusteralpha: 0.0500 neighbourdist: 0.8000 neighbours: {1x129 cell} latency: [0 0.5000] method: 'montecarlo' correctm: 'cluster' channel: {129x1 cell} frequency: [] avgoverchan: 'no' avgovertime: 'no' avgoverfreq: 'no' channelcmb: [] precision: 'double' version: [1x1 struct] previous: {1x6 cell} dim: [129 1 126] tail: 0 feedback: 'text' cvar: [] wvar: [] clusterstatistic: 'maxsum' clustercritval: 2.9200 clustertail: 0 factor: 1 unitfactor: 2 orderedstats: 'no' multivariate: 'no' minnbchan: 0 As you see, cfg.tail=0 but I have only one value of cfg.clustercritval (while the former clusterstat required two). I checked that results are totally compatible with the ones I obtained with clusterrandanalysis, and I easily transformed the spatial data I have (what I erroneously called scalar in my initial e-mail in this thread) to perform cluster randomization analysis. Thank you again for the follow up. Marco -- Marco Buiatti - Post Doc ************************************************************** Cognitive Neuroimaging Unit - INSERM U562 Service Hospitalier Frederic Joliot, CEA/DRM/DSV 4 Place du general Leclerc, 91401 Orsay cedex, France Telephone: +33 1 69 86 77 65 Fax: +33 1 69 86 78 16 E-mail: marco.buiatti at gmail.com Web: www.unicog.org *************************************************************** From lorina_naci at YAHOO.CO.UK Mon Oct 23 19:18:01 2006 From: lorina_naci at YAHOO.CO.UK (Lorina Naci) Date: Mon, 23 Oct 2006 18:18:01 +0100 Subject: Within-subject coherence statististics for virtual sources Message-ID: Dear FIELDTRIP members, I have used BESA to perform source coherence calculations for a multiple-subject/multiple-condition experiment. I have 14 subjects, and 2 conditions for which I’d like to compare coherence values. I have calculated coherence values in the Time-Frequency domain for each person. Given that BESA cannot calculate statistics in a multiple-subject study, their support personnel directed me towards FieldTrip. I would like to use your existing script ‘clusterrandanalysis on TFRs of power that were computed with BESA,’ but I cannot relate this to my data as the coherence values have been calculated for ROI sources, (8 per hemisphere - 16 sources total), and not for electrodes (I had 128). Do you have any advice regarding how I may adopt the script to for source coherence as opposed to electrode coherence? How do I import the source locations? Many thanks is advance for your help, Lorina Send instant messages to your online friends http://uk.messenger.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jaredvs at GMAIL.COM Mon Oct 23 22:28:28 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Mon, 23 Oct 2006 16:28:28 -0400 Subject: Incorrect coordinates? In-Reply-To: <2992F646-2E64-452D-8E51-9F9C121A63E0@fcdonders.ru.nl> Message-ID: Hi Robert, I just wanted to let you know that your suggestion was correct (I was working on a deadline for Friday, otherwise I would've responded sooner), the problem was created by the fact that the out of brain voxels were not masked out in the BESA data. The results of the analysis after masking appropriately were drastically different, and were all within-brain and make sense in light of the experimental task. I used the following code to obtain the mask: inside=[]; for k=1:length(files) src(k)=besa2fieldtrip([files(k).name]); in=find(src(k).avg.pow); inside(end+1:end+length(in))=in; end inside=unique(inside); outside=1:49708; outside(inside)=[]; for k=1:length(files) src(k).inside=inside; src(k).outside=outside; end This ensured that all the subjects had the same mask, and only values that were 0 in all the subjects were masked out. I manually checked all the subjects and there was at most a difference of 3 in the number of nonzero voxels in any two subjects. You might want to document this somewhere for other users, as it's not immediately apparent that specification of the .inside and .outside fields in the source structure are critical for further processing steps to behave correctly. Thanks for your help, -Jared On 10/16/06, Robert Oostenveld wrote: > > Hi Jared, > > On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > > I've rerun the analysis with mri's that were reoriented to MNI, and > > the same problem has emerged. > > I would guess that the anatomical MRIs themselves do not influence > the coordinate system of the source reconstruction. That would > influence the interpolation though. > > If you do > source = besa2fieldtrip(filename1) > and > mri = read_fcdc_mri(filename) > then the source structure is defined using the source.pos field that > describes the position of each source. SInce in this case the > positions are on a regular 3D grid, there is additional structure in > the arrangement of source.pos, which is described using source.xgrid, > source.ygrid, source.zgrid. > > If you do > tmp = reshape(source.avg.pow, source.dim) > you will get a 3D array with along the first dimension the voxels > along the x-axis, etc. The 1..Nth voxels along the xasix have the X > coordinates source.xgrid(1)..source.xgrid(N). Similar for the Y and Z > coordinates. That allows you to determine the coordinate of each voxel. > > Since the anatomical MRI is typically of much higher resolution, you > can use sourceinterpolate which interpolates the source (or stat) > volumes onto the voxel locations that are in the anatomical MRI. I.e. > sourceinterpolate upsamples the functional data to the anatomical > MRI. Normally you would do sourceinterpolate AFTER calling > sourcestatistics, since the source positions in all subjects are all > based on the same standard realistic head moidel in BESA and hence > the source positions in all subjects are the same (please check > whether positions are all the same over subjects/conditions). > > If you work with MEG or with EEG individual headmodels, the source > positions in all subjects are all different, which requires > sourceanalysis->sourceinterpolate->volumenormalize as shown in the > schema for http://www2.ru.nl/fcdonders/fieldtrip/doku.php? > id=fieldtrip:documentation:analysis_protocols#source_reconstruction_for_ > multiple_subjects > > > The typo you noted in your last email was indeed the reason for the > > empty src plot. Plotting src, interp, volume, and grandavg, > > everything looks ok. The 'pow' parameter values all appear within > > the brain. The tscore and p values in stat, however, are all messed > > up. I've attached .bmp's from using sourceplot on grandavg and stat > > to this email. The quality is poor (matlab's figure window doesn't > > ever save bmp's very well), but it should demonstrate the problem > > clearly. Note all the large values outside of the brain. > > In your case you should be able to do besa2fieldtrip -> > sourcestatistics, and then the source positions with the statistical > data on them should stll be the same as the positions with the > original functional data on them. After doing the statistics (or > after doing sourcegrandaverage), you can interpolate the functional/ > statistical data onto the MRI. But since the statistical data and the > functional (beamed power) data are on the same coordinates, there > should not be a difference between them. > > > Any comments you have would be greatly appreciated. I've considered > > just masking out everything that's not in the brain, but I'm not > > confident that the within-brain values are accurate. > > Looking at the bitmaps, I cannot see teh anatomy, but I do see a > brain-shaped outline with some blobs in them. I cannot recognise the > problem from these figures, to me they seem ok. The only problem that > I can see is the one that you also mention, and that is for the > masking. In the original source data (i.e. output from > besa2fieldtrip) there is an source.inside and source.outside field. > Those should contain the indices of the voxels (linear indices, so > voxel [1 1 1] has index 1 and voxel [2 1 1] has index 2...) of the > sources that are inside the brain and outside the brain. Only the > inside voxels are considered for sourcestatistics and for > sourceinterpolation. However, the problem with BESA data is that it > does not describe the inside/outside voxels and therefoer by default > all voxels are marked as inside. Perhaps you can determine the inside/ > outside voxels manually, e.g. > source.inside = find(source.avg.pow(:)>eps); > source.outside = find(source.avg.pow(:) After fixing the inside/outside, you can rerun sourcestatistics and > the rest. See the related FAQ http://www2.ru.nl/fcdonders/fieldtrip/ > doku.php? > id=fieldtrip:documentation:frequently_asked_questions#why_is_there_a_rim > _around_the_brain_for_which_the_source_reconstruction_is_not_computed > > To me it seems that the outside brain mess is caused by an > interpolation artifact, which can well be explained by the missing > inside/outside specification of besa. After fixing the inside/outside > vectors in the source structure, and passing it through > sourceinterpolate, you will get an interp.inside 3D boolean volume > with 0s and 1s for outside and inside voxels. You can element-wise > multiply the data with it, to mask the outside, or you can specify > cfg.mask='inside' in sourceplot (which uses opacity). > > Hope this helps, if not, please put some data (source, mri, stat, > interp) in a zip file on ftp://ftp.fcdonders.nl/pub/incoming > > Robert > -- Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jan.Schoffelen at FCDONDERS.RU.NL Tue Oct 24 15:31:57 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Tue, 24 Oct 2006 15:31:57 +0200 Subject: Within-subject coherence statististics for virtual sources In-Reply-To: <20061023171801.37444.qmail@web28106.mail.ukl.yahoo.com> Message-ID: Dear Lorina, For the time being, I assume that you have your data imported into a fieldtrip-like format, using besa2fieldtrip. I am not familiar with this function, but when I read the help of besa2fieldtrip I guess that your besa file was a .tfc file. So probably your data-object looks like what fieldtrip considers to be a frequency-structure, containing a TFR for each ROI. I guess you have two data-objects for each subject. What you would like to do is possible within fieldtrip, but I would advise you not to use clusterrandanalysis to get there. Quite some correspondence has been devoted to the new statistical interface, you can read about it on the discussion list's website (follow the appropriate links on the fieldtrip website), concerning Re: clusterrandanalysis on scalar values + problem with topoplotER during the past month, but which started in August. In a nutshell: instead of using clusterrandanalysis you could use freqstatistics (under the above assumption that your data resembles a fieldtrip-frequency structure) with the appropriate settings to get your statistics done. Freqstatistics relies on statistics_montecarlo, when you specify cfg.method = 'montecarlo'. Please have a try following the thread on the discussion list, and the following configuration settings, as well as the information in statistics_montecarlo and other dependent functions. You'll probably need the attached function as well, which computes your statistic of interest. Cfg = []; Cfg.method = 'montecarlo'; Cfg.statistic = 'diff'; Cfg.parameter = 'cohspctrm'; %This is at least what I expect your data objects to contain! Cfg.numrandomization = a number; Cfg.design = [1 1 2 2 3 3 with all the numbers in between 14 14; . 1 2 1 2 1 2 with all the numbers in between 1 2]; %this specifies how the data has to be interpreted Cfg.ivar = 2; %row-index of independent variable, which is the condition in your case Cfg.uvar = 1; %row-index of the 'unit'-variable, your unit of observation, which are your individual subjects. %the design-matrix will be shuffled, by swapping the 1 and 2's in the ivar-row, while keeping the uvar-doublets together. Cfg.correctm = 'yes'; %keep it at this for the time being, we have to develop a cunning strategy to incorporate something about the neighbourhood structure of your ROIs %as soon as you get your script running, you can try to incorporate fancy multiple-comparison correction strategies, such as clustering in time and frequency. Stat = freqstatistics(cfg, subj1cond1, subj1cond2, subj2cond1, subj2cond2 ..); %take care that this corresponds with how you specified your design. Subjxconx should then be the data-structure containing your TFRs in a field called cohspctrm. I hope this puts you on track, Yours, Jan-Mathijs _____ From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Lorina Naci Sent: Monday, October 23, 2006 7:18 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: [FIELDTRIP] Within-subject coherence statististics for virtual sources Dear FIELDTRIP members, I have used BESA to perform source coherence calculations for a multiple-subject/multiple-condition experiment. I have 14 subjects, and 2 conditions for which I'd like to compare coherence values. I have calculated coherence values in the Time-Frequency domain for each person. Given that BESA cannot calculate statistics in a multiple-subject study, their support personnel directed me towards FieldTrip. I would like to use your existing script 'clusterrandanalysis on TFRs of power that were computed with BESA,' but I cannot relate this to my data as the coherence values have been calculated for ROI sources, (8 per hemisphere - 16 sources total), and not for electrodes (I had 128). Do you have any advice regarding how I may adopt the script to for source coherence as opposed to electrode coherence? How do I import the source locations? Many thanks is advance for your help, Lorina Send instant messages to your online friends http://uk.messenger.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: statfun_diff.m Type: application/octet-stream Size: 990 bytes Desc: not available URL: From r.oostenveld at FCDONDERS.RU.NL Wed Oct 25 08:05:27 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 25 Oct 2006 08:05:27 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610231328y1b3d2093xe9b02abf4b3af113@mail.gmail.com> Message-ID: Hi Jared, Thanks for your detailled feedback. I think that it is a good idea to document these steps for other BESA users. I am rather busy, but maybe you could do it yourself? The FieldTrip website is a Wiki, and anyone can edit and contribute to it by pressing the "edit this page" button that you see on every page. Regarding this information: I would put it under a subheading (with some introductory comments, which probably can be copied-pasted from our previous mails) on the BESA-related page, i.e. on http://www2.ru.nl/fcdonders/fieldtrip/ doku.php?id=fieldtrip:documentation:integrating_with_besa best regards, Robert On 23 Oct 2006, at 22:28, Jared Van Snellenberg wrote: > Hi Robert, > > I just wanted to let you know that your suggestion was correct (I > was working on a deadline for Friday, otherwise I would've > responded sooner), the problem was created by the fact that the out > of brain voxels were not masked out in the BESA data. The results > of the analysis after masking appropriately were drastically > different, and were all within-brain and make sense in light of the > experimental task. > > I used the following code to obtain the mask: > > inside=[]; > > > for k=1:length(files) > src(k)=besa2fieldtrip([ > > files(k).name]); > in=find(src(k).avg.pow); > > inside(end+1:end+length(in))=in; > > > end > inside=unique(inside); > > outside=1:49708; > > outside(inside)=[]; > > > for k=1:length(files) > src(k).inside=inside; > > src(k).outside=outside; > > > endThis ensured that all the subjects had the same mask, and only > values that were 0 in all the subjects were masked out. I manually > checked all the subjects and there was at most a difference of 3 in > the number of nonzero voxels in any two subjects. > > You might want to document this somewhere for other users, as it's > not immediately apparent that specification of the .inside > and .outside fields in the source structure are critical for > further processing steps to behave correctly. > > Thanks for your help, > > -Jared > > > > > On 10/16/06, Robert Oostenveld > wrote: Hi Jared, > > On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > > I've rerun the analysis with mri's that were reoriented to MNI, and > > the same problem has emerged. > > I would guess that the anatomical MRIs themselves do not influence > the coordinate system of the source reconstruction. That would > influence the interpolation though. > > If you do > source = besa2fieldtrip(filename1) > and > mri = read_fcdc_mri(filename) > then the source structure is defined using the source.pos field that > describes the position of each source. SInce in this case the > positions are on a regular 3D grid, there is additional structure in > the arrangement of source.pos, which is described using source.xgrid, > source.ygrid, source.zgrid. > > If you do > tmp = reshape(source.avg.pow , source.dim) > you will get a 3D array with along the first dimension the voxels > along the x-axis, etc. The 1..Nth voxels along the xasix have the X > coordinates source.xgrid(1)..source.xgrid(N). Similar for the Y and Z > coordinates. That allows you to determine the coordinate of each > voxel. > > Since the anatomical MRI is typically of much higher resolution, you > can use sourceinterpolate which interpolates the source (or stat) > volumes onto the voxel locations that are in the anatomical MRI. I.e. > sourceinterpolate upsamples the functional data to the anatomical > MRI. Normally you would do sourceinterpolate AFTER calling > sourcestatistics, since the source positions in all subjects are all > based on the same standard realistic head moidel in BESA and hence > the source positions in all subjects are the same (please check > whether positions are all the same over subjects/conditions). > > If you work with MEG or with EEG individual headmodels, the source > positions in all subjects are all different, which requires > sourceanalysis->sourceinterpolate->volumenormalize as shown in the > schema for http://www2.ru.nl/fcdonders/fieldtrip/doku.php ? > id=fieldtrip:documentation:analysis_protocols#source_reconstruction_fo > r_ > multiple_subjects > > > The typo you noted in your last email was indeed the reason for the > > empty src plot. Plotting src, interp, volume, and grandavg, > > everything looks ok. The 'pow' parameter values all appear within > > the brain. The tscore and p values in stat, however, are all messed > > up. I've attached .bmp's from using sourceplot on grandavg and stat > > to this email. The quality is poor (matlab's figure window doesn't > > ever save bmp's very well), but it should demonstrate the problem > > clearly. Note all the large values outside of the brain. > > In your case you should be able to do besa2fieldtrip -> > sourcestatistics, and then the source positions with the statistical > data on them should stll be the same as the positions with the > original functional data on them. After doing the statistics (or > after doing sourcegrandaverage), you can interpolate the functional/ > statistical data onto the MRI. But since the statistical data and the > functional (beamed power) data are on the same coordinates, there > should not be a difference between them. > > > Any comments you have would be greatly appreciated. I've considered > > just masking out everything that's not in the brain, but I'm not > > confident that the within-brain values are accurate. > > Looking at the bitmaps, I cannot see teh anatomy, but I do see a > brain-shaped outline with some blobs in them. I cannot recognise the > problem from these figures, to me they seem ok. The only problem that > I can see is the one that you also mention, and that is for the > masking. In the original source data (i.e. output from > besa2fieldtrip) there is an source.inside and source.outside field. > Those should contain the indices of the voxels (linear indices, so > voxel [1 1 1] has index 1 and voxel [2 1 1] has index 2...) of the > sources that are inside the brain and outside the brain. Only the > inside voxels are considered for sourcestatistics and for > sourceinterpolation. However, the problem with BESA data is that it > does not describe the inside/outside voxels and therefoer by default > all voxels are marked as inside. Perhaps you can determine the inside/ > outside voxels manually, e.g. > source.inside = find(source.avg.pow(:)>eps); > source.outside = find(source.avg.pow(:) After fixing the inside/outside, you can rerun sourcestatistics and > the rest. See the related FAQ http://www2.ru.nl/fcdonders/fieldtrip/ > doku.php? > id=fieldtrip:documentation:frequently_asked_questions#why_is_there_a_r > im > _around_the_brain_for_which_the_source_reconstruction_is_not_computed > > To me it seems that the outside brain mess is caused by an > interpolation artifact, which can well be explained by the missing > inside/outside specification of besa. After fixing the inside/outside > vectors in the source structure, and passing it through > sourceinterpolate, you will get an interp.inside 3D boolean volume > with 0s and 1s for outside and inside voxels. You can element-wise > multiply the data with it, to mask the outside, or you can specify > cfg.mask='inside ' in sourceplot (which uses opacity). > > Hope this helps, if not, please put some data (source, mri, stat, > interp) in a zip file on ftp://ftp.fcdonders.nl/pub/incoming > > Robert > > > > -- > Jared Van Snellenberg > Social Cognitive Affective Neuroscience Unit > http://scan.psych.columbia.edu > (212) 854-7858 p > (212) 854-3609 f > Department of Psychology, Columbia University > 406 Schermerhorn Hall > 1190 Amsterdam Avenue, Mail Code 5501 > New York, NY 10027 From litvak at TX.TECHNION.AC.IL Tue Oct 31 15:06:21 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Tue, 31 Oct 2006 14:06:21 -0000 Subject: SPM integration Message-ID: Dear Robert and all, I'm starting to work on a project where I will analyze data preprocessed in FT with SPM5 (www.fil.ion.ucl.ac.uk/spm/). For this purpose I'd like to develop FT/SPM integration routines. I'll probably start with my immediate needs but I think I'm motivated enough at the moment to eventually turn it into something of general usefulness. If anyone has already worked in this direction and has some code or would like to collaborate please let me know. I'm affiliated to the methods group at FIL so I can get help from SPM developers if necessary. Right now I'd like to be able to use FT to read any FT supported format to SPM. Additional question: how does one create low-level routines for a new (rare) data format to be used by FT preprocessing? Is there a template or some interface they should adhere to? Thanks, Vladimir Litvak -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jan.Schoffelen at FCDONDERS.RU.NL Tue Oct 31 15:33:24 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Tue, 31 Oct 2006 15:33:24 +0100 Subject: Picturing wavelet shape In-Reply-To: <454238CD.4090706@psych.york.ac.uk> Message-ID: >Dear Jan > >Please can you advise me how to visualize the actual shape of the wavelets >produced by the two parameters: > >width and gwidth > >I am getting some interesting/frustrating effects whereby small changes in >both values (varying width between 3-5, and gwidth between 1-4) and can >flip the polarity in my spectral plots. In other words, the location in >time and frequency of significant power doesn't really change, but whether >these are assigned an increase(red) or decrease >(blue) in power does change relative to baseline. The spectrograms are >created with singleplotTFR , combined with a baseline. I know I am at the >resolution limits for these analyses, because of our relatively short time >windows, but I am hoping that these effects can be explained by subtle >changes in wavelet shape, and therefore I needn't worry too much. >Alternatively, I may be pushing the analysis to breaking point, where it is >too unreliable to report. But to help me decide, picturing the wavelet >structure would be a real help (I think). Dear Piers, Hmmm, the easy answer to your question is to extract some of the relevant lines to a new script and play around with that. When you look into the code, in my version (revision version 1.16) the wavelets are constructed, starting in line 214: (for foilop = 1:numfoi) dt = 1/data.fsample; sf = cfg.foi(foilop)/cfg.width(foilop); st = 1/(2*pi*sf); toi2 = -cfg.gwidth*st:dt:cfg.gwidth*st; A = 1/sqrt(st*sqrt(pi)); tap = (A*exp(-toi2.^2/(2*st^2)))'; ... (end) The vector tap contains the wavelet, which you can visualize with plot(tap); So far the easy part. However, it is a bit obscure that you get opposite effects by slightly adjusting your wavelet-parameters, and I suspect that that is not a wavelet issue, but rather a baseline-issue. If we look at your configuration for the plotting: cfg5 = []; cfg5.baseline = [-0.2 0.0]; %cfg5.baselinetype = 'relative'; cfg5.baselinetype = 'absolute'; cfg5.zlim = 'maxmin'; cfg5.xlim = [-0.0 0.3]; cfg5.ylim = [7 30]; cfg5.channel = 'V0'; singleplotTFR(cfg5, freq); You use a baseline-interval between -0.2 and 0. This essentially means, that you are subtracting the estimated baseline, averaged between -0.2 and 0. However, timepoint 0 contains quite some post-stimulus-onset stuff, because of the width of your wavelet kernel (which scales with frequency, so I would expect more of your strange effects in these ranges). If there's a strong evoked component in your data, which bleeds into your baseline estimate, this might lead to an overestimation of your baseline-power, and to a subsequent stimulus-locked decrease in power post-stimulus. If there's less bleeding into the baseline, the baseline estimate is lower, which would lead to a stimulus-locked increase in power, which I would expect at a earlier latency than the decrease described before. Best Jan-Mathijs From luca.ciancetta at TISCALI.IT Tue Oct 31 18:28:50 2006 From: luca.ciancetta at TISCALI.IT (Luca Ciancetta) Date: Tue, 31 Oct 2006 18:28:50 +0100 Subject: lcmv localization Message-ID: Dear List members, I'm trying to localize a source with the lcmv method. Following, it's the configuration I use: time_step = 1/h.smpfq; % the time step depends by sampling frequency time = 0:time_step:(500*time_step); % I want to see 500 points of data data.trial{1} = data_raw(gch,0:500); % gch: list of good channels data.time{1} = time; cfg = []; cfg.method = 'lcmv'; cfg.grid.pos = model; % model is a matrix [number_of_sources X 3]. This represent position of dipoles in the reference of the sphere which contains them. cfg.grad.tra = zeros(nch,nch); % number of good sensors ( size of 'gch' list ) for i=1:nch cfg.grad.pnt(i,: ) = h.ch(gch(i)+offset).pos(1).r_s.comp'; % positions of MEG sensors in the reference of the spherical model cfg.grad.ori(i,: ) = h.ch(gch(i)+offset).pos(1).u_s.comp'; % orientations of MEG sensors in the reference of the spherical model cfg.grad.tra(i,i) = 1; cfg.grad.label{i} = sprintf('MZ_%d\n',gch(i)-1); end cfg.vol = []; cfg.vol.r = 65; cfg.bpfilter = 'yes'; cfg.bpfreq = [1 100]; data.avg = squeeze(data.trial{1}); source = sourceanalysis(cfg,data); In this case I used only one trial and the result is a localization in the center of the sphere ( the source is a dipole simulation, it was placed on the surface of my spherical model). Also analyzing over more trials or using different data set, for example a median nerve stimulation, the result was the same. can you help me? Thanks, Luca. From P.PRAAMSTRA at BHAM.AC.UK Sun Oct 1 14:08:41 2006 From: P.PRAAMSTRA at BHAM.AC.UK (Peter Praamstra) Date: Sun, 1 Oct 2006 13:08:41 +0100 Subject: clusterrandanalysis Message-ID: Dear Robert / other fieldtrippers, I´m looking for advice on the following. I´m trying to do clusterrandanalysis on TFR data with the cfg. statistic=´actvsblT´ option. The tutorial `Cluster-level randomization tests´ gives an example in which separate TFRs are calculated for activation and baseline data. The clusterrandanalysis.m documentation also states that two datasets must be passed. However, I´d like to make the activation vs baseline comparison work for baseline and activation TF windows identified in single TFRs that include a prestimulus and a poststimulus period. To do so, I used cfg. latency, cfg. frequency and cfg. keepindividual with freqgrandaverage to create separate datastructures for the baseline and activation timefrequency windows of interest. Unfortunately, this doesn´t work. I get an error message: ??? Error using ==> clusterrandanalysis Not all time points in the first data set are in the activation (post-stimulus) period. This is probably due to clusterrandanalysis expecting a positive time axis for the activation data and a negative time axis for the baseline data. Hence, although I defined TF windows of equal length for activation and baseline, it looks like Fieldtrip is unable to ignore the original, but irrelevant, time axis definition. I considered reading in the same data twice (through freqgrandaverage) with different definitions of the time axes. However, this would still require clusterrandanalysis to deal with activation and baseline TF windows that are not matched in time on the time axes of their respective datastructures. So I suspect it would still not work. Any advice on how I could work around this would be greatly appreciated. Best wishes, Peter Praamstra -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.siegel at UKE.UNI-HAMBURG.DE Mon Oct 2 09:59:01 2006 From: m.siegel at UKE.UNI-HAMBURG.DE (Markus Siegel) Date: Mon, 2 Oct 2006 09:59:01 +0200 Subject: freqanalysis_wltconvol.m In-Reply-To: <6.1.2.0.2.20060929123621.059feec0@email.med.yale.edu> Message-ID: Dear Brian, cfg.width determines in cycles the width of the Morlet-wavelet as the standard deviation of the underlying gaussian (often termed "q"). One can either use a fixed q for all frequencies by giving only one number in cfg.width, or one can use a different q for each frequency of interest with a vector in cfg.width of the same length as cfg.foi. "help freqanalysis_wltconvol" gives you the relationship between cfg.width (width) , the frequency of interest (f0) and the standard- deviation (resolution) of the wavelet-transform in the temporal (st) and spectral (sf) domain: The standard deviation in the frequency domain (sf) at frequency f0 is defined as: sf = f0/width The standard deviation in the temporal domain (st) at frequency f0 is defined as: st = width/f0 = 1/sf The spectral bandwidth (in standard deviations, Hz) of the time- frequency transform can thus be computed as: bw = cfg.foi ./ cfg.width; The parameter cfg.gwidth determines the length of the wavelet-kernel used in standard deviations of the underlying gaussian. In other words, it specifies over how many standard deviations the gaussian is estimated for the morlet-wavelet in both directions. This does in principle not influence the spectro-temporal resolution of the transform, but determines its precision because the gaussian is non- zero at the edges. Therefore, small values (e.g. <2) lead to edge effects in the transform. The full length of the 'longest' wavelet at the lowest frequency cfg.foi(1) is thus computed as: 2 * cfg.gwidth (cfg.width(1) ./ cfg.foi(1)) In freqanalysis_wltconvol, the wavelet transform is implemented by multiplication in the frequency domain which is computationally more efficient than convolution in the temporal domain. However, technically the transform is well described as a convolution of the time-series with a complex Morlet-wavelet (complex sinusoid with a gaussian envelope) as e.g. provided in Tallon-Baudry et al., J Neurosci 1997. Best, Markus Am 29.09.2006 um 18:52 schrieb Brian Roach: > Dear FieldTrip users, > > I have been playing with the freqanalysis_wltconvol function in > hopes of using the morlet wavelet time frequency analysis on some > eeg data. I have been able to get it running, and I find that it > works very quickly, which is great. However, I am hoping some > users or F.T. programmers can explain some of the function inputs > and processing. The cfg example is as follows: > > % cfg.method = 'wltconvol'; > % cfg.foi = 1:1:100; > % cfg.width = 7; > % or > % cfg.width = linspace(5,10,length(cfg.foi)); > % cfg.toi = 0:0.1:2; > % cfg.gwidth = 3; > > I believe that the cfg.width specifies the number of wave cycles > used in each frequency's wavelet analysis (so at 2Hz, 7 cycles > spans 3500ms of data, right?). Maybe this is not correct, because > I do not seem to get the frequencies as low as I would expect given > my data epoch length. Perhaps this has to do with the cfg.gwidth > parameter, which I do not think I completely understand - what is it? > > Also, we do not have the matlab wavelet toolbox, and it appears > that it is not required, but how is the morlet wavelet > implemented? As I look through the code I see calls to fft, ifft, > and fftshift, but I wonder how I can give a good technical > description of this process if I find results in a larger data set. > > Finally, is there a function or a way to compute the frequency > bandwidth based on the cfg inputs, or is there a fix frequency > bandwith for each foi here? I am sure I am confusing a number of > things here, so no response is too simple. > > Thanks for any advice, please let me know if there is more > information I can give or if I can clarify my questions. > > Brian > From r.oostenveld at FCDONDERS.RU.NL Mon Oct 2 21:03:53 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 2 Oct 2006 21:03:53 +0200 Subject: clusterrandanalysis In-Reply-To: <451FBDD9.31055.628453@P.PRAAMSTRA.Bham.ac.uk> Message-ID: Hi Peter > I’m trying to do clusterrandanalysis on TFR data with the cfg. > statistic=’actvsblT’ option. The tutorial ‘Cluster-level > randomization tests’ gives an example in which separate TFRs are > calculated for activation and baseline data. The > clusterrandanalysis.m documentation also states that two datasets > must be passed. I am not that familiar with comparing activation versus baseline using the actvsblT statistic (it was implemented by Eric) but as I understand it, the rationale behind it is that all timepoints in the baseline are equivalent to all timepoints in the activation period. I.e. there is no intrinsic reason to compare one specific baseline timepoint with one specific timepoint in the active period, hence it implements a comparison in which all timepoints in the baseline are collapsed/averaged, and the active period is compared to this average. From the FT homepage documentation (http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? id=fieldtrip:documentation:tutorial:clusterrandanalysis) >> With cfg.statistic=’actvsblT’, we choose the so-called activation- >> versus-baseline T-statistic. By means of this statistic, we >> compare the power in every (channel, frequency, time)-element in >> the activation period with the corresponding average power >> (average over time) in the baseline period. The comparison of the >> activation and the average baseline power is performed by means of >> a pairwise T-statistic, with the pairs corresponding to the trials. However, the approach that I usually take (and also explain to other people here) for comparing two time windows in the same dataset is to copy the dataset into a dummy dataset and shift the timeaxis of the dummy dataset. E.g. dat = preprocessing(..) avg = timelockanalysis(..) % with keeptrials act = avg; bas = avg; bas.time = bas.time + 0.500; % shift the time axis, here the sample corresponding with -500ms is shifted to 0ms stat = clusterrandanalysis(cfg, bas, act) The statistisc then becomes a regular depsamplesT (i.e. paired data in the baseline and activation window). E.g. in the above example you could do figure plot(act.time, act.avg, 'r'); % in red hold on plot(act.time, act.avg, 'b'); % in blue and you would see the two ERPs shifted in time. This plot also makes it easy to identify the timewindow in which to do the statistical test (default is to take all overlapping time that is present in the input data). > However, I’d like to make the activation vs baseline comparison > work for baseline and activation TF windows identified in single > TFRs that include a prestimulus and a poststimulus period. To do > so, I used cfg. latency, cfg. frequency and cfg. keepindividual > with freqgrandaverage to create separate datastructures for the > baseline and activation timefrequency windows of interest. Here I cannot follow you. You have two conditions, each with a baseline and an active period. What is the comparison taht you want to make? I would presume that you do not expect differences in the baseline. If there were an a priori difference in the baseline, then a difference in the active period would seem trivial to me. So to me teh logical assumption would be that the baselines are the same and that you want to compare either the whole time interval or (equally valid) only the active period. I can also imagine that you want to compare the TFR data in the active window after correcting for eventual differences in the baseline. This would involve first doing a (single trial) baseline correction (expressing the power in each trial as relative number compared to the average in the baseline). In FT we have the freqbaseline function, however, that function sofar did not support single-trial baseline coprrections (only averaged powspctrm would be corrected). Please find attached a freqbaseline that will also do it on single trial powspectra. hope this helps, Robert -------------- next part -------------- A non-text attachment was scrubbed... Name: freqbaseline.m Type: application/octet-stream Size: 9714 bytes Desc: not available URL: From maris at NICI.RU.NL Mon Oct 2 21:28:03 2006 From: maris at NICI.RU.NL (Eric Maris) Date: Mon, 2 Oct 2006 21:28:03 +0200 Subject: clusterrandanalysis In-Reply-To: <451FBDD9.31055.628453@P.PRAAMSTRA.Bham.ac.uk> Message-ID: Hi Peter, I'm trying to do clusterrandanalysis on TFR data with the cfg. statistic='actvsblT' option. The tutorial 'Cluster-level randomization tests' gives an example in which separate TFRs are calculated for activation and baseline data. The clusterrandanalysis.m documentation also states that two datasets must be passed. However, I'd like to make the activation vs baseline comparison work for baseline and activation TF windows identified in single TFRs that include a prestimulus and a poststimulus period. To do so, I used cfg. latency, cfg. frequency and cfg. keepindividual with freqgrandaverage to create separate datastructures for the baseline and activation timefrequency windows of interest. This I don't understand. In my terminology, "baseline" and "prestimulus" are synonymous, as are "activation" and "poststimulus". The activation-versus-baseline statistic identifies samples (i.e., (sensor,frequency,time)-elements) in the activation/poststimulus period that are different from the time-average of the corresponding samples in the baseline/prestimulus period. If you use freqgrandaverage to create an activation and a baseline datastructure of the same size (with a positive time-axis for the activation period, and a negative time-axis for the baseline period), then clusterrandanalysis should do the job. Greetings, Eric Maris -------------- next part -------------- An HTML attachment was scrubbed... URL: From P.PRAAMSTRA at BHAM.AC.UK Tue Oct 3 14:13:02 2006 From: P.PRAAMSTRA at BHAM.AC.UK (Peter Praamstra) Date: Tue, 3 Oct 2006 13:13:02 +0100 Subject: clusterrandanalysis Message-ID: Hi Robert, Eric, many thanks for your helpful comments. Robert's was especially useful. Implementing the suggestion to shift the time axis revealed a glitch in besa2fieldtrip that I should have spotted earlier. It doesn't convert ms in s. As a result, cfg.latency or cfg.toilim statements using seconds as time unit don't work properly. This peculiarity concerns BESA TFR data; I don't know about other BESA data formats. Best regards, Peter From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 10:37:32 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 10:37:32 +0200 Subject: attention: default changed for MEG leadfields Message-ID: Dear fieldtrippers, I want to bring to your attention that I just changed the default value for the option cfg.reducerank in the SOURCANALYSIS and the PREPARE_LEADFIELD functions. The old default was 'no', the new default depends on the type of data that you are working with. In case of EEG, the new default is 3. This basically is the same as 'no', since the intrinsic rank of the EEG leadfield for a dipole is 3. So effectively nothing changed here. In case of MEG, the new default is 2. This was the value that I always recommend when someone would ask me for it. To prevent people from accidentally forgetting to set it to 2, we now decided to change the default. The change is immediate for people within the Donders, and for the external users it will become visible in the daily fieldtrip version on the FTP server this evening. Background: The cfg.reducerank option relates to how the leadfields are computed, and is only relevant for MEG in combination with realistic (localspheres, singleshell) volume conduction models for the head. In Fieldtrip, we always work with dipoles that can be oriented in x, y, and z direction. The dipole orientation and strenghth together form the dipole mooment. There is one particular [x,y,z] direction for the dipole for which it points to the surface of the head, i.e. that is the radial component. The magnetic field for that radial component is zero (in a single sphere model), or almost zero (in a realistic model). Since sources that are almost zero pick up a lot of noise in the beamformer method, it is desirable to explicitely set the leadfield in that direction to exactly zero. That is done by the reducerank option, which ensures that the leadfield will only contain the two tangential components and which makes the radial component zero. best regards, Robert From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 10:44:10 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 10:44:10 +0200 Subject: clusterrandanalysis In-Reply-To: <452261DE.19934.F0AE74@P.PRAAMSTRA.Bham.ac.uk> Message-ID: Hi Peter On 3 Oct 2006, at 14:13, Peter Praamstra wrote: > Implementing the suggestion to shift the time > axis revealed a glitch in besa2fieldtrip that I should have spotted > earlier. It > doesn't convert ms in s. As a result, cfg.latency or cfg.toilim > statements > using seconds as time unit don't work properly. > > This peculiarity concerns BESA TFR data; I don't know about other BESA > data formats. There are many variations of the BESA format, which makes them difficult to support. Every couple of months, someone will contact me with yet another BESA file that is not fully supported :-( Fieldtrip always works with seconds and not with ms, hence it should be fixed. I expect the problem to be on line 141 of besa2fieldtrip, which now reads data = []; data.time = Time; data.freq = Frequency; and probably this should read data = []; data.time = Time * 1e-3; % convert to seconds data.freq = Frequency; Can you confirm this? best, Robert From MZvyagintsev at UKAACHEN.DE Wed Oct 4 12:38:00 2006 From: MZvyagintsev at UKAACHEN.DE (Mikhail Zvyagintsev) Date: Wed, 4 Oct 2006 12:38:00 +0200 Subject: MEG realign In-Reply-To: <2093A833-C89D-4DB0-9D53-FB43A9DAF4A2@fcdonders.ru.nl> Message-ID: Dear Robert / other fieldtrippers, I have a question regarding MEG realign procedure. I actually found it very useful and trying to learn how to deal with it. I am using 4 D Neuroimaging mashine (BTi), and, therefore, I had to change the routine a bit - at least change settings, concerning the sensors name. In my particular case I got the message 'mean distance towards template gradiometers is 25.45 mm'. (I actually attached a picture regarding sensors' position's difference derived from Matlab, but probably it is not so easy to recognize what is what on this picture - points are sensors and different colors - positions in different sessions, the view is from front). And later in this routine I use the approach based on calculation of brain surface from headshape. As a headshape we use here points from bridge (of nose) to nape (of the neck). I get 644 dipoles from it 'prunedinv' subfunction gives me 'pruning 49 out of 148 singular values' (so, we use 148 channels mashine). After calculation of realign matrix and applying it for 'realigning trial' the residual variance (RV) which I get for one trial is arround 30%. I have a feelling that it is rather to much, or might be it's normal, becouse difference between sensors is rather big one. Because in case 'mean distance towards template gradiometers' was 6.48 mm - residual variances were arround 5-6%. So, distance RV 6.48 mm 5-6% 25.45 mm ~30%. My question is - is such RV difference correspondent to the difference distance I have and how many points should be like a 'control value' for 'prunedinv' routine? Thank you in advance, Mikhail Zvyagintsev -- __________________________________________________________________ Mikhail Zvyagintsev MD, BSc Klinik für Psychiatrie & Psychotherapie UK Aachen Pauwelsstr. 30 D-52074 Aachen tel +49-0241-80 85580 FAX +49-0241-80 82401 MZvyagintsev at UKAachen.de -------------- next part -------------- A non-text attachment was scrubbed... Name: session 1 and 3 positions.tif Type: image/tiff Size: 706680 bytes Desc: not available URL: From P.PRAAMSTRA at BHAM.AC.UK Wed Oct 4 13:40:16 2006 From: P.PRAAMSTRA at BHAM.AC.UK (Peter Praamstra) Date: Wed, 4 Oct 2006 12:40:16 +0100 Subject: clusterrandanalysis In-Reply-To: Message-ID: hoi Robert, dat doet de truc natuurlijk. groeten, peter On 4 Oct 2006 at 10:44, Robert Oostenveld wrote: > Hi Peter > > On 3 Oct 2006, at 14:13, Peter Praamstra wrote: > > Implementing the suggestion to shift the time > > axis revealed a glitch in besa2fieldtrip that I should have > spotted > > earlier. It > > doesn't convert ms in s. As a result, cfg.latency or cfg.toilim > > statements > > using seconds as time unit don't work properly. > > > > This peculiarity concerns BESA TFR data; I don't know about other > BESA > > data formats. > > There are many variations of the BESA format, which makes them > difficult to support. Every couple of months, someone will contact > me > with yet another BESA file that is not fully supported :-( > > Fieldtrip always works with seconds and not with ms, hence it should > be fixed. I expect the problem to be on line 141 of besa2fieldtrip, > which now reads > data = []; > data.time = Time; > data.freq = Frequency; > and probably this should read > data = []; > data.time = Time * 1e-3; % convert to seconds > data.freq = Frequency; > > Can you confirm this? > > best, > Robert ###################################### Peter Praamstra, MD, PhD Reader in Cognitive Neurophysiology Honorary Consultant Neurology Behavioural Brain Sciences Centre School of Psychology, University of Birmingham Birmingham, B15 2TT tel. 0121 414 7211 fax 0121 414 4897 From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 14:36:09 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 14:36:09 +0200 Subject: MEG realign In-Reply-To: <45238F08.3060006@UKAachen.de> Message-ID: Hi Mikhail On 4 Oct 2006, at 12:38, Mikhail Zvyagintsev wrote: > I am using 4 D Neuroimaging mashine (BTi), and, therefore, I had to > change the routine a bit - at least change settings, concerning the > sensors name. Yes, I can imagine that, since it is using some pre-defined sensor names to construct the averaged template helmet position. Could you send me the change (private mail), then I will include it in FT. > (I actually attached a picture regarding sensors' position's > difference derived from Matlab, but probably it is not so easy to > recognize what is what on this picture - points are sensors and > different colors - positions in different sessions, the view is > from front). There is an option in MEGREALIGN that you can use for plotting something similar (cfg.plot3d=yes) > And later in this routine I use the approach based on calculation > of brain surface from headshape. As a headshape we use here points > from bridge (of nose) to nape (of the neck). You should ensure that the points, when shifted inwards with cfg.inwardshift (units are the same as your units of the volume an dgradiometer system, in case of CTF that is in cm), that they more or less ly in the gray matter, i.e. approx 0.5-1cm inward from the brain surafce. If your head surface includes ears and a nose, you will have weird effects. You could change teh plot3d option in such a way that the dipole grid positions are also plotted (you should plot the pos variable). > I get 644 dipoles from it 'prunedinv' subfunction gives me 'pruning > 49 out of 148 singular values' (so, we use 148 channels mashine). That seems a rather large reduction. The issue here is that you need 148 sources (i.e. a dipole onsists of an x, y and z source, and in case of a spherical headmodel the radial component will be zero) to be able to completely describe the data. But if there is noise (a small and spatially shart amplitude contribution), then that noise will also project to teh sourcespace. Hence, the noise will also project outward again to the new sensor array. By "pruning" the leadfield matrix, the N spatially strongest components are selected, where a component is then not a dipole any more, but a combination of dipoles. I.e. a SVD is done on the leadfield, and the smallest contributing components are removed. By default all source components smaller than 0.001 times the largest component will be removed (note that this is independent of data). In your case there are 49 of the 148 removed. You have 644 sources, each with 3 orientations -> those are compressed into 148-49=99 spatial topographies. > After calculation of realign matrix and applying it for 'realigning > trial' the residual variance (RV) which I get for one trial is > arround 30%. I have a feelling that it is rather to much, or might > be it's normal, becouse difference between sensors is rather big one. > Because in case 'mean distance towards template gradiometers' was > 6.48 mm - residual variances were arround 5-6%. > So, > distance RV > 6.48 mm 5-6% > 25.45 mm ~30%. > My question is - is such RV difference correspondent to the > difference distance I have and how many points should be like a > 'control value' for 'prunedinv' routine? The RV is not the incorrectness of the projection, but the difference between the original and realigned data (i.e. before and after). If it were zero, then realigning would not have an effect. So "RV" is not a good name, it is "before-after difference". A large helmet shift probably fits with a large before-after difference. Various differences can be shown, i.e. "original->brain->original" and "original->brain->template", and also "original->brain->template- >brain->original". I hope that these numbers are now more clear. I cannot tell you what a good value is for the cfg.pruneration option. You can set it between 0 (no pruning) and 1 (all except the largest component will be pruned/removed). Perhaps other people on the FT list can tell you about their experience with this setting. best regards, Robert From litvak at TX.TECHNION.AC.IL Wed Oct 4 15:15:41 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Wed, 4 Oct 2006 14:15:41 +0100 Subject: Signal2 format import In-Reply-To: <2093A833-C89D-4DB0-9D53-FB43A9DAF4A2@fcdonders.ru.nl> Message-ID: Hi Robert and everyone, I am starting a new project and I'd like to import to FT data in Signal (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab library that can read the files but I wonder whether anybody has implemented the conversion all the way to FT or at least close to it. Maybe Biosig can read it (I haven't tried yet)? Any thoughts would be appreciated. Thanks, Vladimir From litvak at TX.TECHNION.AC.IL Wed Oct 4 18:11:08 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Wed, 4 Oct 2006 17:11:08 +0100 Subject: Signal2 format import In-Reply-To: <001901c6e7b7$3125cc70$ec463ec1@sobell.ion.ucl.ac.uk> Message-ID: A correction to my previous post. The files come with extension *.SMR and not *.CED. Vladimir -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Vladimir Litvak Sent: Wednesday, October 04, 2006 2:16 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: [FIELDTRIP] Signal2 format import Hi Robert and everyone, I am starting a new project and I'd like to import to FT data in Signal (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab library that can read the files but I wonder whether anybody has implemented the conversion all the way to FT or at least close to it. Maybe Biosig can read it (I haven't tried yet)? Any thoughts would be appreciated. Thanks, Vladimir From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 18:19:38 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 18:19:38 +0200 Subject: Signal2 format import In-Reply-To: <001901c6e7b7$3125cc70$ec463ec1@sobell.ion.ucl.ac.uk> Message-ID: Hi Vladimir, On 4 Oct 2006, at 15:15, Vladimir Litvak wrote: > I am starting a new project and I'd like to import to FT data in > Signal > (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab > library that can read the files but I wonder whether anybody has > implemented > the conversion all the way to FT or at least close to it. Maybe > Biosig can > read it (I haven't tried yet)? Any thoughts would be appreciated. Gijs van Elswijk contributed code to FT for reading continuous channels (are required to all have the same sampling rate) from a system manufactured by "Cambridge Electronic Design" (CED), and the documentation that I got specifies that the files are from the 'Spike2 SON filing system'. In the FT private/filetype function, those are referred to as being type 'ced_son'. However, those files are assumed to have the extension *.smr. I am not sure whether those are the same files, but it sounds like it could be related. Gijs' code is basically the private/read_ced_son.m file, which uses the Neuroshare library (see http://neuroshare.sourceforge.net). There are matlab bindings to the Neuroshare library, i.e. system specific mex files that you have to add to your Matlab path. I hope this helps. If not, then I also know another library for reading SON2 files. But then, I am not yet sure whether that really corresponds to the dataformat that you now have. Robert From litvak at TX.TECHNION.AC.IL Wed Oct 4 20:21:39 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Wed, 4 Oct 2006 19:21:39 +0100 Subject: Signal2 format import In-Reply-To: <3202C65B-3F02-40BC-8403-A52F470BB6A8@fcdonders.ru.nl> Message-ID: Thanks a lot. It works perfectly (at least from the first glance). Best, Vladimir -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Robert Oostenveld Sent: Wednesday, October 04, 2006 5:20 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: Re: [FIELDTRIP] Signal2 format import Hi Vladimir, On 4 Oct 2006, at 15:15, Vladimir Litvak wrote: > I am starting a new project and I'd like to import to FT data in > Signal > (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab > library that can read the files but I wonder whether anybody has > implemented > the conversion all the way to FT or at least close to it. Maybe > Biosig can > read it (I haven't tried yet)? Any thoughts would be appreciated. Gijs van Elswijk contributed code to FT for reading continuous channels (are required to all have the same sampling rate) from a system manufactured by "Cambridge Electronic Design" (CED), and the documentation that I got specifies that the files are from the 'Spike2 SON filing system'. In the FT private/filetype function, those are referred to as being type 'ced_son'. However, those files are assumed to have the extension *.smr. I am not sure whether those are the same files, but it sounds like it could be related. Gijs' code is basically the private/read_ced_son.m file, which uses the Neuroshare library (see http://neuroshare.sourceforge.net). There are matlab bindings to the Neuroshare library, i.e. system specific mex files that you have to add to your Matlab path. I hope this helps. If not, then I also know another library for reading SON2 files. But then, I am not yet sure whether that really corresponds to the dataformat that you now have. Robert From G.vanElswijk at NEURO.UMCN.NL Wed Oct 4 20:38:24 2006 From: G.vanElswijk at NEURO.UMCN.NL (Gijs van Elswijk) Date: Wed, 4 Oct 2006 20:38:24 +0200 Subject: Signal2 format import Message-ID: Hi Vladimir and Robert, The "read_ced_son" code has not been tested with non-continuous Spike2 files. However, recently a colleague of mine has used the Fieldtrip routines to read his non-continuous Spike2 data. It seems to work fine. I have not tested any Signal data files (which are always non-continuous as far as I know). I believe Signal also uses the "CED SON filing system", which means that those files should be readable with the current FT routines. I was planning to add a few small updates to the current code at some point. If necessary, I could combine it with testing/implementing the support for non-continuous Signal/Spike data. Gijs -----Original Message----- From: FieldTrip discussion list on behalf of Vladimir Litvak Sent: Wed 10/4/2006 8:21 PM To: FIELDTRIP at NIC.SURFNET.NL Cc: Subject: Re: [FIELDTRIP] Signal2 format import Thanks a lot. It works perfectly (at least from the first glance). Best, Vladimir -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Robert Oostenveld Sent: Wednesday, October 04, 2006 5:20 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: Re: [FIELDTRIP] Signal2 format import Hi Vladimir, On 4 Oct 2006, at 15:15, Vladimir Litvak wrote: > I am starting a new project and I'd like to import to FT data in > Signal > (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab > library that can read the files but I wonder whether anybody has > implemented > the conversion all the way to FT or at least close to it. Maybe > Biosig can > read it (I haven't tried yet)? Any thoughts would be appreciated. Gijs van Elswijk contributed code to FT for reading continuous channels (are required to all have the same sampling rate) from a system manufactured by "Cambridge Electronic Design" (CED), and the documentation that I got specifies that the files are from the 'Spike2 SON filing system'. In the FT private/filetype function, those are referred to as being type 'ced_son'. However, those files are assumed to have the extension *.smr. I am not sure whether those are the same files, but it sounds like it could be related. Gijs' code is basically the private/read_ced_son.m file, which uses the Neuroshare library (see http://neuroshare.sourceforge.net). There are matlab bindings to the Neuroshare library, i.e. system specific mex files that you have to add to your Matlab path. I hope this helps. If not, then I also know another library for reading SON2 files. But then, I am not yet sure whether that really corresponds to the dataformat that you now have. Robert From r.oostenveld at FCDONDERS.RU.NL Thu Oct 5 11:05:42 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 5 Oct 2006 11:05:42 +0200 Subject: Signal2 format import In-Reply-To: <87F49DED9808BB438F539227CB809111179417@exchange_smtp.umcn.nl> Message-ID: Hi Gijs and Vladimir, On 4 Oct 2006, at 20:38, Gijs van Elswijk wrote: > The "read_ced_son" code has not been tested with non-continuous > Spike2 files. However, recently a colleague of mine has used the > Fieldtrip routines to read his non-continuous Spike2 data. It seems > to work fine. I have not tested any Signal data files (which are > always non-continuous as far as I know). The preprocessing function of Fieldtrip always assumes that data is continuous, i.e. all data samples are numbered as if they were continuous. The definetrial function has to take care of trial boundaries, and definetrial (or your own trialfun) should ensure that the datasegments of interest do not cross trial boundaries. However, if you use filter padding in preprocessing, then your segments of interest (i.e. the "trl" matrix from definetrial) are extended on both sides, and then it may happen that the padded segment extends over a trial boun. To catch those situations, the read_fcdc_data function will check whether the requested data extends over trial boundaries in a discontinuous file (and give an error if it does). So by default in the case of real non-continuous data, the read_fcdc_data function should catch situations where it tries to read data that crosses a trial boundary. However, that will only work if the header (obtained from read_fcdc_header) correctly specifies it that the data is trial based. You may want to check that in the read_ced_con importer. In some cases, trial-based data can also be interpreted as continuous, e.g. when you acquire CTF data in pseudo-continuous mode. The file then contains trials, but there are no holes between them. In that case, you should use cfg.datatype='continuous' in preprocessing (and in the artifact detection functions). That option tells the read_fcdc_data function that it should NOT do the trial boundary check. best Robert From roel.willems at FCDONDERS.RU.NL Fri Oct 6 11:03:50 2006 From: roel.willems at FCDONDERS.RU.NL (Roel Willems) Date: Fri, 6 Oct 2006 11:03:50 +0200 Subject: two way anova Message-ID: Dear all, I've got a quick and easy question: Is there a straightforward way of doing a 2 way anova (e.g. with factors regions of interest (grouped electrodes) and conditions) of freq data using the new statistics_stats function? All the best, Roel -- Roel Willems, PhD student Radboud University Nijmegen F.C. Donders Centre for Cognitive Neuroimaging Kapittelweg 29 6525 EK Nijmegen tel. +31243668065 www.fcdonders.ru.nl From r.oostenveld at FCDONDERS.RU.NL Fri Oct 6 15:53:53 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 6 Oct 2006 15:53:53 +0200 Subject: two way anova In-Reply-To: <45261BF6.2070002@fcdonders.ru.nl> Message-ID: Hi Roel, On 6 Oct 2006, at 11:03, Roel Willems wrote: > Is there a straightforward way of doing a 2 way anova (e.g. with > factors regions of interest (grouped electrodes) and conditions) of > freq data using the new statistics_stats function? No, the statistics_montecarlo, analytic annd stats function all implement a massive univariate statistic (with multiple comparison correction). So ROIs (channels) cannot be used as factor. You can use the matlab anova2 or anovaN function on the command line. However, you should be aware that power spectra do not always mix linearly, depending on what the underlying assumption is over the generators. Hence you cannot always test for interactions (main effects is not a problem). There are workarounds, we could discuss that next week. best Robert From Brian.Roach at YALE.EDU Sat Oct 7 00:04:01 2006 From: Brian.Roach at YALE.EDU (Brian Roach) Date: Fri, 6 Oct 2006 18:04:01 -0400 Subject: freqanalysis_wltconvol.m In-Reply-To: Message-ID: Markus, I appreciate this answer, but I would like to clarify some of your points to be sure I have completely absorbed them. Here is my example: 1000Hz sample rate for the acquired data 4000ms epochs centered on an event (-2000ms before the event to 1999 after the event) cfg = output: 'pow' method: 'wltconvol' foi: [1x60 double] width: 6 gwidth: 3 toi: [1x1000 double] where foi is 1 to 60Hz (in 1Hz steps), and toi is -.5s to .5s (in 1ms steps) I like that 1Hz is not plotted (NaN) values, since you cannot get 6 cycles of 1Hz data in my 4s epoch size. Having run this, I am still uncertain about how gwidth influences the data. Does a smaller gwidth just widen the bell curve of the gaussian envelope? Is there a trend, such as the higher the gwidth, the better the time resolution (because the wavelet has a sharper rise and fall time)? In my case, does sf = 2Hz/6Hz or 1/3Hz? I don't think I have these values right, and since they influence temporal domain and spectral bandwidth, it is important that I know what is right. It seems like if my interpretation of your e-mail is correct, then each frequency bin consists of that frequency +/-.167 or (1/6) Hz. In my example above, my 2Hz value would then consist of data from 1.8333 to 2.1667Hz. This would mean that there are gaps in the spectral data and a smaller number of cycles or smaller width would lead to larger bandwidth (i.e. decreasing frequency resolution). What do you think? Also, does fieldtrip have a function that gives "phase locking factor" or inter-trial coherence (ITC)? Thank you very much for your help. Brian At 03:59 AM 10/2/2006, Markus Siegel wrote: >Dear Brian, > >cfg.width determines in cycles the width of the Morlet-wavelet as the >standard deviation of the underlying gaussian (often termed "q"). One >can either use a fixed q for all frequencies by giving only one >number in cfg.width, or one can use a different q for each frequency >of interest with a vector in cfg.width of the same length as cfg.foi. >"help freqanalysis_wltconvol" gives you the relationship between >cfg.width (width) , the frequency of interest (f0) and the standard- >deviation (resolution) of the wavelet-transform in the temporal (st) >and spectral (sf) domain: > >The standard deviation in the frequency domain (sf) at frequency f0 is >defined as: sf = f0/width >The standard deviation in the temporal domain (st) at frequency f0 is >defined as: st = width/f0 = 1/sf > >The spectral bandwidth (in standard deviations, Hz) of the time- frequency >transform can thus be computed as: >bw = cfg.foi ./ cfg.width; > >The parameter cfg.gwidth determines the length of the wavelet-kernel >used in standard deviations of the underlying gaussian. In other >words, it specifies over how many standard deviations the gaussian is >estimated for the morlet-wavelet in both directions. This does in >principle not influence the spectro-temporal resolution of the >transform, but determines its precision because the gaussian is non- zero >at the edges. Therefore, small values (e.g. <2) lead to edge >effects in the transform. The full length of the 'longest' wavelet at >the lowest frequency cfg.foi(1) is thus computed as: > >2 * cfg.gwidth (cfg.width(1) ./ cfg.foi(1)) > >In freqanalysis_wltconvol, the wavelet transform is implemented by >multiplication in the frequency domain which is computationally more >efficient than convolution in the temporal domain. However, >technically the transform is well described as a convolution of the >time-series with a complex Morlet-wavelet (complex sinusoid with a >gaussian envelope) as e.g. provided in Tallon-Baudry et al., J >Neurosci 1997. > >Best, >Markus > >Am 29.09.2006 um 18:52 schrieb Brian Roach: > > >>Dear FieldTrip users, >> >>I have been playing with the freqanalysis_wltconvol function in >>hopes of using the morlet wavelet time frequency analysis on some >>eeg data. I have been able to get it running, and I find that it >>works very quickly, which is great. However, I am hoping some >>users or F.T. programmers can explain some of the function inputs >>and processing. The cfg example is as follows: >> >>% cfg.method = 'wltconvol'; >>% cfg.foi = 1:1:100; >>% cfg.width = 7; >>% or >>% cfg.width = linspace(5,10,length(cfg.foi)); >>% cfg.toi = 0:0.1:2; >>% cfg.gwidth = 3; >> >>I believe that the cfg.width specifies the number of wave cycles >>used in each frequency's wavelet analysis (so at 2Hz, 7 cycles >>spans 3500ms of data, right?). Maybe this is not correct, because >>I do not seem to get the frequencies as low as I would expect given >>my data epoch length. Perhaps this has to do with the cfg.gwidth >>parameter, which I do not think I completely understand - what is it? >> >>Also, we do not have the matlab wavelet toolbox, and it appears >>that it is not required, but how is the morlet wavelet >>implemented? As I look through the code I see calls to fft, ifft, >>and fftshift, but I wonder how I can give a good technical >>description of this process if I find results in a larger data set. >> >>Finally, is there a function or a way to compute the frequency >>bandwidth based on the cfg inputs, or is there a fix frequency >>bandwith for each foi here? I am sure I am confusing a number of >>things here, so no response is too simple. >> >>Thanks for any advice, please let me know if there is more >>information I can give or if I can clarify my questions. >> >>Brian > From Jan.Schoffelen at FCDONDERS.RU.NL Mon Oct 9 08:31:58 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Mon, 9 Oct 2006 08:31:58 +0200 Subject: Fieldtrip question from Piers C In-Reply-To: <4523.144.32.162.118.1160130197.squirrel@psycix.york.ac.uk> Message-ID: Dear Piers, Since I am not a big wavelet-analysis expert, I forward this reply to the fieldtrip-mailinglist. Recently there has been a thread concerning this type of analysis. (To subscribe, please have a look at: http://www.ru.nl/fcdonders/fieldtrip/, and follow the links to the discussion list; there's a thread on freqanalysis_wltconvol) I'd like to give you a global idea of what's going on with your analysis, for the details I'd like to refer to Markus' and Brian's discussion. The NaNs in your spectrogram are the consequence of your configuration-settings, and your data length. Only at frequencies and time-points where the wavelet-kernel completely covers your data, an estimate is returned. You could play around a bit with your cfg.width, and cfg.gwidth parameters to change this. Yours, Jan-Mathijs -----Original Message----- From: p.cornelissen at psych.york.ac.uk [mailto:p.cornelissen at psych.york.ac.uk] Sent: Friday, October 06, 2006 12:23 PM To: Jan Mathijs Schoffelen Subject: RE: Fieldtrip question from Piers C Dear Jan-Mathijs Thanks for this advice. It turns out that there is an easy solution in the form of a commandline programme called newDS (this is either a CTF thing, or something written by the team at Aston) which allows one to incorporate a virtual electrode dataset (defined by a SAM weights file) into a DS file. Then, when reading into Fieldtrip, you have to include the 'V0' in the line: cfg.channel = {'MEG' 'STIM' 'V0'}; However, I have a new question. I ran the following wavelet analysis on a virtual electrode channel dataset: cfg1 = []; cfg1.output = 'pow'; cfg1.sgn = 'MEG'; cfg1.method = 'wltconvol'; cfg1.channel = 'V0'; cfg1.width = 5; % Width of wavelet cfg1.gwidth = 5; cfg1.foi = 1:1:50; cfg1.toi = -0.2:0.01:0.7; WVLT = freqanalysis(cfg1, raw); Created a suingle plot as follows. cfg2 = []; cfg2.baseline = [-0.2 0.0]; cfg2.baselinetype = 'relative'; %cfg2.baseline = 'no'; %cfg2.baselinetype = 'absolute'; cfg2.zlim = 'maxmin'; cfg2.xlim = [-0.2 0.7]; cfg2.ylim = [1 35]; cfg2.channel = 'V0'; singleplotTFR(cfg2, WVLT); ... and obtained the result that is attached as a PNG file to this email. It seems as if the plot has been thresholded/masked in a way to exclude values that are (probably) poorly estimated - or something like that. So, please can you advise what rules govern this exclusion/masking, and how they can either be switched off, or the analysis/data collection carried out in such a way that they are not invoked. Thanks very much again Piers > Dear Piers, > > First of all, I took the liberty to include as a CC to this mail the > FieldTrip discussion list. It might be that some of its members could > positively contribute to answering your questions. You can subscribe to > this > list on the fieldtrip-website. > > Anyway, currently there is no support for reading in SAM weights files > into > fieldtrip. The most important reason for us not having implemented it, is > that we do our source estimation in fieldtrip directly. Perhaps anyone > already has an implementation to directly read in your SAM weights into > matlab (hence the cc to the discussion list). As soon as those weights are > available, it is pretty straightforward to create virtual channel data and > do the subsequent analysis within fieldtrip. > Otherwise a reading routine for SAM weights would be a valuable > contribution > to the code. > > Another approach would be to use fieldtrip's beamforming algorithm to > create > your virtual channels. The 'lcmv'-algorithm is not all too different from > SAM, so you could try this on your specified voxels of interest. > > There is a tutorial on the frequency-domain beamformer on the web-site. > The > time-domain beamformer needs a slightly different configuration and > input-data. > > 1 you should use timelockanalysis to compute the covariance of your > bandpass-filtered data. > 2 then you can call sourceanalysis, with the output of timelockanalysis as > an input, in combination with a configuration-structure. > > Key-elements of this configuration would be: > cfg.method = 'lcmv'; > cfg.pos = Nx3 matrix with x,y,z coordinates of your virtual channels > cfg.reducerank = 2; (necessary for comparability with SAM, and also to > give > reasonable results in the first place) > cfg.hdmfile = .hdm file specifying the forward model used > > ...and I guess some other stuff as well. > > Yours, > > Jan-Mathijs > > > > -----Original Message----- > From: p.cornelissen at psych.york.ac.uk > [mailto:p.cornelissen at psych.york.ac.uk] > > Sent: Friday, September 15, 2006 2:54 PM > To: Jan.Schoffelen at fcdonders.ru.nl > Subject: Fieldtrip ? from Piers C > > > Dear Fieldtrip team, > > First - thanks for your excellent software! > > I hope its OK for me to ask you a Fieldtrip question. > > We have data from an experiment using Aston (UK) universitie's old 151 > channel CTF system, and we have used the CTF tools to extract a set of > virtual electrodes, selected on the basis of a robust group SAM analysis. > What we would really like to do is to use our SAM weights files for these > virtual electrodes, to define specific channels in Fieldtrip so that we > can create and compare time*frequency plots from the virtual electrodes in > Fieldtrip. > > Any advice on how to do this (preferably by way of example code)would be > deeply appreciated > > Regards > > Piers Cornelissen > > > > > > > > > > > > > > From m.siegel at UKE.UNI-HAMBURG.DE Mon Oct 9 11:05:27 2006 From: m.siegel at UKE.UNI-HAMBURG.DE (Markus Siegel) Date: Mon, 9 Oct 2006 11:05:27 +0200 Subject: freqanalysis_wltconvol.m In-Reply-To: <6.1.2.0.2.20061006142513.01c9ecf0@email.med.yale.edu> Message-ID: Hi Brian, On Oct 7, 2006, at 12:04 AM, Brian Roach wrote: > Here is my example: > 1000Hz sample rate for the acquired data > 4000ms epochs centered on an event (-2000ms before the event to > 1999 after the event) > > cfg = > > output: 'pow' > method: 'wltconvol' > foi: [1x60 double] > width: 6 > gwidth: 3 > toi: [1x1000 double] > > where foi is 1 to 60Hz (in 1Hz steps), and toi is -.5s to .5s (in > 1ms steps) > > I like that 1Hz is not plotted (NaN) values, since you cannot get 6 > cycles of 1Hz data in my 4s epoch size. Having run this, I am > still uncertain about how gwidth influences the data. Does a > smaller gwidth just widen the bell curve of the gaussian envelope? > Is there a trend, such as the higher the gwidth, the better the > time resolution (because the wavelet has a sharper rise and fall > time)? cfg.gwidth does not influence the width of the gaussian envelope and thus does not have an effect on the temporal or spectral resolution. The cfg.gwidth parameter determines the length of the morlet-wavelet but not its shape. The gaussian envelope implies that the wavelet tails converge towards zero but are not really zero at the edges. Thus one has to decide where to crop the wavelet-kernel. The gwidth parameter determines the cropped length in standard deviations of the gaussian envelope. For cfg.gwidth = 3 the morlet-wavelet is thus estimated for the central +/- 3 standard deviations of the gaussian envelope. Hence, smaller gwidth parameter lead to edges of the wavelets that become more "non-zero" which lead to stronger edge effects and more noisy picture of your time-frequency transform. Run your analysis with the above parameters but cfg.gwidth = 1. If you compare the output to that of cfg.gwidth = 3 this effect should become clear. > In my case, does sf = 2Hz/6Hz or 1/3Hz? I don't think I have these > values right, and since they influence temporal domain and spectral > bandwidth, it is important that I know what is right. It seems > like if my interpretation of your e-mail is correct, then each > frequency bin consists of that frequency +/-.167 or (1/6) Hz. In > my example above, my 2Hz value would then consist of data from > 1.8333 to 2.1667Hz. This would mean that there are gaps in the > spectral data and a smaller number of cycles or smaller width would > lead to larger bandwidth (i.e. decreasing frequency resolution). > What do you think? The spectral bandwidth of your time-frequency tranform is not constant but a function of frequency. For your example, the spectral bandwidth (in standard deviations, Hz) is computed as: bandwidth = cfg.foi ./ cfg.width; For a constant cfg.width, the spectral bandwidth increases linearly with the frequency of interest. While at 18 Hz you have a spectral bandwidth of 3 Hz, the bandwidth at 60 Hz is 10 Hz. > Also, does fieldtrip have a function that gives "phase locking > factor" or inter-trial coherence (ITC)? Not that I know. However, you could compute ITC yourself based on the complex output from freqanalysis_mtmconvol run with cfg.output = 'fourier'. Best, Markus From jaredvs at GMAIL.COM Tue Oct 10 22:38:53 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Tue, 10 Oct 2006 22:38:53 +0200 Subject: Incorrect coordinates? Message-ID: Hi there, I've been analyzing the output of BESA's multiple source beamformer (MEG data) using Fieldtrip, and it appears that there is a problem with the coordinate system. The results of volumewrite, when overlayed with the spm T1.img, appear to be substantially outside of the brain, and in oddly shaped patterns that suggest an error in assigning statical values to the correct coordinates. The analysis protocol used was as follows (we only had MRI's for 2 subjects, one of these was used for all subject who did not have MRI's--for convenience I simply use one mri for all subjects in the example below): mri=read_fcdc_mri('mri.img'); fdir=pwd; files=dir([fdir filesep '*.dat']); %these are the BESA .dat files sinterp_cfg.interpmethod='cubic'; sinterp_cfg.sourceunits='mm'; norm_cfg.template=which('T1.mnc'); norm_cfg.parameter='all'; norm_cfg.coordinates='spm'; norm_cfg.name='high_alpha_beamformer_normed'; for k=1:length(files) src(k)=besa2fieldtrip([fdir filesep files(k).name]); interp(k)=sourceinterpolate(sinterp_cfg,src(k),mri); volume(k)=volumenormalise(norm_cfg,interp(k)); end grav_cfg.parameter='pow'; grav_cfg.keepindividual='yes'; grandavg=sourcegrandaverage(grav_cfg,volume(1),volume(2),volume(3),volume (4),volume(5),volume(6),volume(7),volume(8),volume(9),volume(10),volume (11),volume(12)); stat_cfg.parameter='pow'; stat_cfg.method='parametric'; stat_cfg.statistic = 'zero-baseline'; stat_cfg.bonferoni = 'no'; stat_cfg.threshold=0.01; stat=sourcestatistics_parametric(stat_cfg,grandavg); write_cfg.parameter='tscore'; write_cfg.filename='alpha'; write_cfg.filetype='spm'; write_cfg.coordinates='spm'; write_cfg.scaling='no'; volumewrite(write_cfg,stat) When I overlay the .img on the MNI T1.img using MRICro, there's a lot of data outside of the brain. Any suggestions as to where something may have gone wrong would be greatly appreciated. I would happily provide the resulting alpha.img and alpha.hdr, though as the .img is 55MB I won't attach it to this message. Thanks very much, Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 From r.oostenveld at FCDONDERS.RU.NL Wed Oct 11 09:36:07 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 11 Oct 2006 09:36:07 +0200 Subject: Incorrect coordinates? In-Reply-To: Message-ID: Hi Jared, On 10 Oct 2006, at 22:38, Jared Van Snellenberg wrote: > I've been analyzing the output of BESA's multiple source beamformer > (MEG > data) using Fieldtrip, and it appears that there is a problem with the > coordinate system. The results of volumewrite, when overlayed with > the spm > T1.img, appear to be substantially outside of the brain, and in oddly > shaped patterns that suggest an error in assigning statical values > to the > correct coordinates. I suspect a misalignment between your functional and anatomical data. > mri=read_fcdc_mri('mri.img'); read_fcdc_mri does not do automatic alignment, but just returns the data with the coordinate system as defined in the mri file. Do you know what the coordinate system is to which the anatomical MRI is aligned? I.e. where is the origin [0,0,0] in anatomical terms? > for k=1:length(files) > src(k)=besa2fieldtrip([fdir filesep files(k).name]); > interp(k)=sourceinterpolate(sinterp_cfg,src(k),mri); > volume(k)=volumenormalise(norm_cfg,interp(k)); > end And what is the coorrdinate system in which the functional source data is described? I.e. at which location in the head would a dipole at the coordinate [0 0 0] be? For sourceinterpolate the two input arguments (functional + anatomical data) should be defined w.r.t. the same coordinate system. I suggest that you use sourceplot for debugging, e.g. something like cfg =[] cfg.funparameyter = 'pow' % don't know how the functional data in src is called, probably 'pow' cfg.location = 'interactive' % or try [0 0 0] sourceplot(cfg, src(1)); % there is no anatomy, only functional data and cfg =[] cfg.funparameyter = [] % no functional data, only anatomy cfg.location = 'interactive' % or try [0 0 0] sourceplot(cfg, mri); that should give you both volumes (in seperate windows) and you can compare whether they seem to be aligned. You could use the volumerealign(*) function for manual realignment of the anatomical MRI. Or you can use MRIcro. Also have a look at http://www2.ru.nl/fcdonders/fieldtrip/doku.php? id=fieldtrip:documentation:frequently_asked_questions#how_are_the_differ ent_head_and_mri_coordinate_systems_defined I hope this helps. Robert *) that is a completely new function that was added yesterdays to fieldtrip, hence you should fetch the latest version from ftp From jaredvs at GMAIL.COM Wed Oct 11 19:16:47 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Wed, 11 Oct 2006 13:16:47 -0400 Subject: Incorrect coordinates? In-Reply-To: <901A6BEF-A31F-41ED-8311-BA17061BED47@fcdonders.ru.nl> Message-ID: Hi Robert, Thanks very much, it looks like you're right. While plotting the src data just came up with an empty image, BESA is supposed to output coordinates according to the Talairach atlas, so [0 0 0] should be on the anterior commisure. Plotting the structural MRI shows that [0 0 0] is clearly *not*on the AC, so it needs to be realigned. I'll try volumerealign now. -Jared On 10/11/06, Robert Oostenveld wrote: > > Hi Jared, > > On 10 Oct 2006, at 22:38, Jared Van Snellenberg wrote: > > I've been analyzing the output of BESA's multiple source beamformer > > (MEG > > data) using Fieldtrip, and it appears that there is a problem with the > > coordinate system. The results of volumewrite, when overlayed with > > the spm > > T1.img, appear to be substantially outside of the brain, and in oddly > > shaped patterns that suggest an error in assigning statical values > > to the > > correct coordinates. > > I suspect a misalignment between your functional and anatomical data. > > > mri=read_fcdc_mri('mri.img'); > > read_fcdc_mri does not do automatic alignment, but just returns the > data with the coordinate system as defined in the mri file. > > Do you know what the coordinate system is to which the anatomical MRI > is aligned? I.e. where is the origin [0,0,0] in anatomical terms? > > > for k=1:length(files) > > src(k)=besa2fieldtrip([fdir filesep files(k).name]); > > interp(k)=sourceinterpolate(sinterp_cfg,src(k),mri); > > volume(k)=volumenormalise(norm_cfg,interp(k)); > > end > > And what is the coorrdinate system in which the functional source > data is described? I.e. at which location in the head would a dipole > at the coordinate [0 0 0] be? > > For sourceinterpolate the two input arguments (functional + > anatomical data) should be defined w.r.t. the same coordinate system. > > I suggest that you use sourceplot for debugging, e.g. something like > > cfg =[] > cfg.funparameyter = 'pow' % don't know how the functional > data in src is called, probably 'pow' > cfg.location = 'interactive' % or try [0 0 0] > sourceplot(cfg, src(1)); % there is no anatomy, only > functional data > > and > > cfg =[] > cfg.funparameyter = [] % no functional data, only anatomy > cfg.location = 'interactive' % or try [0 0 0] > sourceplot(cfg, mri); > > that should give you both volumes (in seperate windows) and you can > compare whether they seem to be aligned. You could use the > volumerealign(*) function for manual realignment of the anatomical > MRI. Or you can use MRIcro. Also have a look at > http://www2.ru.nl/fcdonders/fieldtrip/doku.php? > id=fieldtrip:documentation:frequently_asked_questions#how_are_the_differ > ent_head_and_mri_coordinate_systems_defined > > I hope this helps. > Robert > > *) that is a completely new function that was added yesterdays to > fieldtrip, hence you should fetch the latest version from ftp > -- Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.oostenveld at FCDONDERS.RU.NL Thu Oct 12 09:21:08 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 12 Oct 2006 09:21:08 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610111016y5bae7549o382682194f7e034b@mail.gmail.com> Message-ID: On 11 Oct 2006, at 19:16, Jared Van Snellenberg wrote: > Thanks very much, it looks like you're right. good. > While plotting the src data just came up with an empty image In sourceplot cfg.funparameter should specify the parameter that should be plotted, and that should work without anatomy as well. Looking back at your own cfg in the previous mail, I do think that it should be 'pow'. However, I made a typo in my previous reply (cfg.funparameyter). Robert From marco.buiatti at GMAIL.COM Fri Oct 13 19:03:36 2006 From: marco.buiatti at GMAIL.COM (Marco Buiatti) Date: Fri, 13 Oct 2006 19:03:36 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: <82A11B61-8049-432A-B1CF-43764D723ED3@fcdonders.ru.nl> Message-ID: Dear Robert and Eric (and dear FieldTrippers), thank you for your efficient response on my summer question. I followed your advices and tried to use the function timelockstatistics starting from the canonical comparison of ERPs within subjects but I had some problems. Here I report my attempt to perform cluster randomization analysis on ERPs relative to two conditions (W and PW). For simplicity I took just 2 subjects. I report here all the steps from loading eeglab datasets to computing cluster randomization analysis to be sure that I am following the correct procedure. The problem is ??? Undefined variable "data" or class "data.biol". I used yesterday's FieldTrip version 20061012. Can you help me with this? Thank you in advance, Marco % Loading eeglab datasets EEG50PW_s2 = pop_loadset( '02_ev_hpf0.2_lpf35_ep_soa50PW.set', '/home/Pinserm/people/joachim/analysis/02/'); EEG50W_s2 = pop_loadset( '02_ev_hpf0.2_lpf35_ep_soa50W.set', '/home/Pinserm/people/joachim/analysis/02/'); EEG50PW_s4 = pop_loadset( '04_ev_hpf0.2_lpf35_ep_soa50PW.set', '/home/Pinserm/people/joachim/analysis/04/'); EEG50W_s4 = pop_loadset( '04_ev_hpf0.2_lpf35_ep_soa50W.set', '/home/Pinserm/people/joachim/analysis/04/'); % Transform to FieldTrip format data50PW_s2 = eeglab2fieldtrip( EEG50PW_s2, 'timelockanalysis' ); >> data50PW_s2 data50PW_s2 = label: {129x1 cell} fsample: 250 elec: [1x1 struct] avg: [129x523 single] var: [129x523 single] time: [1x523 double] dimord: 'chan_time' cfg: [1x1 struct] data50W_s2 = eeglab2fieldtrip( EEG50W_s2, 'timelockanalysis' ); data50W_s4 = eeglab2fieldtrip( EEG50W_s4, 'timelockanalysis' ); data50PW_s4 = eeglab2fieldtrip( EEG50PW_s4, 'timelockanalysis' ); % Computing grandaverage for each condition cfg =[]; cfg.keepindividual = 'yes'; GA_50PW = timelockgrandaverage(cfg,data50PW_s2,data50PW_s4); GA_50W = timelockgrandaverage(cfg,data50W_s2,data50W_s4) GA_50W = label: {129x1 cell} fsample: 250 avg: [129x523 double] var: [129x523 double] time: [1x523 double] individual: [2x129x523 double] dimord: 'subj_chan_time' cfg: [1x1 struct] % Loading channel names and positions data = eeglab2fieldtrip(EEG50PW_s2,'chanloc'); GA_50W.elec=data.elec; GA_50PW.elec=data.elec; % Setting cfg for timelockstatistics cfg=[]; cfg.statistic='depsamplesT'; cfg.numrandomization = 500; cfg.alpha=0.05; cfg.clusterstatistics='maxsum'; cfg.clusterthreshold = 'parametric'; cfg.clusteralpha = 0.05; cfg.neighbourdist=4; cfg.neighbours = neighbourselection(cfg,GA_50PW); cfg.latency=[0 0.5]; cfg.method = 'montecarlo'; stat = timelockstatistics(cfg,GA_50W,GA_50PW); Using the electrode configuration from the dataset. there are on average 128.0 neighbours per channel selected 129 channels selected 126 time bins selected 1 frequency bins ??? Undefined variable "data" or class "data.biol". Error in ==> fieldtrip-20061012/private/prepare_design at 92 nrepl=size(data.biol,1); Error in ==> fieldtrip-20061012/private/statistics_wrapper at 212 [cfg] = prepare_design(cfg); Error in ==> timelockstatistics at 50 [stat] = statistics_wrapper(cfg, varargin{:}); On 8/29/06, Robert Oostenveld wrote: > Dear Marco > > On 23 Aug 2006, at 14:53, Eric Maris wrote: > >> 2) Is there a way to compute the null distribution by considering > >> all possible reassignments of the conditions instead of the Monte > >> Carlo approximation - in this case it would be feasible because > >> all possible reassignments should be 2^9, right? > > This is not possible with clusterrandanalysis. However, this is > > possible with one of the new statistics functions in Fieldtrip that > > will replace both clusterrandanalysis and sourcestatistics. The > > function of interest for you is timelockstatistics, and you should > > have a look at the help information for the lower-level function > > statistics_montecarlo (which is called by timelockstatistics). > > However, provided that you use more than 500 draws from the > > permutation distribution, don't expect major changes in the output. > We have an in-house version of fieldtrip, and an external FTP > version. The in-house version is always slightly more advanced than > the external version. Even though the timelockstatistics function was > already included in recent external fieldtrip versions (the daily zip > files) on the Donders FTP server, I just noticed that the underlying > statistics_montecarlo function that Eric is referring to was still > missing from the zip file. I have now also tagged that function (and > some further subfunctions on which it depends) to be released in the > external fieldtrip release. You should be able to use the > timelockstatistics function with both the montecarlo and the complete > permutation (cfg.numrandomization='all') based estimaes for the > cluster statistics. > > I hope it works with the new function, if not then don't hesitate to > contact us. > > Robert > > > > -- Marco Buiatti - Post Doc ************************************************************** Cognitive Neuroimaging Unit - INSERM U562 Service Hospitalier Frederic Joliot, CEA/DRM/DSV 4 Place du general Leclerc, 91401 Orsay cedex, France Telephone: +33 1 69 86 77 65 Fax: +33 1 69 86 78 16 E-mail: marco.buiatti at gmail.com Web: www.unicog.org *************************************************************** From jaredvs at GMAIL.COM Sun Oct 15 00:12:48 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Sat, 14 Oct 2006 18:12:48 -0400 Subject: Incorrect coordinates? In-Reply-To: <8528858E-5C8B-46FA-B12B-461539BA59C3@fcdonders.ru.nl> Message-ID: Hi Robert, I've rerun the analysis with mri's that were reoriented to MNI, and the same problem has emerged. The typo you noted in your last email was indeed the reason for the empty src plot. Plotting src, interp, volume, and grandavg, everything looks ok. The 'pow' parameter values all appear within the brain. The tscore and p values in stat, however, are all messed up. I've attached .bmp's from using sourceplot on grandavg and stat to this email. The quality is poor (matlab's figure window doesn't ever save bmp's very well), but it should demonstrate the problem clearly. Note all the large values outside of the brain. Any comments you have would be greatly appreciated. I've considered just masking out everything that's not in the brain, but I'm not confident that the within-brain values are accurate. Thanks, -Jared On 10/12/06, Robert Oostenveld wrote: > > On 11 Oct 2006, at 19:16, Jared Van Snellenberg wrote: > > Thanks very much, it looks like you're right. > good. > > > While plotting the src data just came up with an empty image > > In sourceplot cfg.funparameter should specify the parameter that > should be plotted, and that should work without anatomy as well. > Looking back at your own cfg in the previous mail, I do think that it > should be 'pow'. However, I made a typo in my previous reply > (cfg.funparameyter). > > Robert > -- Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: grandavg.bmp Type: image/bmp Size: 236278 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: stat.bmp Type: image/bmp Size: 236278 bytes Desc: not available URL: From r.oostenveld at FCDONDERS.RU.NL Mon Oct 16 20:16:37 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 16 Oct 2006 20:16:37 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610141512j638067d0g70039058904b6e6@mail.gmail.com> Message-ID: Hi Jared, On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > I've rerun the analysis with mri's that were reoriented to MNI, and > the same problem has emerged. I would guess that the anatomical MRIs themselves do not influence the coordinate system of the source reconstruction. That would influence the interpolation though. If you do source = besa2fieldtrip(filename1) and mri = read_fcdc_mri(filename) then the source structure is defined using the source.pos field that describes the position of each source. SInce in this case the positions are on a regular 3D grid, there is additional structure in the arrangement of source.pos, which is described using source.xgrid, source.ygrid, source.zgrid. If you do tmp = reshape(source.avg.pow, source.dim) you will get a 3D array with along the first dimension the voxels along the x-axis, etc. The 1..Nth voxels along the xasix have the X coordinates source.xgrid(1)..source.xgrid(N). Similar for the Y and Z coordinates. That allows you to determine the coordinate of each voxel. Since the anatomical MRI is typically of much higher resolution, you can use sourceinterpolate which interpolates the source (or stat) volumes onto the voxel locations that are in the anatomical MRI. I.e. sourceinterpolate upsamples the functional data to the anatomical MRI. Normally you would do sourceinterpolate AFTER calling sourcestatistics, since the source positions in all subjects are all based on the same standard realistic head moidel in BESA and hence the source positions in all subjects are the same (please check whether positions are all the same over subjects/conditions). If you work with MEG or with EEG individual headmodels, the source positions in all subjects are all different, which requires sourceanalysis->sourceinterpolate->volumenormalize as shown in the schema for http://www2.ru.nl/fcdonders/fieldtrip/doku.php? id=fieldtrip:documentation:analysis_protocols#source_reconstruction_for_ multiple_subjects > The typo you noted in your last email was indeed the reason for the > empty src plot. Plotting src, interp, volume, and grandavg, > everything looks ok. The 'pow' parameter values all appear within > the brain. The tscore and p values in stat, however, are all messed > up. I've attached .bmp's from using sourceplot on grandavg and stat > to this email. The quality is poor (matlab's figure window doesn't > ever save bmp's very well), but it should demonstrate the problem > clearly. Note all the large values outside of the brain. In your case you should be able to do besa2fieldtrip -> sourcestatistics, and then the source positions with the statistical data on them should stll be the same as the positions with the original functional data on them. After doing the statistics (or after doing sourcegrandaverage), you can interpolate the functional/ statistical data onto the MRI. But since the statistical data and the functional (beamed power) data are on the same coordinates, there should not be a difference between them. > Any comments you have would be greatly appreciated. I've considered > just masking out everything that's not in the brain, but I'm not > confident that the within-brain values are accurate. Looking at the bitmaps, I cannot see teh anatomy, but I do see a brain-shaped outline with some blobs in them. I cannot recognise the problem from these figures, to me they seem ok. The only problem that I can see is the one that you also mention, and that is for the masking. In the original source data (i.e. output from besa2fieldtrip) there is an source.inside and source.outside field. Those should contain the indices of the voxels (linear indices, so voxel [1 1 1] has index 1 and voxel [2 1 1] has index 2...) of the sources that are inside the brain and outside the brain. Only the inside voxels are considered for sourcestatistics and for sourceinterpolation. However, the problem with BESA data is that it does not describe the inside/outside voxels and therefoer by default all voxels are marked as inside. Perhaps you can determine the inside/ outside voxels manually, e.g. source.inside = find(source.avg.pow(:)>eps); source.outside = find(source.avg.pow(:) Message-ID: Hi Marco Your script looks ok. On 13 Oct 2006, at 19:03, Marco Buiatti wrote: > ??? Undefined variable "data" or class "data.biol". > > Error in ==> fieldtrip-20061012/private/prepare_design at 92 > nrepl=size(data.biol,1); > > Error in ==> fieldtrip-20061012/private/statistics_wrapper at 212 > [cfg] = prepare_design(cfg); > > Error in ==> timelockstatistics at 50 > [stat] = statistics_wrapper(cfg, varargin{:}); Yep, that is a known problem (sorry about that). The function prepare_design is not working properly. I suggest to make a design matrix in cfg.design by hand (similar to, but not completely the same as in SPM). It is not difficult, and it will also make you more clear how it works. Please have a look at https://listserv.surfnet.nl/scripts/wa.exe? A2=ind0607&L=FIELDTRIP&P=R3192&I=-3&X=77C04E25A87526C2B4 or if that URL does not work, then search the fieldtrip discussion list archive for the string "cfg.design". best regards, Robert PS note that you can also use timelockstatistics on the 'componentanalysis' part of the EEGLAB data, in that case you cannot use channel clustering, but you still can use timepoint clustering (so cfg.neighbours should be []). You shoudl only do that if the ICA components in the different EEG datasets are spatially the same (or sufficiently similar, e.g. after clustering over subjects in the new EEGLAB). From r.oostenveld at FCDONDERS.RU.NL Mon Oct 16 20:31:15 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 16 Oct 2006 20:31:15 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610141512j638067d0g70039058904b6e6@mail.gmail.com> Message-ID: On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > The quality is poor (matlab's figure window doesn't ever save bmp's > very well), Just a suggestion: instead of exporting to a BMP bitmap (large files with poor quality) or a JPG (lossy, not suited for line drawings), you can export to a PNG bitmap, which is high quality (lossless+full color) and also compressed (small). Try print -dpng filename.png see "help print" for details Robert From Brian.Roach at YALE.EDU Tue Oct 17 23:44:29 2006 From: Brian.Roach at YALE.EDU (Brian Roach) Date: Tue, 17 Oct 2006 17:44:29 -0400 Subject: freqanalysis_wltconvol.m In-Reply-To: <1A240DDA-7643-4C16-820B-B6C0A69BB5DF@uke.uni-hamburg.de> Message-ID: Markus, Thanks for your reply. I believe I am getting a better handle on this function. Regarding phase-locking factor/ITC, couldn't I try to use the complex data within the freqanalysis_wltconvol to calculate these data in a similar method to that in the Tallon-Baudry et. al. '97 gamma paper? The wltconvol function is so similar to that paper's analysis already, it seems like I would only need to divide the complex data by its absolute value. The paper refers to taking the "modulus of this complex value," where the complex value is: Pi(f,f0) = w(t,f0) X si(t,f0)/ | w(t,f0) X si(t,f0) I read this as the dividing the imaginary, sine wave, portion of the wavelet (representing phase angle) at any given time and frequency by its absolute value. Does modulus have the same functionality/meaning as the C++ mod or matlab rem function? Is there interest in phase-locking values in the FieldTrip user community? I am interested in trying to implement what is described above, but it would be nice to have others see the code and test it to be sure I have calculated phase-locking values correctly. Anyone have any thoughts/feelings about this? Thanks, Brian At 05:05 AM 10/9/2006, you wrote: >Hi Brian, > >On Oct 7, 2006, at 12:04 AM, Brian Roach wrote: > >>Here is my example: >>1000Hz sample rate for the acquired data >>4000ms epochs centered on an event (-2000ms before the event to >>1999 after the event) >> >>cfg = >> >> output: 'pow' >> method: 'wltconvol' >> foi: [1x60 double] >> width: 6 >> gwidth: 3 >> toi: [1x1000 double] >> >>where foi is 1 to 60Hz (in 1Hz steps), and toi is -.5s to .5s (in >>1ms steps) >> >>I like that 1Hz is not plotted (NaN) values, since you cannot get 6 >>cycles of 1Hz data in my 4s epoch size. Having run this, I am >>still uncertain about how gwidth influences the data. Does a >>smaller gwidth just widen the bell curve of the gaussian envelope? >>Is there a trend, such as the higher the gwidth, the better the >>time resolution (because the wavelet has a sharper rise and fall >>time)? > >cfg.gwidth does not influence the width of the gaussian envelope and >thus does not have an effect on the temporal or spectral resolution. >The cfg.gwidth parameter determines the length of the morlet-wavelet >but not its shape. The gaussian envelope implies that the wavelet >tails converge towards zero but are not really zero at the edges. >Thus one has to decide where to crop the wavelet-kernel. The gwidth >parameter determines the cropped length in standard deviations of the >gaussian envelope. For cfg.gwidth = 3 the morlet-wavelet is thus >estimated for the central +/- 3 standard deviations of the gaussian >envelope. Hence, smaller gwidth parameter lead to edges of the >wavelets that become more "non-zero" which lead to stronger edge >effects and more noisy picture of your time-frequency transform. Run >your analysis with the above parameters but cfg.gwidth = 1. If you >compare the output to that of cfg.gwidth = 3 this effect should >become clear. > >>In my case, does sf = 2Hz/6Hz or 1/3Hz? I don't think I have these >>values right, and since they influence temporal domain and spectral >>bandwidth, it is important that I know what is right. It seems >>like if my interpretation of your e-mail is correct, then each >>frequency bin consists of that frequency +/-.167 or (1/6) Hz. In >>my example above, my 2Hz value would then consist of data from >>1.8333 to 2.1667Hz. This would mean that there are gaps in the >>spectral data and a smaller number of cycles or smaller width would >>lead to larger bandwidth (i.e. decreasing frequency resolution). >>What do you think? > >The spectral bandwidth of your time-frequency tranform is not >constant but a function of frequency. For your example, the spectral >bandwidth (in standard deviations, Hz) is computed as: > >bandwidth = cfg.foi ./ cfg.width; > >For a constant cfg.width, the spectral bandwidth increases linearly >with the frequency of interest. While at 18 Hz you have a spectral >bandwidth of 3 Hz, the bandwidth at 60 Hz is 10 Hz. > >>Also, does fieldtrip have a function that gives "phase locking >>factor" or inter-trial coherence (ITC)? > >Not that I know. However, you could compute ITC yourself based on the >complex output from freqanalysis_mtmconvol run with cfg.output = >'fourier'. > >Best, >Markus > From Jan.Schoffelen at FCDONDERS.RU.NL Wed Oct 18 09:47:45 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Wed, 18 Oct 2006 09:47:45 +0200 Subject: freqanalysis_wltconvol.m In-Reply-To: <6.1.2.0.2.20061017173241.01def4e0@email.med.yale.edu> Message-ID: Dear Brian, >Regarding phase-locking factor/ITC, couldn't I try to use the complex data >within the freqanalysis_wltconvol to calculate these data in a similar >method to that in the Tallon-Baudry et. al. '97 gamma paper? The wltconvol >function is so similar to that paper's analysis already, it seems like I >would only need to divide the complex data by its absolute value. The >paper refers to taking the "modulus of this complex value," where the >complex value is: >Pi(f,f0) = w(t,f0) X si(t,f0)/ | w(t,f0) X si(t,f0) I would implement the ITC as follows: itc = abs(mean(x./abs(x))); in which x is a vector of complex numbers representing your single-trial observations (in a single channel and a single frequencybin). Markus pointed out that you could use freqanalysis_mtmfft with cfg.output = 'fourier' to obtain these complex numbers, but apparently freqanalysis_wltconvol gives you a complex output as well. The above formula is how it is for example done in Tallon-Baudry '97 >I read this as the dividing the imaginary, sine wave, portion of the >wavelet (representing phase angle) at any given time and frequency by its >absolute value. Beware: a complex number can be represented as: B(cos*x+isin*x), or as A*exp(phi*i). The imaginary part you refer to is indeed the 'sine wave' but is not the whole story about the phase. The phase phi is determined both by the sine part and the cosine part. By normalizing with the absolute value, you divide the complete complex number by its amplitude, i.e. also the cosine part. If you think of it as a polar notation (A*exp(phi*i)), you divide the number by A, leaving a unit vector pointing in a particular direction (as determined by phi). >Does modulus have the same functionality/meaning as the >C++ mod or matlab rem function? The modulus of a complex number is its absolute, i.e. |x|, the corresponding matlab-function is abs(). The functions mod (also exists in matlab) and rem, are concerned with remainders after division, and modulo-stuff, which is similar to remainders >Is there interest in phase-locking values in the FieldTrip user community? >I am interested in trying to implement what is described above, but it >would be nice to have others see the code and test it to be sure I have >calculated phase-locking values correctly. I guess so, hopefully you now have a handle of doing it yourself. Yours, Jan-Mathijs From esther.meeuwissen at FCDONDERS.RU.NL Wed Oct 18 13:04:07 2006 From: esther.meeuwissen at FCDONDERS.RU.NL (Esther Meeuwissen) Date: Wed, 18 Oct 2006 13:04:07 +0200 Subject: cfg.highlight in topoplot Message-ID: Dear Fieldtrip users, Does anyone have suggestions how I can define two different cfg.highlights for 1 topoplot? For instance, to get a topoplot is an ERP diffence wave with channels in positive clusters marked red and channels in negative clusters marked blue. Thanks you in advance. Esther Meeuwissen From marco.buiatti at GMAIL.COM Thu Oct 19 12:13:18 2006 From: marco.buiatti at GMAIL.COM (Marco Buiatti) Date: Thu, 19 Oct 2006 12:13:18 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: Message-ID: Dear Robert, I followed your advice again, and made a (hopefully correct!) design matrix (I agree it clarifies what I am really computing). Now timelockstatistics starts to compute the statistics on the correct number of permutations, but as you can see from the results below, I still had some problems that I do not understand. This time I took three subjects instead of two, but the result does not depend on the subject's number. I also checked that I did not pick up any two identical datasets, and that ERPs are pretty standard (I expect no difference on N1, and difference on P300). Thank you in advance for your help, Marco % loading data from eeglab datasets EEG50PW_s2 = pop_loadset( '02_ev_ep_soa50PW.set','F:\joachim\'); EEG50W_s2 = pop_loadset( '02_ev_ep_soa50W.set','F:\joachim\'); EEG50PW_s4 = pop_loadset( '04_ev_ep_soa50PW.set','F:\joachim\'); EEG50W_s4 = pop_loadset( '04_ev_ep_soa50W.set','F:\joachim\'); EEG50PW_s5 = pop_loadset( '05_ev_ep_soa50PW.set','F:\joachim\'); EEG50W_s5 = pop_loadset( '05_ev_ep_soa50W.set','F:\joachim\'); % Transform to FieldTrip format data50PW{1} = eeglab2fieldtrip( EEG50PW_s2, 'timelockanalysis' ); data50W{1} = eeglab2fieldtrip( EEG50W_s2, 'timelockanalysis' ); data50W{2} = eeglab2fieldtrip( EEG50W_s4, 'timelockanalysis' ); data50PW{2} = eeglab2fieldtrip( EEG50PW_s4, 'timelockanalysis' ); data50W{3} = eeglab2fieldtrip( EEG50W_s5, 'timelockanalysis' ); data50PW{3} = eeglab2fieldtrip( EEG50PW_s5, 'timelockanalysis' ); % Loading channel names and positions data = eeglab2fieldtrip(EEG50PW_s2,'chanloc'); for i=1:3 data50W{i}.elec=data.elec; data50PW{i}.elec=data.elec; end; >> data50PW data50PW = [1x1 struct] [1x1 struct] [1x1 struct] >> data50PW{1} ans = label: {129x1 cell} fsample: 250 elec: [1x1 struct] avg: [129x523 single] var: [129x523 single] time: [1x523 double] dimord: 'chan_time' cfg: [1x1 struct] % designing design matrix cfg = [] cfg.design = [1 1 1 2 2 2; 1 2 3 1 2 3]; 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 % Setting cfg for timelockstatistics cfg.statistic='depsamplesT'; cfg.numrandomization = 'all'; cfg.alpha=0.05; cfg.clusterstatistics='maxsum'; cfg.clusterthreshold = 'parametric'; cfg.clusteralpha = 0.05; cfg.neighbourdist=4; cfg.neighbours = neighbourselection(cfg,data50PW{1}); cfg.latency=[0 0.5]; cfg.method = 'montecarlo'; cfg.correctm = 'cluster'; cfg = [] Using the electrode configuration from the dataset. there are on average 128.0 neighbours per channel stat = timelockstatistics(cfg,data50W{:},data50PW{:}); selected 129 channels selected 126 time bins selected 1 frequency bins using "statistics_montecarlo" for the statistical testing using "statfun_depsamplesT" for the single-sample statistics constructing randomized design total number of measurements = 6 total number of variables = 2 number of independent variables = 1 number of unit variables = 1 number of control variables = 0 number of within-block variables = 0 repeated measurement in variable 2 over 3 levels number of repeated measurements in each level is 2 2 2 creating all possible permutations (8) computing a parmetric threshold for clustering computing statistic Warning: Divide by zero. > In fieldtrip-20061016\private\statfun_depsamplesT at 106 In statistics_montecarlo at 249 In fieldtrip-20061016\private\statistics_wrapper at 233 In timelockstatistics at 50 estimated time per randomization is 0 seconds computing statistic 1 from 8 Warning: Divide by zero. > In fieldtrip-20061016\private\statfun_depsamplesT at 106 In statistics_montecarlo at 278 In fieldtrip-20061016\private\statistics_wrapper at 233 In timelockstatistics at 50 computing statistic 2 from 8 Warning: Divide by zero. > In fieldtrip-20061016\private\statfun_depsamplesT at 106 In statistics_montecarlo at 278 In fieldtrip-20061016\private\statistics_wrapper at 233 In timelockstatistics at 50 ... same output up to statistic 8 and then ??? Attempted to access (2); index out of bounds because numel()=1. Error in ==> fieldtrip-20061016\private\clusterstat at 65 postailcritval = cfg.clustercritval(2); Error in ==> statistics_montecarlo at 305 stat = clusterstat(cfg, statrand, statobs); Error in ==> fieldtrip-20061016\private\statistics_wrapper at 233 [stat, cfg] = statmethod(cfg, dat, cfg.design); Error in ==> timelockstatistics at 50 [stat] = statistics_wrapper(cfg, varargin{:}); On 10/16/06, Robert Oostenveld wrote: > Hi Marco > > Your script looks ok. > > On 13 Oct 2006, at 19:03, Marco Buiatti wrote: > > ??? Undefined variable "data" or class "data.biol". > > > > Error in ==> fieldtrip-20061012/private/prepare_design at 92 > > nrepl=size(data.biol,1); > > > > Error in ==> fieldtrip-20061012/private/statistics_wrapper at 212 > > [cfg] = prepare_design(cfg); > > > > Error in ==> timelockstatistics at 50 > > [stat] = statistics_wrapper(cfg, varargin{:}); > > Yep, that is a known problem (sorry about that). The function > prepare_design is not working properly. I suggest to make a design > matrix in cfg.design by hand (similar to, but not completely the same > as in SPM). It is not difficult, and it will also make you more clear > how it works. Please have a look at > https://listserv.surfnet.nl/scripts/wa.exe? > A2=ind0607&L=FIELDTRIP&P=R3192&I=-3&X=77C04E25A87526C2B4 > or if that URL does not work, then search the fieldtrip discussion > list archive for the string "cfg.design". > > best regards, > Robert > > PS note that you can also use timelockstatistics on the > 'componentanalysis' part of the EEGLAB data, in that case you cannot > use channel clustering, but you still can use timepoint clustering > (so cfg.neighbours should be []). You shoudl only do that if the ICA > components in the different EEG datasets are spatially the same (or > sufficiently similar, e.g. after clustering over subjects in the new > EEGLAB). > -- Marco Buiatti - Post Doc ************************************************************** Cognitive Neuroimaging Unit - INSERM U562 Service Hospitalier Frederic Joliot, CEA/DRM/DSV 4 Place du general Leclerc, 91401 Orsay cedex, France Telephone: +33 1 69 86 77 65 Fax: +33 1 69 86 78 16 E-mail: marco.buiatti at gmail.com Web: www.unicog.org *************************************************************** From r.oostenveld at FCDONDERS.RU.NL Thu Oct 19 16:39:17 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 19 Oct 2006 16:39:17 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: <22f732b0610190313y30ab9dd5p9ce335337184d8a2@mail.gmail.com> Message-ID: Dear Marco On 19 Oct 2006, at 12:13, Marco Buiatti wrote: > computing statistic 1 from 8 > Warning: Divide by zero. >> In fieldtrip-20061016\private\statfun_depsamplesT at 106 > In statistics_montecarlo at 278 > In fieldtrip-20061016\private\statistics_wrapper at 233 > In timelockstatistics at 50 > computing statistic 2 from 8 > Warning: Divide by zero. >> In fieldtrip-20061016\private\statfun_depsamplesT at 106 > In statistics_montecarlo at 278 > In fieldtrip-20061016\private\statistics_wrapper at 233 > In timelockstatistics at 50 > > ... same output up to statistic 8 and then Hmm, to me this seems to indicate that you have samples at which you do not have any variance, i.e. the computation of the t-score is mean_difference/pooled_variance, and since variance is zero, you have someting divided by zero, probably resulting in "Inf", i.e. infinite numbers. Could it be that you have baseline corrected data that is corrected to only one sample (i.e. the sample at time t=0), and that hence one sample in the data is always zero? I don't know how a t-score of Inf will affect the other computations. But the actual problem is > ??? Attempted to access (2); index out of bounds because numel()=1. > > Error in ==> fieldtrip-20061016\private\clusterstat at 65 > postailcritval = cfg.clustercritval(2); > > Error in ==> statistics_montecarlo at 305 > stat = clusterstat(cfg, statrand, statobs); > > Error in ==> fieldtrip-20061016\private\statistics_wrapper at 233 > [stat, cfg] = statmethod(cfg, dat, cfg.design); > > Error in ==> timelockstatistics at 50 > [stat] = statistics_wrapper(cfg, varargin{:}); That problem is NOT due to the warning above (i.e. the potential t- value of inf), but just a small programming error. The sequence of if- statements in that section of code was the wrong way around. Please find a corrected version of clusterstat.m attached to this mail. Actually, looking further into the code, I am surprised that you get this error. It means that the low level statfun_depsamplesT is using a cfg.tail=1 (that corresponds to cfg.clustertail in statistics_montecarlo itself). But from your cfg I do not see that you explicitely define a positive-tailed test, and the default set at the level of statistics_montecarlo should be two-tailed. Do you have any ideas about this yourself? best regards, Robert --- PS you can type dbstop if error on the matlab promt to start using the matlab debugger, and dbclear all to get rid of it again. That will help a lot in diagnosing problems like these. See "help dbstop" -------------- next part -------------- A non-text attachment was scrubbed... Name: clusterstat.m Type: application/octet-stream Size: 26868 bytes Desc: not available URL: From marco.buiatti at GMAIL.COM Fri Oct 20 19:02:08 2006 From: marco.buiatti at GMAIL.COM (Marco Buiatti) Date: Fri, 20 Oct 2006 19:02:08 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: <7BCCB2F0-B1B5-458A-8B2B-7E97FAFE1103@fcdonders.ru.nl> Message-ID: Thank you Robert, now EVERYTHING WORKS!!! More in detail: On 10/19/06, Robert Oostenveld wrote: > > computing statistic 2 from 8 > > Warning: Divide by zero. > >> In fieldtrip-20061016\private\statfun_depsamplesT at 106 > > In statistics_montecarlo at 278 > > In fieldtrip-20061016\private\statistics_wrapper at 233 > > In timelockstatistics at 50 > > > > ... same output up to statistic 8 and then > > Hmm, to me this seems to indicate that you have samples at which you > do not have any variance, i.e. the computation of the t-score is > mean_difference/pooled_variance, and since variance is zero, you have > someting divided by zero, probably resulting in "Inf", i.e. infinite > numbers. Could it be that you have baseline corrected data that is > corrected to only one sample (i.e. the sample at time t=0), and that > hence one sample in the data is always zero? You were right, and the reason for this was even more trivial: I had included the reference channel, which is always zero by definition. Now data are in average reference. > > I don't know how a t-score of Inf will affect the other computations. > But the actual problem is > > > ??? Attempted to access (2); index out of bounds because numel()=1. > > > > Error in ==> fieldtrip-20061016\private\clusterstat at 65 > > postailcritval = cfg.clustercritval(2); > > > > Error in ==> statistics_montecarlo at 305 > > stat = clusterstat(cfg, statrand, statobs); > > > > Error in ==> fieldtrip-20061016\private\statistics_wrapper at 233 > > [stat, cfg] = statmethod(cfg, dat, cfg.design); > > > > Error in ==> timelockstatistics at 50 > > [stat] = statistics_wrapper(cfg, varargin{:}); > > That problem is NOT due to the warning above (i.e. the potential t- > value of inf), but just a small programming error. The sequence of if- > statements in that section of code was the wrong way around. Please > find a corrected version of clusterstat.m attached to this mail. > > Actually, looking further into the code, I am surprised that you get > this error. It means that the low level statfun_depsamplesT is using > a cfg.tail=1 (that corresponds to cfg.clustertail in > statistics_montecarlo itself). But from your cfg I do not see that > you explicitely define a positive-tailed test, and the default set at > the level of statistics_montecarlo should be two-tailed. Do you have > any ideas about this yourself? Everything works now with the new clusterstat.m! Here you are my cfg at the point where it crashed before: cfg = design: [2x6 double] ivar: 1 uvar: 2 statistic: 'depsamplesT' numrandomization: 'all' alpha: 0.0500 clusterstatistics: 'maxsum' clusterthreshold: 'parametric' clusteralpha: 0.0500 neighbourdist: 0.8000 neighbours: {1x129 cell} latency: [0 0.5000] method: 'montecarlo' correctm: 'cluster' channel: {129x1 cell} frequency: [] avgoverchan: 'no' avgovertime: 'no' avgoverfreq: 'no' channelcmb: [] precision: 'double' version: [1x1 struct] previous: {1x6 cell} dim: [129 1 126] tail: 0 feedback: 'text' cvar: [] wvar: [] clusterstatistic: 'maxsum' clustercritval: 2.9200 clustertail: 0 factor: 1 unitfactor: 2 orderedstats: 'no' multivariate: 'no' minnbchan: 0 As you see, cfg.tail=0 but I have only one value of cfg.clustercritval (while the former clusterstat required two). I checked that results are totally compatible with the ones I obtained with clusterrandanalysis, and I easily transformed the spatial data I have (what I erroneously called scalar in my initial e-mail in this thread) to perform cluster randomization analysis. Thank you again for the follow up. Marco -- Marco Buiatti - Post Doc ************************************************************** Cognitive Neuroimaging Unit - INSERM U562 Service Hospitalier Frederic Joliot, CEA/DRM/DSV 4 Place du general Leclerc, 91401 Orsay cedex, France Telephone: +33 1 69 86 77 65 Fax: +33 1 69 86 78 16 E-mail: marco.buiatti at gmail.com Web: www.unicog.org *************************************************************** From lorina_naci at YAHOO.CO.UK Mon Oct 23 19:18:01 2006 From: lorina_naci at YAHOO.CO.UK (Lorina Naci) Date: Mon, 23 Oct 2006 18:18:01 +0100 Subject: Within-subject coherence statististics for virtual sources Message-ID: Dear FIELDTRIP members, I have used BESA to perform source coherence calculations for a multiple-subject/multiple-condition experiment. I have 14 subjects, and 2 conditions for which I’d like to compare coherence values. I have calculated coherence values in the Time-Frequency domain for each person. Given that BESA cannot calculate statistics in a multiple-subject study, their support personnel directed me towards FieldTrip. I would like to use your existing script ‘clusterrandanalysis on TFRs of power that were computed with BESA,’ but I cannot relate this to my data as the coherence values have been calculated for ROI sources, (8 per hemisphere - 16 sources total), and not for electrodes (I had 128). Do you have any advice regarding how I may adopt the script to for source coherence as opposed to electrode coherence? How do I import the source locations? Many thanks is advance for your help, Lorina Send instant messages to your online friends http://uk.messenger.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jaredvs at GMAIL.COM Mon Oct 23 22:28:28 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Mon, 23 Oct 2006 16:28:28 -0400 Subject: Incorrect coordinates? In-Reply-To: <2992F646-2E64-452D-8E51-9F9C121A63E0@fcdonders.ru.nl> Message-ID: Hi Robert, I just wanted to let you know that your suggestion was correct (I was working on a deadline for Friday, otherwise I would've responded sooner), the problem was created by the fact that the out of brain voxels were not masked out in the BESA data. The results of the analysis after masking appropriately were drastically different, and were all within-brain and make sense in light of the experimental task. I used the following code to obtain the mask: inside=[]; for k=1:length(files) src(k)=besa2fieldtrip([files(k).name]); in=find(src(k).avg.pow); inside(end+1:end+length(in))=in; end inside=unique(inside); outside=1:49708; outside(inside)=[]; for k=1:length(files) src(k).inside=inside; src(k).outside=outside; end This ensured that all the subjects had the same mask, and only values that were 0 in all the subjects were masked out. I manually checked all the subjects and there was at most a difference of 3 in the number of nonzero voxels in any two subjects. You might want to document this somewhere for other users, as it's not immediately apparent that specification of the .inside and .outside fields in the source structure are critical for further processing steps to behave correctly. Thanks for your help, -Jared On 10/16/06, Robert Oostenveld wrote: > > Hi Jared, > > On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > > I've rerun the analysis with mri's that were reoriented to MNI, and > > the same problem has emerged. > > I would guess that the anatomical MRIs themselves do not influence > the coordinate system of the source reconstruction. That would > influence the interpolation though. > > If you do > source = besa2fieldtrip(filename1) > and > mri = read_fcdc_mri(filename) > then the source structure is defined using the source.pos field that > describes the position of each source. SInce in this case the > positions are on a regular 3D grid, there is additional structure in > the arrangement of source.pos, which is described using source.xgrid, > source.ygrid, source.zgrid. > > If you do > tmp = reshape(source.avg.pow, source.dim) > you will get a 3D array with along the first dimension the voxels > along the x-axis, etc. The 1..Nth voxels along the xasix have the X > coordinates source.xgrid(1)..source.xgrid(N). Similar for the Y and Z > coordinates. That allows you to determine the coordinate of each voxel. > > Since the anatomical MRI is typically of much higher resolution, you > can use sourceinterpolate which interpolates the source (or stat) > volumes onto the voxel locations that are in the anatomical MRI. I.e. > sourceinterpolate upsamples the functional data to the anatomical > MRI. Normally you would do sourceinterpolate AFTER calling > sourcestatistics, since the source positions in all subjects are all > based on the same standard realistic head moidel in BESA and hence > the source positions in all subjects are the same (please check > whether positions are all the same over subjects/conditions). > > If you work with MEG or with EEG individual headmodels, the source > positions in all subjects are all different, which requires > sourceanalysis->sourceinterpolate->volumenormalize as shown in the > schema for http://www2.ru.nl/fcdonders/fieldtrip/doku.php? > id=fieldtrip:documentation:analysis_protocols#source_reconstruction_for_ > multiple_subjects > > > The typo you noted in your last email was indeed the reason for the > > empty src plot. Plotting src, interp, volume, and grandavg, > > everything looks ok. The 'pow' parameter values all appear within > > the brain. The tscore and p values in stat, however, are all messed > > up. I've attached .bmp's from using sourceplot on grandavg and stat > > to this email. The quality is poor (matlab's figure window doesn't > > ever save bmp's very well), but it should demonstrate the problem > > clearly. Note all the large values outside of the brain. > > In your case you should be able to do besa2fieldtrip -> > sourcestatistics, and then the source positions with the statistical > data on them should stll be the same as the positions with the > original functional data on them. After doing the statistics (or > after doing sourcegrandaverage), you can interpolate the functional/ > statistical data onto the MRI. But since the statistical data and the > functional (beamed power) data are on the same coordinates, there > should not be a difference between them. > > > Any comments you have would be greatly appreciated. I've considered > > just masking out everything that's not in the brain, but I'm not > > confident that the within-brain values are accurate. > > Looking at the bitmaps, I cannot see teh anatomy, but I do see a > brain-shaped outline with some blobs in them. I cannot recognise the > problem from these figures, to me they seem ok. The only problem that > I can see is the one that you also mention, and that is for the > masking. In the original source data (i.e. output from > besa2fieldtrip) there is an source.inside and source.outside field. > Those should contain the indices of the voxels (linear indices, so > voxel [1 1 1] has index 1 and voxel [2 1 1] has index 2...) of the > sources that are inside the brain and outside the brain. Only the > inside voxels are considered for sourcestatistics and for > sourceinterpolation. However, the problem with BESA data is that it > does not describe the inside/outside voxels and therefoer by default > all voxels are marked as inside. Perhaps you can determine the inside/ > outside voxels manually, e.g. > source.inside = find(source.avg.pow(:)>eps); > source.outside = find(source.avg.pow(:) After fixing the inside/outside, you can rerun sourcestatistics and > the rest. See the related FAQ http://www2.ru.nl/fcdonders/fieldtrip/ > doku.php? > id=fieldtrip:documentation:frequently_asked_questions#why_is_there_a_rim > _around_the_brain_for_which_the_source_reconstruction_is_not_computed > > To me it seems that the outside brain mess is caused by an > interpolation artifact, which can well be explained by the missing > inside/outside specification of besa. After fixing the inside/outside > vectors in the source structure, and passing it through > sourceinterpolate, you will get an interp.inside 3D boolean volume > with 0s and 1s for outside and inside voxels. You can element-wise > multiply the data with it, to mask the outside, or you can specify > cfg.mask='inside' in sourceplot (which uses opacity). > > Hope this helps, if not, please put some data (source, mri, stat, > interp) in a zip file on ftp://ftp.fcdonders.nl/pub/incoming > > Robert > -- Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jan.Schoffelen at FCDONDERS.RU.NL Tue Oct 24 15:31:57 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Tue, 24 Oct 2006 15:31:57 +0200 Subject: Within-subject coherence statististics for virtual sources In-Reply-To: <20061023171801.37444.qmail@web28106.mail.ukl.yahoo.com> Message-ID: Dear Lorina, For the time being, I assume that you have your data imported into a fieldtrip-like format, using besa2fieldtrip. I am not familiar with this function, but when I read the help of besa2fieldtrip I guess that your besa file was a .tfc file. So probably your data-object looks like what fieldtrip considers to be a frequency-structure, containing a TFR for each ROI. I guess you have two data-objects for each subject. What you would like to do is possible within fieldtrip, but I would advise you not to use clusterrandanalysis to get there. Quite some correspondence has been devoted to the new statistical interface, you can read about it on the discussion list's website (follow the appropriate links on the fieldtrip website), concerning Re: clusterrandanalysis on scalar values + problem with topoplotER during the past month, but which started in August. In a nutshell: instead of using clusterrandanalysis you could use freqstatistics (under the above assumption that your data resembles a fieldtrip-frequency structure) with the appropriate settings to get your statistics done. Freqstatistics relies on statistics_montecarlo, when you specify cfg.method = 'montecarlo'. Please have a try following the thread on the discussion list, and the following configuration settings, as well as the information in statistics_montecarlo and other dependent functions. You'll probably need the attached function as well, which computes your statistic of interest. Cfg = []; Cfg.method = 'montecarlo'; Cfg.statistic = 'diff'; Cfg.parameter = 'cohspctrm'; %This is at least what I expect your data objects to contain! Cfg.numrandomization = a number; Cfg.design = [1 1 2 2 3 3 with all the numbers in between 14 14; . 1 2 1 2 1 2 with all the numbers in between 1 2]; %this specifies how the data has to be interpreted Cfg.ivar = 2; %row-index of independent variable, which is the condition in your case Cfg.uvar = 1; %row-index of the 'unit'-variable, your unit of observation, which are your individual subjects. %the design-matrix will be shuffled, by swapping the 1 and 2's in the ivar-row, while keeping the uvar-doublets together. Cfg.correctm = 'yes'; %keep it at this for the time being, we have to develop a cunning strategy to incorporate something about the neighbourhood structure of your ROIs %as soon as you get your script running, you can try to incorporate fancy multiple-comparison correction strategies, such as clustering in time and frequency. Stat = freqstatistics(cfg, subj1cond1, subj1cond2, subj2cond1, subj2cond2 ..); %take care that this corresponds with how you specified your design. Subjxconx should then be the data-structure containing your TFRs in a field called cohspctrm. I hope this puts you on track, Yours, Jan-Mathijs _____ From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Lorina Naci Sent: Monday, October 23, 2006 7:18 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: [FIELDTRIP] Within-subject coherence statististics for virtual sources Dear FIELDTRIP members, I have used BESA to perform source coherence calculations for a multiple-subject/multiple-condition experiment. I have 14 subjects, and 2 conditions for which I'd like to compare coherence values. I have calculated coherence values in the Time-Frequency domain for each person. Given that BESA cannot calculate statistics in a multiple-subject study, their support personnel directed me towards FieldTrip. I would like to use your existing script 'clusterrandanalysis on TFRs of power that were computed with BESA,' but I cannot relate this to my data as the coherence values have been calculated for ROI sources, (8 per hemisphere - 16 sources total), and not for electrodes (I had 128). Do you have any advice regarding how I may adopt the script to for source coherence as opposed to electrode coherence? How do I import the source locations? Many thanks is advance for your help, Lorina Send instant messages to your online friends http://uk.messenger.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: statfun_diff.m Type: application/octet-stream Size: 990 bytes Desc: not available URL: From r.oostenveld at FCDONDERS.RU.NL Wed Oct 25 08:05:27 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 25 Oct 2006 08:05:27 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610231328y1b3d2093xe9b02abf4b3af113@mail.gmail.com> Message-ID: Hi Jared, Thanks for your detailled feedback. I think that it is a good idea to document these steps for other BESA users. I am rather busy, but maybe you could do it yourself? The FieldTrip website is a Wiki, and anyone can edit and contribute to it by pressing the "edit this page" button that you see on every page. Regarding this information: I would put it under a subheading (with some introductory comments, which probably can be copied-pasted from our previous mails) on the BESA-related page, i.e. on http://www2.ru.nl/fcdonders/fieldtrip/ doku.php?id=fieldtrip:documentation:integrating_with_besa best regards, Robert On 23 Oct 2006, at 22:28, Jared Van Snellenberg wrote: > Hi Robert, > > I just wanted to let you know that your suggestion was correct (I > was working on a deadline for Friday, otherwise I would've > responded sooner), the problem was created by the fact that the out > of brain voxels were not masked out in the BESA data. The results > of the analysis after masking appropriately were drastically > different, and were all within-brain and make sense in light of the > experimental task. > > I used the following code to obtain the mask: > > inside=[]; > > > for k=1:length(files) > src(k)=besa2fieldtrip([ > > files(k).name]); > in=find(src(k).avg.pow); > > inside(end+1:end+length(in))=in; > > > end > inside=unique(inside); > > outside=1:49708; > > outside(inside)=[]; > > > for k=1:length(files) > src(k).inside=inside; > > src(k).outside=outside; > > > endThis ensured that all the subjects had the same mask, and only > values that were 0 in all the subjects were masked out. I manually > checked all the subjects and there was at most a difference of 3 in > the number of nonzero voxels in any two subjects. > > You might want to document this somewhere for other users, as it's > not immediately apparent that specification of the .inside > and .outside fields in the source structure are critical for > further processing steps to behave correctly. > > Thanks for your help, > > -Jared > > > > > On 10/16/06, Robert Oostenveld > wrote: Hi Jared, > > On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > > I've rerun the analysis with mri's that were reoriented to MNI, and > > the same problem has emerged. > > I would guess that the anatomical MRIs themselves do not influence > the coordinate system of the source reconstruction. That would > influence the interpolation though. > > If you do > source = besa2fieldtrip(filename1) > and > mri = read_fcdc_mri(filename) > then the source structure is defined using the source.pos field that > describes the position of each source. SInce in this case the > positions are on a regular 3D grid, there is additional structure in > the arrangement of source.pos, which is described using source.xgrid, > source.ygrid, source.zgrid. > > If you do > tmp = reshape(source.avg.pow , source.dim) > you will get a 3D array with along the first dimension the voxels > along the x-axis, etc. The 1..Nth voxels along the xasix have the X > coordinates source.xgrid(1)..source.xgrid(N). Similar for the Y and Z > coordinates. That allows you to determine the coordinate of each > voxel. > > Since the anatomical MRI is typically of much higher resolution, you > can use sourceinterpolate which interpolates the source (or stat) > volumes onto the voxel locations that are in the anatomical MRI. I.e. > sourceinterpolate upsamples the functional data to the anatomical > MRI. Normally you would do sourceinterpolate AFTER calling > sourcestatistics, since the source positions in all subjects are all > based on the same standard realistic head moidel in BESA and hence > the source positions in all subjects are the same (please check > whether positions are all the same over subjects/conditions). > > If you work with MEG or with EEG individual headmodels, the source > positions in all subjects are all different, which requires > sourceanalysis->sourceinterpolate->volumenormalize as shown in the > schema for http://www2.ru.nl/fcdonders/fieldtrip/doku.php ? > id=fieldtrip:documentation:analysis_protocols#source_reconstruction_fo > r_ > multiple_subjects > > > The typo you noted in your last email was indeed the reason for the > > empty src plot. Plotting src, interp, volume, and grandavg, > > everything looks ok. The 'pow' parameter values all appear within > > the brain. The tscore and p values in stat, however, are all messed > > up. I've attached .bmp's from using sourceplot on grandavg and stat > > to this email. The quality is poor (matlab's figure window doesn't > > ever save bmp's very well), but it should demonstrate the problem > > clearly. Note all the large values outside of the brain. > > In your case you should be able to do besa2fieldtrip -> > sourcestatistics, and then the source positions with the statistical > data on them should stll be the same as the positions with the > original functional data on them. After doing the statistics (or > after doing sourcegrandaverage), you can interpolate the functional/ > statistical data onto the MRI. But since the statistical data and the > functional (beamed power) data are on the same coordinates, there > should not be a difference between them. > > > Any comments you have would be greatly appreciated. I've considered > > just masking out everything that's not in the brain, but I'm not > > confident that the within-brain values are accurate. > > Looking at the bitmaps, I cannot see teh anatomy, but I do see a > brain-shaped outline with some blobs in them. I cannot recognise the > problem from these figures, to me they seem ok. The only problem that > I can see is the one that you also mention, and that is for the > masking. In the original source data (i.e. output from > besa2fieldtrip) there is an source.inside and source.outside field. > Those should contain the indices of the voxels (linear indices, so > voxel [1 1 1] has index 1 and voxel [2 1 1] has index 2...) of the > sources that are inside the brain and outside the brain. Only the > inside voxels are considered for sourcestatistics and for > sourceinterpolation. However, the problem with BESA data is that it > does not describe the inside/outside voxels and therefoer by default > all voxels are marked as inside. Perhaps you can determine the inside/ > outside voxels manually, e.g. > source.inside = find(source.avg.pow(:)>eps); > source.outside = find(source.avg.pow(:) After fixing the inside/outside, you can rerun sourcestatistics and > the rest. See the related FAQ http://www2.ru.nl/fcdonders/fieldtrip/ > doku.php? > id=fieldtrip:documentation:frequently_asked_questions#why_is_there_a_r > im > _around_the_brain_for_which_the_source_reconstruction_is_not_computed > > To me it seems that the outside brain mess is caused by an > interpolation artifact, which can well be explained by the missing > inside/outside specification of besa. After fixing the inside/outside > vectors in the source structure, and passing it through > sourceinterpolate, you will get an interp.inside 3D boolean volume > with 0s and 1s for outside and inside voxels. You can element-wise > multiply the data with it, to mask the outside, or you can specify > cfg.mask='inside ' in sourceplot (which uses opacity). > > Hope this helps, if not, please put some data (source, mri, stat, > interp) in a zip file on ftp://ftp.fcdonders.nl/pub/incoming > > Robert > > > > -- > Jared Van Snellenberg > Social Cognitive Affective Neuroscience Unit > http://scan.psych.columbia.edu > (212) 854-7858 p > (212) 854-3609 f > Department of Psychology, Columbia University > 406 Schermerhorn Hall > 1190 Amsterdam Avenue, Mail Code 5501 > New York, NY 10027 From litvak at TX.TECHNION.AC.IL Tue Oct 31 15:06:21 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Tue, 31 Oct 2006 14:06:21 -0000 Subject: SPM integration Message-ID: Dear Robert and all, I'm starting to work on a project where I will analyze data preprocessed in FT with SPM5 (www.fil.ion.ucl.ac.uk/spm/). For this purpose I'd like to develop FT/SPM integration routines. I'll probably start with my immediate needs but I think I'm motivated enough at the moment to eventually turn it into something of general usefulness. If anyone has already worked in this direction and has some code or would like to collaborate please let me know. I'm affiliated to the methods group at FIL so I can get help from SPM developers if necessary. Right now I'd like to be able to use FT to read any FT supported format to SPM. Additional question: how does one create low-level routines for a new (rare) data format to be used by FT preprocessing? Is there a template or some interface they should adhere to? Thanks, Vladimir Litvak -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jan.Schoffelen at FCDONDERS.RU.NL Tue Oct 31 15:33:24 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Tue, 31 Oct 2006 15:33:24 +0100 Subject: Picturing wavelet shape In-Reply-To: <454238CD.4090706@psych.york.ac.uk> Message-ID: >Dear Jan > >Please can you advise me how to visualize the actual shape of the wavelets >produced by the two parameters: > >width and gwidth > >I am getting some interesting/frustrating effects whereby small changes in >both values (varying width between 3-5, and gwidth between 1-4) and can >flip the polarity in my spectral plots. In other words, the location in >time and frequency of significant power doesn't really change, but whether >these are assigned an increase(red) or decrease >(blue) in power does change relative to baseline. The spectrograms are >created with singleplotTFR , combined with a baseline. I know I am at the >resolution limits for these analyses, because of our relatively short time >windows, but I am hoping that these effects can be explained by subtle >changes in wavelet shape, and therefore I needn't worry too much. >Alternatively, I may be pushing the analysis to breaking point, where it is >too unreliable to report. But to help me decide, picturing the wavelet >structure would be a real help (I think). Dear Piers, Hmmm, the easy answer to your question is to extract some of the relevant lines to a new script and play around with that. When you look into the code, in my version (revision version 1.16) the wavelets are constructed, starting in line 214: (for foilop = 1:numfoi) dt = 1/data.fsample; sf = cfg.foi(foilop)/cfg.width(foilop); st = 1/(2*pi*sf); toi2 = -cfg.gwidth*st:dt:cfg.gwidth*st; A = 1/sqrt(st*sqrt(pi)); tap = (A*exp(-toi2.^2/(2*st^2)))'; ... (end) The vector tap contains the wavelet, which you can visualize with plot(tap); So far the easy part. However, it is a bit obscure that you get opposite effects by slightly adjusting your wavelet-parameters, and I suspect that that is not a wavelet issue, but rather a baseline-issue. If we look at your configuration for the plotting: cfg5 = []; cfg5.baseline = [-0.2 0.0]; %cfg5.baselinetype = 'relative'; cfg5.baselinetype = 'absolute'; cfg5.zlim = 'maxmin'; cfg5.xlim = [-0.0 0.3]; cfg5.ylim = [7 30]; cfg5.channel = 'V0'; singleplotTFR(cfg5, freq); You use a baseline-interval between -0.2 and 0. This essentially means, that you are subtracting the estimated baseline, averaged between -0.2 and 0. However, timepoint 0 contains quite some post-stimulus-onset stuff, because of the width of your wavelet kernel (which scales with frequency, so I would expect more of your strange effects in these ranges). If there's a strong evoked component in your data, which bleeds into your baseline estimate, this might lead to an overestimation of your baseline-power, and to a subsequent stimulus-locked decrease in power post-stimulus. If there's less bleeding into the baseline, the baseline estimate is lower, which would lead to a stimulus-locked increase in power, which I would expect at a earlier latency than the decrease described before. Best Jan-Mathijs From luca.ciancetta at TISCALI.IT Tue Oct 31 18:28:50 2006 From: luca.ciancetta at TISCALI.IT (Luca Ciancetta) Date: Tue, 31 Oct 2006 18:28:50 +0100 Subject: lcmv localization Message-ID: Dear List members, I'm trying to localize a source with the lcmv method. Following, it's the configuration I use: time_step = 1/h.smpfq; % the time step depends by sampling frequency time = 0:time_step:(500*time_step); % I want to see 500 points of data data.trial{1} = data_raw(gch,0:500); % gch: list of good channels data.time{1} = time; cfg = []; cfg.method = 'lcmv'; cfg.grid.pos = model; % model is a matrix [number_of_sources X 3]. This represent position of dipoles in the reference of the sphere which contains them. cfg.grad.tra = zeros(nch,nch); % number of good sensors ( size of 'gch' list ) for i=1:nch cfg.grad.pnt(i,: ) = h.ch(gch(i)+offset).pos(1).r_s.comp'; % positions of MEG sensors in the reference of the spherical model cfg.grad.ori(i,: ) = h.ch(gch(i)+offset).pos(1).u_s.comp'; % orientations of MEG sensors in the reference of the spherical model cfg.grad.tra(i,i) = 1; cfg.grad.label{i} = sprintf('MZ_%d\n',gch(i)-1); end cfg.vol = []; cfg.vol.r = 65; cfg.bpfilter = 'yes'; cfg.bpfreq = [1 100]; data.avg = squeeze(data.trial{1}); source = sourceanalysis(cfg,data); In this case I used only one trial and the result is a localization in the center of the sphere ( the source is a dipole simulation, it was placed on the surface of my spherical model). Also analyzing over more trials or using different data set, for example a median nerve stimulation, the result was the same. can you help me? Thanks, Luca. From P.PRAAMSTRA at BHAM.AC.UK Sun Oct 1 14:08:41 2006 From: P.PRAAMSTRA at BHAM.AC.UK (Peter Praamstra) Date: Sun, 1 Oct 2006 13:08:41 +0100 Subject: clusterrandanalysis Message-ID: Dear Robert / other fieldtrippers, I´m looking for advice on the following. I´m trying to do clusterrandanalysis on TFR data with the cfg. statistic=´actvsblT´ option. The tutorial `Cluster-level randomization tests´ gives an example in which separate TFRs are calculated for activation and baseline data. The clusterrandanalysis.m documentation also states that two datasets must be passed. However, I´d like to make the activation vs baseline comparison work for baseline and activation TF windows identified in single TFRs that include a prestimulus and a poststimulus period. To do so, I used cfg. latency, cfg. frequency and cfg. keepindividual with freqgrandaverage to create separate datastructures for the baseline and activation timefrequency windows of interest. Unfortunately, this doesn´t work. I get an error message: ??? Error using ==> clusterrandanalysis Not all time points in the first data set are in the activation (post-stimulus) period. This is probably due to clusterrandanalysis expecting a positive time axis for the activation data and a negative time axis for the baseline data. Hence, although I defined TF windows of equal length for activation and baseline, it looks like Fieldtrip is unable to ignore the original, but irrelevant, time axis definition. I considered reading in the same data twice (through freqgrandaverage) with different definitions of the time axes. However, this would still require clusterrandanalysis to deal with activation and baseline TF windows that are not matched in time on the time axes of their respective datastructures. So I suspect it would still not work. Any advice on how I could work around this would be greatly appreciated. Best wishes, Peter Praamstra -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.siegel at UKE.UNI-HAMBURG.DE Mon Oct 2 09:59:01 2006 From: m.siegel at UKE.UNI-HAMBURG.DE (Markus Siegel) Date: Mon, 2 Oct 2006 09:59:01 +0200 Subject: freqanalysis_wltconvol.m In-Reply-To: <6.1.2.0.2.20060929123621.059feec0@email.med.yale.edu> Message-ID: Dear Brian, cfg.width determines in cycles the width of the Morlet-wavelet as the standard deviation of the underlying gaussian (often termed "q"). One can either use a fixed q for all frequencies by giving only one number in cfg.width, or one can use a different q for each frequency of interest with a vector in cfg.width of the same length as cfg.foi. "help freqanalysis_wltconvol" gives you the relationship between cfg.width (width) , the frequency of interest (f0) and the standard- deviation (resolution) of the wavelet-transform in the temporal (st) and spectral (sf) domain: The standard deviation in the frequency domain (sf) at frequency f0 is defined as: sf = f0/width The standard deviation in the temporal domain (st) at frequency f0 is defined as: st = width/f0 = 1/sf The spectral bandwidth (in standard deviations, Hz) of the time- frequency transform can thus be computed as: bw = cfg.foi ./ cfg.width; The parameter cfg.gwidth determines the length of the wavelet-kernel used in standard deviations of the underlying gaussian. In other words, it specifies over how many standard deviations the gaussian is estimated for the morlet-wavelet in both directions. This does in principle not influence the spectro-temporal resolution of the transform, but determines its precision because the gaussian is non- zero at the edges. Therefore, small values (e.g. <2) lead to edge effects in the transform. The full length of the 'longest' wavelet at the lowest frequency cfg.foi(1) is thus computed as: 2 * cfg.gwidth (cfg.width(1) ./ cfg.foi(1)) In freqanalysis_wltconvol, the wavelet transform is implemented by multiplication in the frequency domain which is computationally more efficient than convolution in the temporal domain. However, technically the transform is well described as a convolution of the time-series with a complex Morlet-wavelet (complex sinusoid with a gaussian envelope) as e.g. provided in Tallon-Baudry et al., J Neurosci 1997. Best, Markus Am 29.09.2006 um 18:52 schrieb Brian Roach: > Dear FieldTrip users, > > I have been playing with the freqanalysis_wltconvol function in > hopes of using the morlet wavelet time frequency analysis on some > eeg data. I have been able to get it running, and I find that it > works very quickly, which is great. However, I am hoping some > users or F.T. programmers can explain some of the function inputs > and processing. The cfg example is as follows: > > % cfg.method = 'wltconvol'; > % cfg.foi = 1:1:100; > % cfg.width = 7; > % or > % cfg.width = linspace(5,10,length(cfg.foi)); > % cfg.toi = 0:0.1:2; > % cfg.gwidth = 3; > > I believe that the cfg.width specifies the number of wave cycles > used in each frequency's wavelet analysis (so at 2Hz, 7 cycles > spans 3500ms of data, right?). Maybe this is not correct, because > I do not seem to get the frequencies as low as I would expect given > my data epoch length. Perhaps this has to do with the cfg.gwidth > parameter, which I do not think I completely understand - what is it? > > Also, we do not have the matlab wavelet toolbox, and it appears > that it is not required, but how is the morlet wavelet > implemented? As I look through the code I see calls to fft, ifft, > and fftshift, but I wonder how I can give a good technical > description of this process if I find results in a larger data set. > > Finally, is there a function or a way to compute the frequency > bandwidth based on the cfg inputs, or is there a fix frequency > bandwith for each foi here? I am sure I am confusing a number of > things here, so no response is too simple. > > Thanks for any advice, please let me know if there is more > information I can give or if I can clarify my questions. > > Brian > From r.oostenveld at FCDONDERS.RU.NL Mon Oct 2 21:03:53 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 2 Oct 2006 21:03:53 +0200 Subject: clusterrandanalysis In-Reply-To: <451FBDD9.31055.628453@P.PRAAMSTRA.Bham.ac.uk> Message-ID: Hi Peter > I’m trying to do clusterrandanalysis on TFR data with the cfg. > statistic=’actvsblT’ option. The tutorial ‘Cluster-level > randomization tests’ gives an example in which separate TFRs are > calculated for activation and baseline data. The > clusterrandanalysis.m documentation also states that two datasets > must be passed. I am not that familiar with comparing activation versus baseline using the actvsblT statistic (it was implemented by Eric) but as I understand it, the rationale behind it is that all timepoints in the baseline are equivalent to all timepoints in the activation period. I.e. there is no intrinsic reason to compare one specific baseline timepoint with one specific timepoint in the active period, hence it implements a comparison in which all timepoints in the baseline are collapsed/averaged, and the active period is compared to this average. From the FT homepage documentation (http://www2.ru.nl/fcdonders/ fieldtrip/doku.php? id=fieldtrip:documentation:tutorial:clusterrandanalysis) >> With cfg.statistic=’actvsblT’, we choose the so-called activation- >> versus-baseline T-statistic. By means of this statistic, we >> compare the power in every (channel, frequency, time)-element in >> the activation period with the corresponding average power >> (average over time) in the baseline period. The comparison of the >> activation and the average baseline power is performed by means of >> a pairwise T-statistic, with the pairs corresponding to the trials. However, the approach that I usually take (and also explain to other people here) for comparing two time windows in the same dataset is to copy the dataset into a dummy dataset and shift the timeaxis of the dummy dataset. E.g. dat = preprocessing(..) avg = timelockanalysis(..) % with keeptrials act = avg; bas = avg; bas.time = bas.time + 0.500; % shift the time axis, here the sample corresponding with -500ms is shifted to 0ms stat = clusterrandanalysis(cfg, bas, act) The statistisc then becomes a regular depsamplesT (i.e. paired data in the baseline and activation window). E.g. in the above example you could do figure plot(act.time, act.avg, 'r'); % in red hold on plot(act.time, act.avg, 'b'); % in blue and you would see the two ERPs shifted in time. This plot also makes it easy to identify the timewindow in which to do the statistical test (default is to take all overlapping time that is present in the input data). > However, I’d like to make the activation vs baseline comparison > work for baseline and activation TF windows identified in single > TFRs that include a prestimulus and a poststimulus period. To do > so, I used cfg. latency, cfg. frequency and cfg. keepindividual > with freqgrandaverage to create separate datastructures for the > baseline and activation timefrequency windows of interest. Here I cannot follow you. You have two conditions, each with a baseline and an active period. What is the comparison taht you want to make? I would presume that you do not expect differences in the baseline. If there were an a priori difference in the baseline, then a difference in the active period would seem trivial to me. So to me teh logical assumption would be that the baselines are the same and that you want to compare either the whole time interval or (equally valid) only the active period. I can also imagine that you want to compare the TFR data in the active window after correcting for eventual differences in the baseline. This would involve first doing a (single trial) baseline correction (expressing the power in each trial as relative number compared to the average in the baseline). In FT we have the freqbaseline function, however, that function sofar did not support single-trial baseline coprrections (only averaged powspctrm would be corrected). Please find attached a freqbaseline that will also do it on single trial powspectra. hope this helps, Robert -------------- next part -------------- A non-text attachment was scrubbed... Name: freqbaseline.m Type: application/octet-stream Size: 9714 bytes Desc: not available URL: From maris at NICI.RU.NL Mon Oct 2 21:28:03 2006 From: maris at NICI.RU.NL (Eric Maris) Date: Mon, 2 Oct 2006 21:28:03 +0200 Subject: clusterrandanalysis In-Reply-To: <451FBDD9.31055.628453@P.PRAAMSTRA.Bham.ac.uk> Message-ID: Hi Peter, I'm trying to do clusterrandanalysis on TFR data with the cfg. statistic='actvsblT' option. The tutorial 'Cluster-level randomization tests' gives an example in which separate TFRs are calculated for activation and baseline data. The clusterrandanalysis.m documentation also states that two datasets must be passed. However, I'd like to make the activation vs baseline comparison work for baseline and activation TF windows identified in single TFRs that include a prestimulus and a poststimulus period. To do so, I used cfg. latency, cfg. frequency and cfg. keepindividual with freqgrandaverage to create separate datastructures for the baseline and activation timefrequency windows of interest. This I don't understand. In my terminology, "baseline" and "prestimulus" are synonymous, as are "activation" and "poststimulus". The activation-versus-baseline statistic identifies samples (i.e., (sensor,frequency,time)-elements) in the activation/poststimulus period that are different from the time-average of the corresponding samples in the baseline/prestimulus period. If you use freqgrandaverage to create an activation and a baseline datastructure of the same size (with a positive time-axis for the activation period, and a negative time-axis for the baseline period), then clusterrandanalysis should do the job. Greetings, Eric Maris -------------- next part -------------- An HTML attachment was scrubbed... URL: From P.PRAAMSTRA at BHAM.AC.UK Tue Oct 3 14:13:02 2006 From: P.PRAAMSTRA at BHAM.AC.UK (Peter Praamstra) Date: Tue, 3 Oct 2006 13:13:02 +0100 Subject: clusterrandanalysis Message-ID: Hi Robert, Eric, many thanks for your helpful comments. Robert's was especially useful. Implementing the suggestion to shift the time axis revealed a glitch in besa2fieldtrip that I should have spotted earlier. It doesn't convert ms in s. As a result, cfg.latency or cfg.toilim statements using seconds as time unit don't work properly. This peculiarity concerns BESA TFR data; I don't know about other BESA data formats. Best regards, Peter From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 10:37:32 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 10:37:32 +0200 Subject: attention: default changed for MEG leadfields Message-ID: Dear fieldtrippers, I want to bring to your attention that I just changed the default value for the option cfg.reducerank in the SOURCANALYSIS and the PREPARE_LEADFIELD functions. The old default was 'no', the new default depends on the type of data that you are working with. In case of EEG, the new default is 3. This basically is the same as 'no', since the intrinsic rank of the EEG leadfield for a dipole is 3. So effectively nothing changed here. In case of MEG, the new default is 2. This was the value that I always recommend when someone would ask me for it. To prevent people from accidentally forgetting to set it to 2, we now decided to change the default. The change is immediate for people within the Donders, and for the external users it will become visible in the daily fieldtrip version on the FTP server this evening. Background: The cfg.reducerank option relates to how the leadfields are computed, and is only relevant for MEG in combination with realistic (localspheres, singleshell) volume conduction models for the head. In Fieldtrip, we always work with dipoles that can be oriented in x, y, and z direction. The dipole orientation and strenghth together form the dipole mooment. There is one particular [x,y,z] direction for the dipole for which it points to the surface of the head, i.e. that is the radial component. The magnetic field for that radial component is zero (in a single sphere model), or almost zero (in a realistic model). Since sources that are almost zero pick up a lot of noise in the beamformer method, it is desirable to explicitely set the leadfield in that direction to exactly zero. That is done by the reducerank option, which ensures that the leadfield will only contain the two tangential components and which makes the radial component zero. best regards, Robert From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 10:44:10 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 10:44:10 +0200 Subject: clusterrandanalysis In-Reply-To: <452261DE.19934.F0AE74@P.PRAAMSTRA.Bham.ac.uk> Message-ID: Hi Peter On 3 Oct 2006, at 14:13, Peter Praamstra wrote: > Implementing the suggestion to shift the time > axis revealed a glitch in besa2fieldtrip that I should have spotted > earlier. It > doesn't convert ms in s. As a result, cfg.latency or cfg.toilim > statements > using seconds as time unit don't work properly. > > This peculiarity concerns BESA TFR data; I don't know about other BESA > data formats. There are many variations of the BESA format, which makes them difficult to support. Every couple of months, someone will contact me with yet another BESA file that is not fully supported :-( Fieldtrip always works with seconds and not with ms, hence it should be fixed. I expect the problem to be on line 141 of besa2fieldtrip, which now reads data = []; data.time = Time; data.freq = Frequency; and probably this should read data = []; data.time = Time * 1e-3; % convert to seconds data.freq = Frequency; Can you confirm this? best, Robert From MZvyagintsev at UKAACHEN.DE Wed Oct 4 12:38:00 2006 From: MZvyagintsev at UKAACHEN.DE (Mikhail Zvyagintsev) Date: Wed, 4 Oct 2006 12:38:00 +0200 Subject: MEG realign In-Reply-To: <2093A833-C89D-4DB0-9D53-FB43A9DAF4A2@fcdonders.ru.nl> Message-ID: Dear Robert / other fieldtrippers, I have a question regarding MEG realign procedure. I actually found it very useful and trying to learn how to deal with it. I am using 4 D Neuroimaging mashine (BTi), and, therefore, I had to change the routine a bit - at least change settings, concerning the sensors name. In my particular case I got the message 'mean distance towards template gradiometers is 25.45 mm'. (I actually attached a picture regarding sensors' position's difference derived from Matlab, but probably it is not so easy to recognize what is what on this picture - points are sensors and different colors - positions in different sessions, the view is from front). And later in this routine I use the approach based on calculation of brain surface from headshape. As a headshape we use here points from bridge (of nose) to nape (of the neck). I get 644 dipoles from it 'prunedinv' subfunction gives me 'pruning 49 out of 148 singular values' (so, we use 148 channels mashine). After calculation of realign matrix and applying it for 'realigning trial' the residual variance (RV) which I get for one trial is arround 30%. I have a feelling that it is rather to much, or might be it's normal, becouse difference between sensors is rather big one. Because in case 'mean distance towards template gradiometers' was 6.48 mm - residual variances were arround 5-6%. So, distance RV 6.48 mm 5-6% 25.45 mm ~30%. My question is - is such RV difference correspondent to the difference distance I have and how many points should be like a 'control value' for 'prunedinv' routine? Thank you in advance, Mikhail Zvyagintsev -- __________________________________________________________________ Mikhail Zvyagintsev MD, BSc Klinik für Psychiatrie & Psychotherapie UK Aachen Pauwelsstr. 30 D-52074 Aachen tel +49-0241-80 85580 FAX +49-0241-80 82401 MZvyagintsev at UKAachen.de -------------- next part -------------- A non-text attachment was scrubbed... Name: session 1 and 3 positions.tif Type: image/tiff Size: 706680 bytes Desc: not available URL: From P.PRAAMSTRA at BHAM.AC.UK Wed Oct 4 13:40:16 2006 From: P.PRAAMSTRA at BHAM.AC.UK (Peter Praamstra) Date: Wed, 4 Oct 2006 12:40:16 +0100 Subject: clusterrandanalysis In-Reply-To: Message-ID: hoi Robert, dat doet de truc natuurlijk. groeten, peter On 4 Oct 2006 at 10:44, Robert Oostenveld wrote: > Hi Peter > > On 3 Oct 2006, at 14:13, Peter Praamstra wrote: > > Implementing the suggestion to shift the time > > axis revealed a glitch in besa2fieldtrip that I should have > spotted > > earlier. It > > doesn't convert ms in s. As a result, cfg.latency or cfg.toilim > > statements > > using seconds as time unit don't work properly. > > > > This peculiarity concerns BESA TFR data; I don't know about other > BESA > > data formats. > > There are many variations of the BESA format, which makes them > difficult to support. Every couple of months, someone will contact > me > with yet another BESA file that is not fully supported :-( > > Fieldtrip always works with seconds and not with ms, hence it should > be fixed. I expect the problem to be on line 141 of besa2fieldtrip, > which now reads > data = []; > data.time = Time; > data.freq = Frequency; > and probably this should read > data = []; > data.time = Time * 1e-3; % convert to seconds > data.freq = Frequency; > > Can you confirm this? > > best, > Robert ###################################### Peter Praamstra, MD, PhD Reader in Cognitive Neurophysiology Honorary Consultant Neurology Behavioural Brain Sciences Centre School of Psychology, University of Birmingham Birmingham, B15 2TT tel. 0121 414 7211 fax 0121 414 4897 From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 14:36:09 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 14:36:09 +0200 Subject: MEG realign In-Reply-To: <45238F08.3060006@UKAachen.de> Message-ID: Hi Mikhail On 4 Oct 2006, at 12:38, Mikhail Zvyagintsev wrote: > I am using 4 D Neuroimaging mashine (BTi), and, therefore, I had to > change the routine a bit - at least change settings, concerning the > sensors name. Yes, I can imagine that, since it is using some pre-defined sensor names to construct the averaged template helmet position. Could you send me the change (private mail), then I will include it in FT. > (I actually attached a picture regarding sensors' position's > difference derived from Matlab, but probably it is not so easy to > recognize what is what on this picture - points are sensors and > different colors - positions in different sessions, the view is > from front). There is an option in MEGREALIGN that you can use for plotting something similar (cfg.plot3d=yes) > And later in this routine I use the approach based on calculation > of brain surface from headshape. As a headshape we use here points > from bridge (of nose) to nape (of the neck). You should ensure that the points, when shifted inwards with cfg.inwardshift (units are the same as your units of the volume an dgradiometer system, in case of CTF that is in cm), that they more or less ly in the gray matter, i.e. approx 0.5-1cm inward from the brain surafce. If your head surface includes ears and a nose, you will have weird effects. You could change teh plot3d option in such a way that the dipole grid positions are also plotted (you should plot the pos variable). > I get 644 dipoles from it 'prunedinv' subfunction gives me 'pruning > 49 out of 148 singular values' (so, we use 148 channels mashine). That seems a rather large reduction. The issue here is that you need 148 sources (i.e. a dipole onsists of an x, y and z source, and in case of a spherical headmodel the radial component will be zero) to be able to completely describe the data. But if there is noise (a small and spatially shart amplitude contribution), then that noise will also project to teh sourcespace. Hence, the noise will also project outward again to the new sensor array. By "pruning" the leadfield matrix, the N spatially strongest components are selected, where a component is then not a dipole any more, but a combination of dipoles. I.e. a SVD is done on the leadfield, and the smallest contributing components are removed. By default all source components smaller than 0.001 times the largest component will be removed (note that this is independent of data). In your case there are 49 of the 148 removed. You have 644 sources, each with 3 orientations -> those are compressed into 148-49=99 spatial topographies. > After calculation of realign matrix and applying it for 'realigning > trial' the residual variance (RV) which I get for one trial is > arround 30%. I have a feelling that it is rather to much, or might > be it's normal, becouse difference between sensors is rather big one. > Because in case 'mean distance towards template gradiometers' was > 6.48 mm - residual variances were arround 5-6%. > So, > distance RV > 6.48 mm 5-6% > 25.45 mm ~30%. > My question is - is such RV difference correspondent to the > difference distance I have and how many points should be like a > 'control value' for 'prunedinv' routine? The RV is not the incorrectness of the projection, but the difference between the original and realigned data (i.e. before and after). If it were zero, then realigning would not have an effect. So "RV" is not a good name, it is "before-after difference". A large helmet shift probably fits with a large before-after difference. Various differences can be shown, i.e. "original->brain->original" and "original->brain->template", and also "original->brain->template- >brain->original". I hope that these numbers are now more clear. I cannot tell you what a good value is for the cfg.pruneration option. You can set it between 0 (no pruning) and 1 (all except the largest component will be pruned/removed). Perhaps other people on the FT list can tell you about their experience with this setting. best regards, Robert From litvak at TX.TECHNION.AC.IL Wed Oct 4 15:15:41 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Wed, 4 Oct 2006 14:15:41 +0100 Subject: Signal2 format import In-Reply-To: <2093A833-C89D-4DB0-9D53-FB43A9DAF4A2@fcdonders.ru.nl> Message-ID: Hi Robert and everyone, I am starting a new project and I'd like to import to FT data in Signal (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab library that can read the files but I wonder whether anybody has implemented the conversion all the way to FT or at least close to it. Maybe Biosig can read it (I haven't tried yet)? Any thoughts would be appreciated. Thanks, Vladimir From litvak at TX.TECHNION.AC.IL Wed Oct 4 18:11:08 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Wed, 4 Oct 2006 17:11:08 +0100 Subject: Signal2 format import In-Reply-To: <001901c6e7b7$3125cc70$ec463ec1@sobell.ion.ucl.ac.uk> Message-ID: A correction to my previous post. The files come with extension *.SMR and not *.CED. Vladimir -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Vladimir Litvak Sent: Wednesday, October 04, 2006 2:16 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: [FIELDTRIP] Signal2 format import Hi Robert and everyone, I am starting a new project and I'd like to import to FT data in Signal (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab library that can read the files but I wonder whether anybody has implemented the conversion all the way to FT or at least close to it. Maybe Biosig can read it (I haven't tried yet)? Any thoughts would be appreciated. Thanks, Vladimir From r.oostenveld at FCDONDERS.RU.NL Wed Oct 4 18:19:38 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 4 Oct 2006 18:19:38 +0200 Subject: Signal2 format import In-Reply-To: <001901c6e7b7$3125cc70$ec463ec1@sobell.ion.ucl.ac.uk> Message-ID: Hi Vladimir, On 4 Oct 2006, at 15:15, Vladimir Litvak wrote: > I am starting a new project and I'd like to import to FT data in > Signal > (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab > library that can read the files but I wonder whether anybody has > implemented > the conversion all the way to FT or at least close to it. Maybe > Biosig can > read it (I haven't tried yet)? Any thoughts would be appreciated. Gijs van Elswijk contributed code to FT for reading continuous channels (are required to all have the same sampling rate) from a system manufactured by "Cambridge Electronic Design" (CED), and the documentation that I got specifies that the files are from the 'Spike2 SON filing system'. In the FT private/filetype function, those are referred to as being type 'ced_son'. However, those files are assumed to have the extension *.smr. I am not sure whether those are the same files, but it sounds like it could be related. Gijs' code is basically the private/read_ced_son.m file, which uses the Neuroshare library (see http://neuroshare.sourceforge.net). There are matlab bindings to the Neuroshare library, i.e. system specific mex files that you have to add to your Matlab path. I hope this helps. If not, then I also know another library for reading SON2 files. But then, I am not yet sure whether that really corresponds to the dataformat that you now have. Robert From litvak at TX.TECHNION.AC.IL Wed Oct 4 20:21:39 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Wed, 4 Oct 2006 19:21:39 +0100 Subject: Signal2 format import In-Reply-To: <3202C65B-3F02-40BC-8403-A52F470BB6A8@fcdonders.ru.nl> Message-ID: Thanks a lot. It works perfectly (at least from the first glance). Best, Vladimir -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Robert Oostenveld Sent: Wednesday, October 04, 2006 5:20 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: Re: [FIELDTRIP] Signal2 format import Hi Vladimir, On 4 Oct 2006, at 15:15, Vladimir Litvak wrote: > I am starting a new project and I'd like to import to FT data in > Signal > (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab > library that can read the files but I wonder whether anybody has > implemented > the conversion all the way to FT or at least close to it. Maybe > Biosig can > read it (I haven't tried yet)? Any thoughts would be appreciated. Gijs van Elswijk contributed code to FT for reading continuous channels (are required to all have the same sampling rate) from a system manufactured by "Cambridge Electronic Design" (CED), and the documentation that I got specifies that the files are from the 'Spike2 SON filing system'. In the FT private/filetype function, those are referred to as being type 'ced_son'. However, those files are assumed to have the extension *.smr. I am not sure whether those are the same files, but it sounds like it could be related. Gijs' code is basically the private/read_ced_son.m file, which uses the Neuroshare library (see http://neuroshare.sourceforge.net). There are matlab bindings to the Neuroshare library, i.e. system specific mex files that you have to add to your Matlab path. I hope this helps. If not, then I also know another library for reading SON2 files. But then, I am not yet sure whether that really corresponds to the dataformat that you now have. Robert From G.vanElswijk at NEURO.UMCN.NL Wed Oct 4 20:38:24 2006 From: G.vanElswijk at NEURO.UMCN.NL (Gijs van Elswijk) Date: Wed, 4 Oct 2006 20:38:24 +0200 Subject: Signal2 format import Message-ID: Hi Vladimir and Robert, The "read_ced_son" code has not been tested with non-continuous Spike2 files. However, recently a colleague of mine has used the Fieldtrip routines to read his non-continuous Spike2 data. It seems to work fine. I have not tested any Signal data files (which are always non-continuous as far as I know). I believe Signal also uses the "CED SON filing system", which means that those files should be readable with the current FT routines. I was planning to add a few small updates to the current code at some point. If necessary, I could combine it with testing/implementing the support for non-continuous Signal/Spike data. Gijs -----Original Message----- From: FieldTrip discussion list on behalf of Vladimir Litvak Sent: Wed 10/4/2006 8:21 PM To: FIELDTRIP at NIC.SURFNET.NL Cc: Subject: Re: [FIELDTRIP] Signal2 format import Thanks a lot. It works perfectly (at least from the first glance). Best, Vladimir -----Original Message----- From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Robert Oostenveld Sent: Wednesday, October 04, 2006 5:20 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: Re: [FIELDTRIP] Signal2 format import Hi Vladimir, On 4 Oct 2006, at 15:15, Vladimir Litvak wrote: > I am starting a new project and I'd like to import to FT data in > Signal > (a.k.a. Spike2) format (files with extension *.ced). There is a Matlab > library that can read the files but I wonder whether anybody has > implemented > the conversion all the way to FT or at least close to it. Maybe > Biosig can > read it (I haven't tried yet)? Any thoughts would be appreciated. Gijs van Elswijk contributed code to FT for reading continuous channels (are required to all have the same sampling rate) from a system manufactured by "Cambridge Electronic Design" (CED), and the documentation that I got specifies that the files are from the 'Spike2 SON filing system'. In the FT private/filetype function, those are referred to as being type 'ced_son'. However, those files are assumed to have the extension *.smr. I am not sure whether those are the same files, but it sounds like it could be related. Gijs' code is basically the private/read_ced_son.m file, which uses the Neuroshare library (see http://neuroshare.sourceforge.net). There are matlab bindings to the Neuroshare library, i.e. system specific mex files that you have to add to your Matlab path. I hope this helps. If not, then I also know another library for reading SON2 files. But then, I am not yet sure whether that really corresponds to the dataformat that you now have. Robert From r.oostenveld at FCDONDERS.RU.NL Thu Oct 5 11:05:42 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 5 Oct 2006 11:05:42 +0200 Subject: Signal2 format import In-Reply-To: <87F49DED9808BB438F539227CB809111179417@exchange_smtp.umcn.nl> Message-ID: Hi Gijs and Vladimir, On 4 Oct 2006, at 20:38, Gijs van Elswijk wrote: > The "read_ced_son" code has not been tested with non-continuous > Spike2 files. However, recently a colleague of mine has used the > Fieldtrip routines to read his non-continuous Spike2 data. It seems > to work fine. I have not tested any Signal data files (which are > always non-continuous as far as I know). The preprocessing function of Fieldtrip always assumes that data is continuous, i.e. all data samples are numbered as if they were continuous. The definetrial function has to take care of trial boundaries, and definetrial (or your own trialfun) should ensure that the datasegments of interest do not cross trial boundaries. However, if you use filter padding in preprocessing, then your segments of interest (i.e. the "trl" matrix from definetrial) are extended on both sides, and then it may happen that the padded segment extends over a trial boun. To catch those situations, the read_fcdc_data function will check whether the requested data extends over trial boundaries in a discontinuous file (and give an error if it does). So by default in the case of real non-continuous data, the read_fcdc_data function should catch situations where it tries to read data that crosses a trial boundary. However, that will only work if the header (obtained from read_fcdc_header) correctly specifies it that the data is trial based. You may want to check that in the read_ced_con importer. In some cases, trial-based data can also be interpreted as continuous, e.g. when you acquire CTF data in pseudo-continuous mode. The file then contains trials, but there are no holes between them. In that case, you should use cfg.datatype='continuous' in preprocessing (and in the artifact detection functions). That option tells the read_fcdc_data function that it should NOT do the trial boundary check. best Robert From roel.willems at FCDONDERS.RU.NL Fri Oct 6 11:03:50 2006 From: roel.willems at FCDONDERS.RU.NL (Roel Willems) Date: Fri, 6 Oct 2006 11:03:50 +0200 Subject: two way anova Message-ID: Dear all, I've got a quick and easy question: Is there a straightforward way of doing a 2 way anova (e.g. with factors regions of interest (grouped electrodes) and conditions) of freq data using the new statistics_stats function? All the best, Roel -- Roel Willems, PhD student Radboud University Nijmegen F.C. Donders Centre for Cognitive Neuroimaging Kapittelweg 29 6525 EK Nijmegen tel. +31243668065 www.fcdonders.ru.nl From r.oostenveld at FCDONDERS.RU.NL Fri Oct 6 15:53:53 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 6 Oct 2006 15:53:53 +0200 Subject: two way anova In-Reply-To: <45261BF6.2070002@fcdonders.ru.nl> Message-ID: Hi Roel, On 6 Oct 2006, at 11:03, Roel Willems wrote: > Is there a straightforward way of doing a 2 way anova (e.g. with > factors regions of interest (grouped electrodes) and conditions) of > freq data using the new statistics_stats function? No, the statistics_montecarlo, analytic annd stats function all implement a massive univariate statistic (with multiple comparison correction). So ROIs (channels) cannot be used as factor. You can use the matlab anova2 or anovaN function on the command line. However, you should be aware that power spectra do not always mix linearly, depending on what the underlying assumption is over the generators. Hence you cannot always test for interactions (main effects is not a problem). There are workarounds, we could discuss that next week. best Robert From Brian.Roach at YALE.EDU Sat Oct 7 00:04:01 2006 From: Brian.Roach at YALE.EDU (Brian Roach) Date: Fri, 6 Oct 2006 18:04:01 -0400 Subject: freqanalysis_wltconvol.m In-Reply-To: Message-ID: Markus, I appreciate this answer, but I would like to clarify some of your points to be sure I have completely absorbed them. Here is my example: 1000Hz sample rate for the acquired data 4000ms epochs centered on an event (-2000ms before the event to 1999 after the event) cfg = output: 'pow' method: 'wltconvol' foi: [1x60 double] width: 6 gwidth: 3 toi: [1x1000 double] where foi is 1 to 60Hz (in 1Hz steps), and toi is -.5s to .5s (in 1ms steps) I like that 1Hz is not plotted (NaN) values, since you cannot get 6 cycles of 1Hz data in my 4s epoch size. Having run this, I am still uncertain about how gwidth influences the data. Does a smaller gwidth just widen the bell curve of the gaussian envelope? Is there a trend, such as the higher the gwidth, the better the time resolution (because the wavelet has a sharper rise and fall time)? In my case, does sf = 2Hz/6Hz or 1/3Hz? I don't think I have these values right, and since they influence temporal domain and spectral bandwidth, it is important that I know what is right. It seems like if my interpretation of your e-mail is correct, then each frequency bin consists of that frequency +/-.167 or (1/6) Hz. In my example above, my 2Hz value would then consist of data from 1.8333 to 2.1667Hz. This would mean that there are gaps in the spectral data and a smaller number of cycles or smaller width would lead to larger bandwidth (i.e. decreasing frequency resolution). What do you think? Also, does fieldtrip have a function that gives "phase locking factor" or inter-trial coherence (ITC)? Thank you very much for your help. Brian At 03:59 AM 10/2/2006, Markus Siegel wrote: >Dear Brian, > >cfg.width determines in cycles the width of the Morlet-wavelet as the >standard deviation of the underlying gaussian (often termed "q"). One >can either use a fixed q for all frequencies by giving only one >number in cfg.width, or one can use a different q for each frequency >of interest with a vector in cfg.width of the same length as cfg.foi. >"help freqanalysis_wltconvol" gives you the relationship between >cfg.width (width) , the frequency of interest (f0) and the standard- >deviation (resolution) of the wavelet-transform in the temporal (st) >and spectral (sf) domain: > >The standard deviation in the frequency domain (sf) at frequency f0 is >defined as: sf = f0/width >The standard deviation in the temporal domain (st) at frequency f0 is >defined as: st = width/f0 = 1/sf > >The spectral bandwidth (in standard deviations, Hz) of the time- frequency >transform can thus be computed as: >bw = cfg.foi ./ cfg.width; > >The parameter cfg.gwidth determines the length of the wavelet-kernel >used in standard deviations of the underlying gaussian. In other >words, it specifies over how many standard deviations the gaussian is >estimated for the morlet-wavelet in both directions. This does in >principle not influence the spectro-temporal resolution of the >transform, but determines its precision because the gaussian is non- zero >at the edges. Therefore, small values (e.g. <2) lead to edge >effects in the transform. The full length of the 'longest' wavelet at >the lowest frequency cfg.foi(1) is thus computed as: > >2 * cfg.gwidth (cfg.width(1) ./ cfg.foi(1)) > >In freqanalysis_wltconvol, the wavelet transform is implemented by >multiplication in the frequency domain which is computationally more >efficient than convolution in the temporal domain. However, >technically the transform is well described as a convolution of the >time-series with a complex Morlet-wavelet (complex sinusoid with a >gaussian envelope) as e.g. provided in Tallon-Baudry et al., J >Neurosci 1997. > >Best, >Markus > >Am 29.09.2006 um 18:52 schrieb Brian Roach: > > >>Dear FieldTrip users, >> >>I have been playing with the freqanalysis_wltconvol function in >>hopes of using the morlet wavelet time frequency analysis on some >>eeg data. I have been able to get it running, and I find that it >>works very quickly, which is great. However, I am hoping some >>users or F.T. programmers can explain some of the function inputs >>and processing. The cfg example is as follows: >> >>% cfg.method = 'wltconvol'; >>% cfg.foi = 1:1:100; >>% cfg.width = 7; >>% or >>% cfg.width = linspace(5,10,length(cfg.foi)); >>% cfg.toi = 0:0.1:2; >>% cfg.gwidth = 3; >> >>I believe that the cfg.width specifies the number of wave cycles >>used in each frequency's wavelet analysis (so at 2Hz, 7 cycles >>spans 3500ms of data, right?). Maybe this is not correct, because >>I do not seem to get the frequencies as low as I would expect given >>my data epoch length. Perhaps this has to do with the cfg.gwidth >>parameter, which I do not think I completely understand - what is it? >> >>Also, we do not have the matlab wavelet toolbox, and it appears >>that it is not required, but how is the morlet wavelet >>implemented? As I look through the code I see calls to fft, ifft, >>and fftshift, but I wonder how I can give a good technical >>description of this process if I find results in a larger data set. >> >>Finally, is there a function or a way to compute the frequency >>bandwidth based on the cfg inputs, or is there a fix frequency >>bandwith for each foi here? I am sure I am confusing a number of >>things here, so no response is too simple. >> >>Thanks for any advice, please let me know if there is more >>information I can give or if I can clarify my questions. >> >>Brian > From Jan.Schoffelen at FCDONDERS.RU.NL Mon Oct 9 08:31:58 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Mon, 9 Oct 2006 08:31:58 +0200 Subject: Fieldtrip question from Piers C In-Reply-To: <4523.144.32.162.118.1160130197.squirrel@psycix.york.ac.uk> Message-ID: Dear Piers, Since I am not a big wavelet-analysis expert, I forward this reply to the fieldtrip-mailinglist. Recently there has been a thread concerning this type of analysis. (To subscribe, please have a look at: http://www.ru.nl/fcdonders/fieldtrip/, and follow the links to the discussion list; there's a thread on freqanalysis_wltconvol) I'd like to give you a global idea of what's going on with your analysis, for the details I'd like to refer to Markus' and Brian's discussion. The NaNs in your spectrogram are the consequence of your configuration-settings, and your data length. Only at frequencies and time-points where the wavelet-kernel completely covers your data, an estimate is returned. You could play around a bit with your cfg.width, and cfg.gwidth parameters to change this. Yours, Jan-Mathijs -----Original Message----- From: p.cornelissen at psych.york.ac.uk [mailto:p.cornelissen at psych.york.ac.uk] Sent: Friday, October 06, 2006 12:23 PM To: Jan Mathijs Schoffelen Subject: RE: Fieldtrip question from Piers C Dear Jan-Mathijs Thanks for this advice. It turns out that there is an easy solution in the form of a commandline programme called newDS (this is either a CTF thing, or something written by the team at Aston) which allows one to incorporate a virtual electrode dataset (defined by a SAM weights file) into a DS file. Then, when reading into Fieldtrip, you have to include the 'V0' in the line: cfg.channel = {'MEG' 'STIM' 'V0'}; However, I have a new question. I ran the following wavelet analysis on a virtual electrode channel dataset: cfg1 = []; cfg1.output = 'pow'; cfg1.sgn = 'MEG'; cfg1.method = 'wltconvol'; cfg1.channel = 'V0'; cfg1.width = 5; % Width of wavelet cfg1.gwidth = 5; cfg1.foi = 1:1:50; cfg1.toi = -0.2:0.01:0.7; WVLT = freqanalysis(cfg1, raw); Created a suingle plot as follows. cfg2 = []; cfg2.baseline = [-0.2 0.0]; cfg2.baselinetype = 'relative'; %cfg2.baseline = 'no'; %cfg2.baselinetype = 'absolute'; cfg2.zlim = 'maxmin'; cfg2.xlim = [-0.2 0.7]; cfg2.ylim = [1 35]; cfg2.channel = 'V0'; singleplotTFR(cfg2, WVLT); ... and obtained the result that is attached as a PNG file to this email. It seems as if the plot has been thresholded/masked in a way to exclude values that are (probably) poorly estimated - or something like that. So, please can you advise what rules govern this exclusion/masking, and how they can either be switched off, or the analysis/data collection carried out in such a way that they are not invoked. Thanks very much again Piers > Dear Piers, > > First of all, I took the liberty to include as a CC to this mail the > FieldTrip discussion list. It might be that some of its members could > positively contribute to answering your questions. You can subscribe to > this > list on the fieldtrip-website. > > Anyway, currently there is no support for reading in SAM weights files > into > fieldtrip. The most important reason for us not having implemented it, is > that we do our source estimation in fieldtrip directly. Perhaps anyone > already has an implementation to directly read in your SAM weights into > matlab (hence the cc to the discussion list). As soon as those weights are > available, it is pretty straightforward to create virtual channel data and > do the subsequent analysis within fieldtrip. > Otherwise a reading routine for SAM weights would be a valuable > contribution > to the code. > > Another approach would be to use fieldtrip's beamforming algorithm to > create > your virtual channels. The 'lcmv'-algorithm is not all too different from > SAM, so you could try this on your specified voxels of interest. > > There is a tutorial on the frequency-domain beamformer on the web-site. > The > time-domain beamformer needs a slightly different configuration and > input-data. > > 1 you should use timelockanalysis to compute the covariance of your > bandpass-filtered data. > 2 then you can call sourceanalysis, with the output of timelockanalysis as > an input, in combination with a configuration-structure. > > Key-elements of this configuration would be: > cfg.method = 'lcmv'; > cfg.pos = Nx3 matrix with x,y,z coordinates of your virtual channels > cfg.reducerank = 2; (necessary for comparability with SAM, and also to > give > reasonable results in the first place) > cfg.hdmfile = .hdm file specifying the forward model used > > ...and I guess some other stuff as well. > > Yours, > > Jan-Mathijs > > > > -----Original Message----- > From: p.cornelissen at psych.york.ac.uk > [mailto:p.cornelissen at psych.york.ac.uk] > > Sent: Friday, September 15, 2006 2:54 PM > To: Jan.Schoffelen at fcdonders.ru.nl > Subject: Fieldtrip ? from Piers C > > > Dear Fieldtrip team, > > First - thanks for your excellent software! > > I hope its OK for me to ask you a Fieldtrip question. > > We have data from an experiment using Aston (UK) universitie's old 151 > channel CTF system, and we have used the CTF tools to extract a set of > virtual electrodes, selected on the basis of a robust group SAM analysis. > What we would really like to do is to use our SAM weights files for these > virtual electrodes, to define specific channels in Fieldtrip so that we > can create and compare time*frequency plots from the virtual electrodes in > Fieldtrip. > > Any advice on how to do this (preferably by way of example code)would be > deeply appreciated > > Regards > > Piers Cornelissen > > > > > > > > > > > > > > From m.siegel at UKE.UNI-HAMBURG.DE Mon Oct 9 11:05:27 2006 From: m.siegel at UKE.UNI-HAMBURG.DE (Markus Siegel) Date: Mon, 9 Oct 2006 11:05:27 +0200 Subject: freqanalysis_wltconvol.m In-Reply-To: <6.1.2.0.2.20061006142513.01c9ecf0@email.med.yale.edu> Message-ID: Hi Brian, On Oct 7, 2006, at 12:04 AM, Brian Roach wrote: > Here is my example: > 1000Hz sample rate for the acquired data > 4000ms epochs centered on an event (-2000ms before the event to > 1999 after the event) > > cfg = > > output: 'pow' > method: 'wltconvol' > foi: [1x60 double] > width: 6 > gwidth: 3 > toi: [1x1000 double] > > where foi is 1 to 60Hz (in 1Hz steps), and toi is -.5s to .5s (in > 1ms steps) > > I like that 1Hz is not plotted (NaN) values, since you cannot get 6 > cycles of 1Hz data in my 4s epoch size. Having run this, I am > still uncertain about how gwidth influences the data. Does a > smaller gwidth just widen the bell curve of the gaussian envelope? > Is there a trend, such as the higher the gwidth, the better the > time resolution (because the wavelet has a sharper rise and fall > time)? cfg.gwidth does not influence the width of the gaussian envelope and thus does not have an effect on the temporal or spectral resolution. The cfg.gwidth parameter determines the length of the morlet-wavelet but not its shape. The gaussian envelope implies that the wavelet tails converge towards zero but are not really zero at the edges. Thus one has to decide where to crop the wavelet-kernel. The gwidth parameter determines the cropped length in standard deviations of the gaussian envelope. For cfg.gwidth = 3 the morlet-wavelet is thus estimated for the central +/- 3 standard deviations of the gaussian envelope. Hence, smaller gwidth parameter lead to edges of the wavelets that become more "non-zero" which lead to stronger edge effects and more noisy picture of your time-frequency transform. Run your analysis with the above parameters but cfg.gwidth = 1. If you compare the output to that of cfg.gwidth = 3 this effect should become clear. > In my case, does sf = 2Hz/6Hz or 1/3Hz? I don't think I have these > values right, and since they influence temporal domain and spectral > bandwidth, it is important that I know what is right. It seems > like if my interpretation of your e-mail is correct, then each > frequency bin consists of that frequency +/-.167 or (1/6) Hz. In > my example above, my 2Hz value would then consist of data from > 1.8333 to 2.1667Hz. This would mean that there are gaps in the > spectral data and a smaller number of cycles or smaller width would > lead to larger bandwidth (i.e. decreasing frequency resolution). > What do you think? The spectral bandwidth of your time-frequency tranform is not constant but a function of frequency. For your example, the spectral bandwidth (in standard deviations, Hz) is computed as: bandwidth = cfg.foi ./ cfg.width; For a constant cfg.width, the spectral bandwidth increases linearly with the frequency of interest. While at 18 Hz you have a spectral bandwidth of 3 Hz, the bandwidth at 60 Hz is 10 Hz. > Also, does fieldtrip have a function that gives "phase locking > factor" or inter-trial coherence (ITC)? Not that I know. However, you could compute ITC yourself based on the complex output from freqanalysis_mtmconvol run with cfg.output = 'fourier'. Best, Markus From jaredvs at GMAIL.COM Tue Oct 10 22:38:53 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Tue, 10 Oct 2006 22:38:53 +0200 Subject: Incorrect coordinates? Message-ID: Hi there, I've been analyzing the output of BESA's multiple source beamformer (MEG data) using Fieldtrip, and it appears that there is a problem with the coordinate system. The results of volumewrite, when overlayed with the spm T1.img, appear to be substantially outside of the brain, and in oddly shaped patterns that suggest an error in assigning statical values to the correct coordinates. The analysis protocol used was as follows (we only had MRI's for 2 subjects, one of these was used for all subject who did not have MRI's--for convenience I simply use one mri for all subjects in the example below): mri=read_fcdc_mri('mri.img'); fdir=pwd; files=dir([fdir filesep '*.dat']); %these are the BESA .dat files sinterp_cfg.interpmethod='cubic'; sinterp_cfg.sourceunits='mm'; norm_cfg.template=which('T1.mnc'); norm_cfg.parameter='all'; norm_cfg.coordinates='spm'; norm_cfg.name='high_alpha_beamformer_normed'; for k=1:length(files) src(k)=besa2fieldtrip([fdir filesep files(k).name]); interp(k)=sourceinterpolate(sinterp_cfg,src(k),mri); volume(k)=volumenormalise(norm_cfg,interp(k)); end grav_cfg.parameter='pow'; grav_cfg.keepindividual='yes'; grandavg=sourcegrandaverage(grav_cfg,volume(1),volume(2),volume(3),volume (4),volume(5),volume(6),volume(7),volume(8),volume(9),volume(10),volume (11),volume(12)); stat_cfg.parameter='pow'; stat_cfg.method='parametric'; stat_cfg.statistic = 'zero-baseline'; stat_cfg.bonferoni = 'no'; stat_cfg.threshold=0.01; stat=sourcestatistics_parametric(stat_cfg,grandavg); write_cfg.parameter='tscore'; write_cfg.filename='alpha'; write_cfg.filetype='spm'; write_cfg.coordinates='spm'; write_cfg.scaling='no'; volumewrite(write_cfg,stat) When I overlay the .img on the MNI T1.img using MRICro, there's a lot of data outside of the brain. Any suggestions as to where something may have gone wrong would be greatly appreciated. I would happily provide the resulting alpha.img and alpha.hdr, though as the .img is 55MB I won't attach it to this message. Thanks very much, Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 From r.oostenveld at FCDONDERS.RU.NL Wed Oct 11 09:36:07 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 11 Oct 2006 09:36:07 +0200 Subject: Incorrect coordinates? In-Reply-To: Message-ID: Hi Jared, On 10 Oct 2006, at 22:38, Jared Van Snellenberg wrote: > I've been analyzing the output of BESA's multiple source beamformer > (MEG > data) using Fieldtrip, and it appears that there is a problem with the > coordinate system. The results of volumewrite, when overlayed with > the spm > T1.img, appear to be substantially outside of the brain, and in oddly > shaped patterns that suggest an error in assigning statical values > to the > correct coordinates. I suspect a misalignment between your functional and anatomical data. > mri=read_fcdc_mri('mri.img'); read_fcdc_mri does not do automatic alignment, but just returns the data with the coordinate system as defined in the mri file. Do you know what the coordinate system is to which the anatomical MRI is aligned? I.e. where is the origin [0,0,0] in anatomical terms? > for k=1:length(files) > src(k)=besa2fieldtrip([fdir filesep files(k).name]); > interp(k)=sourceinterpolate(sinterp_cfg,src(k),mri); > volume(k)=volumenormalise(norm_cfg,interp(k)); > end And what is the coorrdinate system in which the functional source data is described? I.e. at which location in the head would a dipole at the coordinate [0 0 0] be? For sourceinterpolate the two input arguments (functional + anatomical data) should be defined w.r.t. the same coordinate system. I suggest that you use sourceplot for debugging, e.g. something like cfg =[] cfg.funparameyter = 'pow' % don't know how the functional data in src is called, probably 'pow' cfg.location = 'interactive' % or try [0 0 0] sourceplot(cfg, src(1)); % there is no anatomy, only functional data and cfg =[] cfg.funparameyter = [] % no functional data, only anatomy cfg.location = 'interactive' % or try [0 0 0] sourceplot(cfg, mri); that should give you both volumes (in seperate windows) and you can compare whether they seem to be aligned. You could use the volumerealign(*) function for manual realignment of the anatomical MRI. Or you can use MRIcro. Also have a look at http://www2.ru.nl/fcdonders/fieldtrip/doku.php? id=fieldtrip:documentation:frequently_asked_questions#how_are_the_differ ent_head_and_mri_coordinate_systems_defined I hope this helps. Robert *) that is a completely new function that was added yesterdays to fieldtrip, hence you should fetch the latest version from ftp From jaredvs at GMAIL.COM Wed Oct 11 19:16:47 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Wed, 11 Oct 2006 13:16:47 -0400 Subject: Incorrect coordinates? In-Reply-To: <901A6BEF-A31F-41ED-8311-BA17061BED47@fcdonders.ru.nl> Message-ID: Hi Robert, Thanks very much, it looks like you're right. While plotting the src data just came up with an empty image, BESA is supposed to output coordinates according to the Talairach atlas, so [0 0 0] should be on the anterior commisure. Plotting the structural MRI shows that [0 0 0] is clearly *not*on the AC, so it needs to be realigned. I'll try volumerealign now. -Jared On 10/11/06, Robert Oostenveld wrote: > > Hi Jared, > > On 10 Oct 2006, at 22:38, Jared Van Snellenberg wrote: > > I've been analyzing the output of BESA's multiple source beamformer > > (MEG > > data) using Fieldtrip, and it appears that there is a problem with the > > coordinate system. The results of volumewrite, when overlayed with > > the spm > > T1.img, appear to be substantially outside of the brain, and in oddly > > shaped patterns that suggest an error in assigning statical values > > to the > > correct coordinates. > > I suspect a misalignment between your functional and anatomical data. > > > mri=read_fcdc_mri('mri.img'); > > read_fcdc_mri does not do automatic alignment, but just returns the > data with the coordinate system as defined in the mri file. > > Do you know what the coordinate system is to which the anatomical MRI > is aligned? I.e. where is the origin [0,0,0] in anatomical terms? > > > for k=1:length(files) > > src(k)=besa2fieldtrip([fdir filesep files(k).name]); > > interp(k)=sourceinterpolate(sinterp_cfg,src(k),mri); > > volume(k)=volumenormalise(norm_cfg,interp(k)); > > end > > And what is the coorrdinate system in which the functional source > data is described? I.e. at which location in the head would a dipole > at the coordinate [0 0 0] be? > > For sourceinterpolate the two input arguments (functional + > anatomical data) should be defined w.r.t. the same coordinate system. > > I suggest that you use sourceplot for debugging, e.g. something like > > cfg =[] > cfg.funparameyter = 'pow' % don't know how the functional > data in src is called, probably 'pow' > cfg.location = 'interactive' % or try [0 0 0] > sourceplot(cfg, src(1)); % there is no anatomy, only > functional data > > and > > cfg =[] > cfg.funparameyter = [] % no functional data, only anatomy > cfg.location = 'interactive' % or try [0 0 0] > sourceplot(cfg, mri); > > that should give you both volumes (in seperate windows) and you can > compare whether they seem to be aligned. You could use the > volumerealign(*) function for manual realignment of the anatomical > MRI. Or you can use MRIcro. Also have a look at > http://www2.ru.nl/fcdonders/fieldtrip/doku.php? > id=fieldtrip:documentation:frequently_asked_questions#how_are_the_differ > ent_head_and_mri_coordinate_systems_defined > > I hope this helps. > Robert > > *) that is a completely new function that was added yesterdays to > fieldtrip, hence you should fetch the latest version from ftp > -- Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.oostenveld at FCDONDERS.RU.NL Thu Oct 12 09:21:08 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 12 Oct 2006 09:21:08 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610111016y5bae7549o382682194f7e034b@mail.gmail.com> Message-ID: On 11 Oct 2006, at 19:16, Jared Van Snellenberg wrote: > Thanks very much, it looks like you're right. good. > While plotting the src data just came up with an empty image In sourceplot cfg.funparameter should specify the parameter that should be plotted, and that should work without anatomy as well. Looking back at your own cfg in the previous mail, I do think that it should be 'pow'. However, I made a typo in my previous reply (cfg.funparameyter). Robert From marco.buiatti at GMAIL.COM Fri Oct 13 19:03:36 2006 From: marco.buiatti at GMAIL.COM (Marco Buiatti) Date: Fri, 13 Oct 2006 19:03:36 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: <82A11B61-8049-432A-B1CF-43764D723ED3@fcdonders.ru.nl> Message-ID: Dear Robert and Eric (and dear FieldTrippers), thank you for your efficient response on my summer question. I followed your advices and tried to use the function timelockstatistics starting from the canonical comparison of ERPs within subjects but I had some problems. Here I report my attempt to perform cluster randomization analysis on ERPs relative to two conditions (W and PW). For simplicity I took just 2 subjects. I report here all the steps from loading eeglab datasets to computing cluster randomization analysis to be sure that I am following the correct procedure. The problem is ??? Undefined variable "data" or class "data.biol". I used yesterday's FieldTrip version 20061012. Can you help me with this? Thank you in advance, Marco % Loading eeglab datasets EEG50PW_s2 = pop_loadset( '02_ev_hpf0.2_lpf35_ep_soa50PW.set', '/home/Pinserm/people/joachim/analysis/02/'); EEG50W_s2 = pop_loadset( '02_ev_hpf0.2_lpf35_ep_soa50W.set', '/home/Pinserm/people/joachim/analysis/02/'); EEG50PW_s4 = pop_loadset( '04_ev_hpf0.2_lpf35_ep_soa50PW.set', '/home/Pinserm/people/joachim/analysis/04/'); EEG50W_s4 = pop_loadset( '04_ev_hpf0.2_lpf35_ep_soa50W.set', '/home/Pinserm/people/joachim/analysis/04/'); % Transform to FieldTrip format data50PW_s2 = eeglab2fieldtrip( EEG50PW_s2, 'timelockanalysis' ); >> data50PW_s2 data50PW_s2 = label: {129x1 cell} fsample: 250 elec: [1x1 struct] avg: [129x523 single] var: [129x523 single] time: [1x523 double] dimord: 'chan_time' cfg: [1x1 struct] data50W_s2 = eeglab2fieldtrip( EEG50W_s2, 'timelockanalysis' ); data50W_s4 = eeglab2fieldtrip( EEG50W_s4, 'timelockanalysis' ); data50PW_s4 = eeglab2fieldtrip( EEG50PW_s4, 'timelockanalysis' ); % Computing grandaverage for each condition cfg =[]; cfg.keepindividual = 'yes'; GA_50PW = timelockgrandaverage(cfg,data50PW_s2,data50PW_s4); GA_50W = timelockgrandaverage(cfg,data50W_s2,data50W_s4) GA_50W = label: {129x1 cell} fsample: 250 avg: [129x523 double] var: [129x523 double] time: [1x523 double] individual: [2x129x523 double] dimord: 'subj_chan_time' cfg: [1x1 struct] % Loading channel names and positions data = eeglab2fieldtrip(EEG50PW_s2,'chanloc'); GA_50W.elec=data.elec; GA_50PW.elec=data.elec; % Setting cfg for timelockstatistics cfg=[]; cfg.statistic='depsamplesT'; cfg.numrandomization = 500; cfg.alpha=0.05; cfg.clusterstatistics='maxsum'; cfg.clusterthreshold = 'parametric'; cfg.clusteralpha = 0.05; cfg.neighbourdist=4; cfg.neighbours = neighbourselection(cfg,GA_50PW); cfg.latency=[0 0.5]; cfg.method = 'montecarlo'; stat = timelockstatistics(cfg,GA_50W,GA_50PW); Using the electrode configuration from the dataset. there are on average 128.0 neighbours per channel selected 129 channels selected 126 time bins selected 1 frequency bins ??? Undefined variable "data" or class "data.biol". Error in ==> fieldtrip-20061012/private/prepare_design at 92 nrepl=size(data.biol,1); Error in ==> fieldtrip-20061012/private/statistics_wrapper at 212 [cfg] = prepare_design(cfg); Error in ==> timelockstatistics at 50 [stat] = statistics_wrapper(cfg, varargin{:}); On 8/29/06, Robert Oostenveld wrote: > Dear Marco > > On 23 Aug 2006, at 14:53, Eric Maris wrote: > >> 2) Is there a way to compute the null distribution by considering > >> all possible reassignments of the conditions instead of the Monte > >> Carlo approximation - in this case it would be feasible because > >> all possible reassignments should be 2^9, right? > > This is not possible with clusterrandanalysis. However, this is > > possible with one of the new statistics functions in Fieldtrip that > > will replace both clusterrandanalysis and sourcestatistics. The > > function of interest for you is timelockstatistics, and you should > > have a look at the help information for the lower-level function > > statistics_montecarlo (which is called by timelockstatistics). > > However, provided that you use more than 500 draws from the > > permutation distribution, don't expect major changes in the output. > We have an in-house version of fieldtrip, and an external FTP > version. The in-house version is always slightly more advanced than > the external version. Even though the timelockstatistics function was > already included in recent external fieldtrip versions (the daily zip > files) on the Donders FTP server, I just noticed that the underlying > statistics_montecarlo function that Eric is referring to was still > missing from the zip file. I have now also tagged that function (and > some further subfunctions on which it depends) to be released in the > external fieldtrip release. You should be able to use the > timelockstatistics function with both the montecarlo and the complete > permutation (cfg.numrandomization='all') based estimaes for the > cluster statistics. > > I hope it works with the new function, if not then don't hesitate to > contact us. > > Robert > > > > -- Marco Buiatti - Post Doc ************************************************************** Cognitive Neuroimaging Unit - INSERM U562 Service Hospitalier Frederic Joliot, CEA/DRM/DSV 4 Place du general Leclerc, 91401 Orsay cedex, France Telephone: +33 1 69 86 77 65 Fax: +33 1 69 86 78 16 E-mail: marco.buiatti at gmail.com Web: www.unicog.org *************************************************************** From jaredvs at GMAIL.COM Sun Oct 15 00:12:48 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Sat, 14 Oct 2006 18:12:48 -0400 Subject: Incorrect coordinates? In-Reply-To: <8528858E-5C8B-46FA-B12B-461539BA59C3@fcdonders.ru.nl> Message-ID: Hi Robert, I've rerun the analysis with mri's that were reoriented to MNI, and the same problem has emerged. The typo you noted in your last email was indeed the reason for the empty src plot. Plotting src, interp, volume, and grandavg, everything looks ok. The 'pow' parameter values all appear within the brain. The tscore and p values in stat, however, are all messed up. I've attached .bmp's from using sourceplot on grandavg and stat to this email. The quality is poor (matlab's figure window doesn't ever save bmp's very well), but it should demonstrate the problem clearly. Note all the large values outside of the brain. Any comments you have would be greatly appreciated. I've considered just masking out everything that's not in the brain, but I'm not confident that the within-brain values are accurate. Thanks, -Jared On 10/12/06, Robert Oostenveld wrote: > > On 11 Oct 2006, at 19:16, Jared Van Snellenberg wrote: > > Thanks very much, it looks like you're right. > good. > > > While plotting the src data just came up with an empty image > > In sourceplot cfg.funparameter should specify the parameter that > should be plotted, and that should work without anatomy as well. > Looking back at your own cfg in the previous mail, I do think that it > should be 'pow'. However, I made a typo in my previous reply > (cfg.funparameyter). > > Robert > -- Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: grandavg.bmp Type: image/bmp Size: 236278 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: stat.bmp Type: image/bmp Size: 236278 bytes Desc: not available URL: From r.oostenveld at FCDONDERS.RU.NL Mon Oct 16 20:16:37 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 16 Oct 2006 20:16:37 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610141512j638067d0g70039058904b6e6@mail.gmail.com> Message-ID: Hi Jared, On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > I've rerun the analysis with mri's that were reoriented to MNI, and > the same problem has emerged. I would guess that the anatomical MRIs themselves do not influence the coordinate system of the source reconstruction. That would influence the interpolation though. If you do source = besa2fieldtrip(filename1) and mri = read_fcdc_mri(filename) then the source structure is defined using the source.pos field that describes the position of each source. SInce in this case the positions are on a regular 3D grid, there is additional structure in the arrangement of source.pos, which is described using source.xgrid, source.ygrid, source.zgrid. If you do tmp = reshape(source.avg.pow, source.dim) you will get a 3D array with along the first dimension the voxels along the x-axis, etc. The 1..Nth voxels along the xasix have the X coordinates source.xgrid(1)..source.xgrid(N). Similar for the Y and Z coordinates. That allows you to determine the coordinate of each voxel. Since the anatomical MRI is typically of much higher resolution, you can use sourceinterpolate which interpolates the source (or stat) volumes onto the voxel locations that are in the anatomical MRI. I.e. sourceinterpolate upsamples the functional data to the anatomical MRI. Normally you would do sourceinterpolate AFTER calling sourcestatistics, since the source positions in all subjects are all based on the same standard realistic head moidel in BESA and hence the source positions in all subjects are the same (please check whether positions are all the same over subjects/conditions). If you work with MEG or with EEG individual headmodels, the source positions in all subjects are all different, which requires sourceanalysis->sourceinterpolate->volumenormalize as shown in the schema for http://www2.ru.nl/fcdonders/fieldtrip/doku.php? id=fieldtrip:documentation:analysis_protocols#source_reconstruction_for_ multiple_subjects > The typo you noted in your last email was indeed the reason for the > empty src plot. Plotting src, interp, volume, and grandavg, > everything looks ok. The 'pow' parameter values all appear within > the brain. The tscore and p values in stat, however, are all messed > up. I've attached .bmp's from using sourceplot on grandavg and stat > to this email. The quality is poor (matlab's figure window doesn't > ever save bmp's very well), but it should demonstrate the problem > clearly. Note all the large values outside of the brain. In your case you should be able to do besa2fieldtrip -> sourcestatistics, and then the source positions with the statistical data on them should stll be the same as the positions with the original functional data on them. After doing the statistics (or after doing sourcegrandaverage), you can interpolate the functional/ statistical data onto the MRI. But since the statistical data and the functional (beamed power) data are on the same coordinates, there should not be a difference between them. > Any comments you have would be greatly appreciated. I've considered > just masking out everything that's not in the brain, but I'm not > confident that the within-brain values are accurate. Looking at the bitmaps, I cannot see teh anatomy, but I do see a brain-shaped outline with some blobs in them. I cannot recognise the problem from these figures, to me they seem ok. The only problem that I can see is the one that you also mention, and that is for the masking. In the original source data (i.e. output from besa2fieldtrip) there is an source.inside and source.outside field. Those should contain the indices of the voxels (linear indices, so voxel [1 1 1] has index 1 and voxel [2 1 1] has index 2...) of the sources that are inside the brain and outside the brain. Only the inside voxels are considered for sourcestatistics and for sourceinterpolation. However, the problem with BESA data is that it does not describe the inside/outside voxels and therefoer by default all voxels are marked as inside. Perhaps you can determine the inside/ outside voxels manually, e.g. source.inside = find(source.avg.pow(:)>eps); source.outside = find(source.avg.pow(:) Message-ID: Hi Marco Your script looks ok. On 13 Oct 2006, at 19:03, Marco Buiatti wrote: > ??? Undefined variable "data" or class "data.biol". > > Error in ==> fieldtrip-20061012/private/prepare_design at 92 > nrepl=size(data.biol,1); > > Error in ==> fieldtrip-20061012/private/statistics_wrapper at 212 > [cfg] = prepare_design(cfg); > > Error in ==> timelockstatistics at 50 > [stat] = statistics_wrapper(cfg, varargin{:}); Yep, that is a known problem (sorry about that). The function prepare_design is not working properly. I suggest to make a design matrix in cfg.design by hand (similar to, but not completely the same as in SPM). It is not difficult, and it will also make you more clear how it works. Please have a look at https://listserv.surfnet.nl/scripts/wa.exe? A2=ind0607&L=FIELDTRIP&P=R3192&I=-3&X=77C04E25A87526C2B4 or if that URL does not work, then search the fieldtrip discussion list archive for the string "cfg.design". best regards, Robert PS note that you can also use timelockstatistics on the 'componentanalysis' part of the EEGLAB data, in that case you cannot use channel clustering, but you still can use timepoint clustering (so cfg.neighbours should be []). You shoudl only do that if the ICA components in the different EEG datasets are spatially the same (or sufficiently similar, e.g. after clustering over subjects in the new EEGLAB). From r.oostenveld at FCDONDERS.RU.NL Mon Oct 16 20:31:15 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 16 Oct 2006 20:31:15 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610141512j638067d0g70039058904b6e6@mail.gmail.com> Message-ID: On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > The quality is poor (matlab's figure window doesn't ever save bmp's > very well), Just a suggestion: instead of exporting to a BMP bitmap (large files with poor quality) or a JPG (lossy, not suited for line drawings), you can export to a PNG bitmap, which is high quality (lossless+full color) and also compressed (small). Try print -dpng filename.png see "help print" for details Robert From Brian.Roach at YALE.EDU Tue Oct 17 23:44:29 2006 From: Brian.Roach at YALE.EDU (Brian Roach) Date: Tue, 17 Oct 2006 17:44:29 -0400 Subject: freqanalysis_wltconvol.m In-Reply-To: <1A240DDA-7643-4C16-820B-B6C0A69BB5DF@uke.uni-hamburg.de> Message-ID: Markus, Thanks for your reply. I believe I am getting a better handle on this function. Regarding phase-locking factor/ITC, couldn't I try to use the complex data within the freqanalysis_wltconvol to calculate these data in a similar method to that in the Tallon-Baudry et. al. '97 gamma paper? The wltconvol function is so similar to that paper's analysis already, it seems like I would only need to divide the complex data by its absolute value. The paper refers to taking the "modulus of this complex value," where the complex value is: Pi(f,f0) = w(t,f0) X si(t,f0)/ | w(t,f0) X si(t,f0) I read this as the dividing the imaginary, sine wave, portion of the wavelet (representing phase angle) at any given time and frequency by its absolute value. Does modulus have the same functionality/meaning as the C++ mod or matlab rem function? Is there interest in phase-locking values in the FieldTrip user community? I am interested in trying to implement what is described above, but it would be nice to have others see the code and test it to be sure I have calculated phase-locking values correctly. Anyone have any thoughts/feelings about this? Thanks, Brian At 05:05 AM 10/9/2006, you wrote: >Hi Brian, > >On Oct 7, 2006, at 12:04 AM, Brian Roach wrote: > >>Here is my example: >>1000Hz sample rate for the acquired data >>4000ms epochs centered on an event (-2000ms before the event to >>1999 after the event) >> >>cfg = >> >> output: 'pow' >> method: 'wltconvol' >> foi: [1x60 double] >> width: 6 >> gwidth: 3 >> toi: [1x1000 double] >> >>where foi is 1 to 60Hz (in 1Hz steps), and toi is -.5s to .5s (in >>1ms steps) >> >>I like that 1Hz is not plotted (NaN) values, since you cannot get 6 >>cycles of 1Hz data in my 4s epoch size. Having run this, I am >>still uncertain about how gwidth influences the data. Does a >>smaller gwidth just widen the bell curve of the gaussian envelope? >>Is there a trend, such as the higher the gwidth, the better the >>time resolution (because the wavelet has a sharper rise and fall >>time)? > >cfg.gwidth does not influence the width of the gaussian envelope and >thus does not have an effect on the temporal or spectral resolution. >The cfg.gwidth parameter determines the length of the morlet-wavelet >but not its shape. The gaussian envelope implies that the wavelet >tails converge towards zero but are not really zero at the edges. >Thus one has to decide where to crop the wavelet-kernel. The gwidth >parameter determines the cropped length in standard deviations of the >gaussian envelope. For cfg.gwidth = 3 the morlet-wavelet is thus >estimated for the central +/- 3 standard deviations of the gaussian >envelope. Hence, smaller gwidth parameter lead to edges of the >wavelets that become more "non-zero" which lead to stronger edge >effects and more noisy picture of your time-frequency transform. Run >your analysis with the above parameters but cfg.gwidth = 1. If you >compare the output to that of cfg.gwidth = 3 this effect should >become clear. > >>In my case, does sf = 2Hz/6Hz or 1/3Hz? I don't think I have these >>values right, and since they influence temporal domain and spectral >>bandwidth, it is important that I know what is right. It seems >>like if my interpretation of your e-mail is correct, then each >>frequency bin consists of that frequency +/-.167 or (1/6) Hz. In >>my example above, my 2Hz value would then consist of data from >>1.8333 to 2.1667Hz. This would mean that there are gaps in the >>spectral data and a smaller number of cycles or smaller width would >>lead to larger bandwidth (i.e. decreasing frequency resolution). >>What do you think? > >The spectral bandwidth of your time-frequency tranform is not >constant but a function of frequency. For your example, the spectral >bandwidth (in standard deviations, Hz) is computed as: > >bandwidth = cfg.foi ./ cfg.width; > >For a constant cfg.width, the spectral bandwidth increases linearly >with the frequency of interest. While at 18 Hz you have a spectral >bandwidth of 3 Hz, the bandwidth at 60 Hz is 10 Hz. > >>Also, does fieldtrip have a function that gives "phase locking >>factor" or inter-trial coherence (ITC)? > >Not that I know. However, you could compute ITC yourself based on the >complex output from freqanalysis_mtmconvol run with cfg.output = >'fourier'. > >Best, >Markus > From Jan.Schoffelen at FCDONDERS.RU.NL Wed Oct 18 09:47:45 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Wed, 18 Oct 2006 09:47:45 +0200 Subject: freqanalysis_wltconvol.m In-Reply-To: <6.1.2.0.2.20061017173241.01def4e0@email.med.yale.edu> Message-ID: Dear Brian, >Regarding phase-locking factor/ITC, couldn't I try to use the complex data >within the freqanalysis_wltconvol to calculate these data in a similar >method to that in the Tallon-Baudry et. al. '97 gamma paper? The wltconvol >function is so similar to that paper's analysis already, it seems like I >would only need to divide the complex data by its absolute value. The >paper refers to taking the "modulus of this complex value," where the >complex value is: >Pi(f,f0) = w(t,f0) X si(t,f0)/ | w(t,f0) X si(t,f0) I would implement the ITC as follows: itc = abs(mean(x./abs(x))); in which x is a vector of complex numbers representing your single-trial observations (in a single channel and a single frequencybin). Markus pointed out that you could use freqanalysis_mtmfft with cfg.output = 'fourier' to obtain these complex numbers, but apparently freqanalysis_wltconvol gives you a complex output as well. The above formula is how it is for example done in Tallon-Baudry '97 >I read this as the dividing the imaginary, sine wave, portion of the >wavelet (representing phase angle) at any given time and frequency by its >absolute value. Beware: a complex number can be represented as: B(cos*x+isin*x), or as A*exp(phi*i). The imaginary part you refer to is indeed the 'sine wave' but is not the whole story about the phase. The phase phi is determined both by the sine part and the cosine part. By normalizing with the absolute value, you divide the complete complex number by its amplitude, i.e. also the cosine part. If you think of it as a polar notation (A*exp(phi*i)), you divide the number by A, leaving a unit vector pointing in a particular direction (as determined by phi). >Does modulus have the same functionality/meaning as the >C++ mod or matlab rem function? The modulus of a complex number is its absolute, i.e. |x|, the corresponding matlab-function is abs(). The functions mod (also exists in matlab) and rem, are concerned with remainders after division, and modulo-stuff, which is similar to remainders >Is there interest in phase-locking values in the FieldTrip user community? >I am interested in trying to implement what is described above, but it >would be nice to have others see the code and test it to be sure I have >calculated phase-locking values correctly. I guess so, hopefully you now have a handle of doing it yourself. Yours, Jan-Mathijs From esther.meeuwissen at FCDONDERS.RU.NL Wed Oct 18 13:04:07 2006 From: esther.meeuwissen at FCDONDERS.RU.NL (Esther Meeuwissen) Date: Wed, 18 Oct 2006 13:04:07 +0200 Subject: cfg.highlight in topoplot Message-ID: Dear Fieldtrip users, Does anyone have suggestions how I can define two different cfg.highlights for 1 topoplot? For instance, to get a topoplot is an ERP diffence wave with channels in positive clusters marked red and channels in negative clusters marked blue. Thanks you in advance. Esther Meeuwissen From marco.buiatti at GMAIL.COM Thu Oct 19 12:13:18 2006 From: marco.buiatti at GMAIL.COM (Marco Buiatti) Date: Thu, 19 Oct 2006 12:13:18 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: Message-ID: Dear Robert, I followed your advice again, and made a (hopefully correct!) design matrix (I agree it clarifies what I am really computing). Now timelockstatistics starts to compute the statistics on the correct number of permutations, but as you can see from the results below, I still had some problems that I do not understand. This time I took three subjects instead of two, but the result does not depend on the subject's number. I also checked that I did not pick up any two identical datasets, and that ERPs are pretty standard (I expect no difference on N1, and difference on P300). Thank you in advance for your help, Marco % loading data from eeglab datasets EEG50PW_s2 = pop_loadset( '02_ev_ep_soa50PW.set','F:\joachim\'); EEG50W_s2 = pop_loadset( '02_ev_ep_soa50W.set','F:\joachim\'); EEG50PW_s4 = pop_loadset( '04_ev_ep_soa50PW.set','F:\joachim\'); EEG50W_s4 = pop_loadset( '04_ev_ep_soa50W.set','F:\joachim\'); EEG50PW_s5 = pop_loadset( '05_ev_ep_soa50PW.set','F:\joachim\'); EEG50W_s5 = pop_loadset( '05_ev_ep_soa50W.set','F:\joachim\'); % Transform to FieldTrip format data50PW{1} = eeglab2fieldtrip( EEG50PW_s2, 'timelockanalysis' ); data50W{1} = eeglab2fieldtrip( EEG50W_s2, 'timelockanalysis' ); data50W{2} = eeglab2fieldtrip( EEG50W_s4, 'timelockanalysis' ); data50PW{2} = eeglab2fieldtrip( EEG50PW_s4, 'timelockanalysis' ); data50W{3} = eeglab2fieldtrip( EEG50W_s5, 'timelockanalysis' ); data50PW{3} = eeglab2fieldtrip( EEG50PW_s5, 'timelockanalysis' ); % Loading channel names and positions data = eeglab2fieldtrip(EEG50PW_s2,'chanloc'); for i=1:3 data50W{i}.elec=data.elec; data50PW{i}.elec=data.elec; end; >> data50PW data50PW = [1x1 struct] [1x1 struct] [1x1 struct] >> data50PW{1} ans = label: {129x1 cell} fsample: 250 elec: [1x1 struct] avg: [129x523 single] var: [129x523 single] time: [1x523 double] dimord: 'chan_time' cfg: [1x1 struct] % designing design matrix cfg = [] cfg.design = [1 1 1 2 2 2; 1 2 3 1 2 3]; 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 % Setting cfg for timelockstatistics cfg.statistic='depsamplesT'; cfg.numrandomization = 'all'; cfg.alpha=0.05; cfg.clusterstatistics='maxsum'; cfg.clusterthreshold = 'parametric'; cfg.clusteralpha = 0.05; cfg.neighbourdist=4; cfg.neighbours = neighbourselection(cfg,data50PW{1}); cfg.latency=[0 0.5]; cfg.method = 'montecarlo'; cfg.correctm = 'cluster'; cfg = [] Using the electrode configuration from the dataset. there are on average 128.0 neighbours per channel stat = timelockstatistics(cfg,data50W{:},data50PW{:}); selected 129 channels selected 126 time bins selected 1 frequency bins using "statistics_montecarlo" for the statistical testing using "statfun_depsamplesT" for the single-sample statistics constructing randomized design total number of measurements = 6 total number of variables = 2 number of independent variables = 1 number of unit variables = 1 number of control variables = 0 number of within-block variables = 0 repeated measurement in variable 2 over 3 levels number of repeated measurements in each level is 2 2 2 creating all possible permutations (8) computing a parmetric threshold for clustering computing statistic Warning: Divide by zero. > In fieldtrip-20061016\private\statfun_depsamplesT at 106 In statistics_montecarlo at 249 In fieldtrip-20061016\private\statistics_wrapper at 233 In timelockstatistics at 50 estimated time per randomization is 0 seconds computing statistic 1 from 8 Warning: Divide by zero. > In fieldtrip-20061016\private\statfun_depsamplesT at 106 In statistics_montecarlo at 278 In fieldtrip-20061016\private\statistics_wrapper at 233 In timelockstatistics at 50 computing statistic 2 from 8 Warning: Divide by zero. > In fieldtrip-20061016\private\statfun_depsamplesT at 106 In statistics_montecarlo at 278 In fieldtrip-20061016\private\statistics_wrapper at 233 In timelockstatistics at 50 ... same output up to statistic 8 and then ??? Attempted to access (2); index out of bounds because numel()=1. Error in ==> fieldtrip-20061016\private\clusterstat at 65 postailcritval = cfg.clustercritval(2); Error in ==> statistics_montecarlo at 305 stat = clusterstat(cfg, statrand, statobs); Error in ==> fieldtrip-20061016\private\statistics_wrapper at 233 [stat, cfg] = statmethod(cfg, dat, cfg.design); Error in ==> timelockstatistics at 50 [stat] = statistics_wrapper(cfg, varargin{:}); On 10/16/06, Robert Oostenveld wrote: > Hi Marco > > Your script looks ok. > > On 13 Oct 2006, at 19:03, Marco Buiatti wrote: > > ??? Undefined variable "data" or class "data.biol". > > > > Error in ==> fieldtrip-20061012/private/prepare_design at 92 > > nrepl=size(data.biol,1); > > > > Error in ==> fieldtrip-20061012/private/statistics_wrapper at 212 > > [cfg] = prepare_design(cfg); > > > > Error in ==> timelockstatistics at 50 > > [stat] = statistics_wrapper(cfg, varargin{:}); > > Yep, that is a known problem (sorry about that). The function > prepare_design is not working properly. I suggest to make a design > matrix in cfg.design by hand (similar to, but not completely the same > as in SPM). It is not difficult, and it will also make you more clear > how it works. Please have a look at > https://listserv.surfnet.nl/scripts/wa.exe? > A2=ind0607&L=FIELDTRIP&P=R3192&I=-3&X=77C04E25A87526C2B4 > or if that URL does not work, then search the fieldtrip discussion > list archive for the string "cfg.design". > > best regards, > Robert > > PS note that you can also use timelockstatistics on the > 'componentanalysis' part of the EEGLAB data, in that case you cannot > use channel clustering, but you still can use timepoint clustering > (so cfg.neighbours should be []). You shoudl only do that if the ICA > components in the different EEG datasets are spatially the same (or > sufficiently similar, e.g. after clustering over subjects in the new > EEGLAB). > -- Marco Buiatti - Post Doc ************************************************************** Cognitive Neuroimaging Unit - INSERM U562 Service Hospitalier Frederic Joliot, CEA/DRM/DSV 4 Place du general Leclerc, 91401 Orsay cedex, France Telephone: +33 1 69 86 77 65 Fax: +33 1 69 86 78 16 E-mail: marco.buiatti at gmail.com Web: www.unicog.org *************************************************************** From r.oostenveld at FCDONDERS.RU.NL Thu Oct 19 16:39:17 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 19 Oct 2006 16:39:17 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: <22f732b0610190313y30ab9dd5p9ce335337184d8a2@mail.gmail.com> Message-ID: Dear Marco On 19 Oct 2006, at 12:13, Marco Buiatti wrote: > computing statistic 1 from 8 > Warning: Divide by zero. >> In fieldtrip-20061016\private\statfun_depsamplesT at 106 > In statistics_montecarlo at 278 > In fieldtrip-20061016\private\statistics_wrapper at 233 > In timelockstatistics at 50 > computing statistic 2 from 8 > Warning: Divide by zero. >> In fieldtrip-20061016\private\statfun_depsamplesT at 106 > In statistics_montecarlo at 278 > In fieldtrip-20061016\private\statistics_wrapper at 233 > In timelockstatistics at 50 > > ... same output up to statistic 8 and then Hmm, to me this seems to indicate that you have samples at which you do not have any variance, i.e. the computation of the t-score is mean_difference/pooled_variance, and since variance is zero, you have someting divided by zero, probably resulting in "Inf", i.e. infinite numbers. Could it be that you have baseline corrected data that is corrected to only one sample (i.e. the sample at time t=0), and that hence one sample in the data is always zero? I don't know how a t-score of Inf will affect the other computations. But the actual problem is > ??? Attempted to access (2); index out of bounds because numel()=1. > > Error in ==> fieldtrip-20061016\private\clusterstat at 65 > postailcritval = cfg.clustercritval(2); > > Error in ==> statistics_montecarlo at 305 > stat = clusterstat(cfg, statrand, statobs); > > Error in ==> fieldtrip-20061016\private\statistics_wrapper at 233 > [stat, cfg] = statmethod(cfg, dat, cfg.design); > > Error in ==> timelockstatistics at 50 > [stat] = statistics_wrapper(cfg, varargin{:}); That problem is NOT due to the warning above (i.e. the potential t- value of inf), but just a small programming error. The sequence of if- statements in that section of code was the wrong way around. Please find a corrected version of clusterstat.m attached to this mail. Actually, looking further into the code, I am surprised that you get this error. It means that the low level statfun_depsamplesT is using a cfg.tail=1 (that corresponds to cfg.clustertail in statistics_montecarlo itself). But from your cfg I do not see that you explicitely define a positive-tailed test, and the default set at the level of statistics_montecarlo should be two-tailed. Do you have any ideas about this yourself? best regards, Robert --- PS you can type dbstop if error on the matlab promt to start using the matlab debugger, and dbclear all to get rid of it again. That will help a lot in diagnosing problems like these. See "help dbstop" -------------- next part -------------- A non-text attachment was scrubbed... Name: clusterstat.m Type: application/octet-stream Size: 26868 bytes Desc: not available URL: From marco.buiatti at GMAIL.COM Fri Oct 20 19:02:08 2006 From: marco.buiatti at GMAIL.COM (Marco Buiatti) Date: Fri, 20 Oct 2006 19:02:08 +0200 Subject: clusterrandanalysis on scalar values + problem with topoplotER In-Reply-To: <7BCCB2F0-B1B5-458A-8B2B-7E97FAFE1103@fcdonders.ru.nl> Message-ID: Thank you Robert, now EVERYTHING WORKS!!! More in detail: On 10/19/06, Robert Oostenveld wrote: > > computing statistic 2 from 8 > > Warning: Divide by zero. > >> In fieldtrip-20061016\private\statfun_depsamplesT at 106 > > In statistics_montecarlo at 278 > > In fieldtrip-20061016\private\statistics_wrapper at 233 > > In timelockstatistics at 50 > > > > ... same output up to statistic 8 and then > > Hmm, to me this seems to indicate that you have samples at which you > do not have any variance, i.e. the computation of the t-score is > mean_difference/pooled_variance, and since variance is zero, you have > someting divided by zero, probably resulting in "Inf", i.e. infinite > numbers. Could it be that you have baseline corrected data that is > corrected to only one sample (i.e. the sample at time t=0), and that > hence one sample in the data is always zero? You were right, and the reason for this was even more trivial: I had included the reference channel, which is always zero by definition. Now data are in average reference. > > I don't know how a t-score of Inf will affect the other computations. > But the actual problem is > > > ??? Attempted to access (2); index out of bounds because numel()=1. > > > > Error in ==> fieldtrip-20061016\private\clusterstat at 65 > > postailcritval = cfg.clustercritval(2); > > > > Error in ==> statistics_montecarlo at 305 > > stat = clusterstat(cfg, statrand, statobs); > > > > Error in ==> fieldtrip-20061016\private\statistics_wrapper at 233 > > [stat, cfg] = statmethod(cfg, dat, cfg.design); > > > > Error in ==> timelockstatistics at 50 > > [stat] = statistics_wrapper(cfg, varargin{:}); > > That problem is NOT due to the warning above (i.e. the potential t- > value of inf), but just a small programming error. The sequence of if- > statements in that section of code was the wrong way around. Please > find a corrected version of clusterstat.m attached to this mail. > > Actually, looking further into the code, I am surprised that you get > this error. It means that the low level statfun_depsamplesT is using > a cfg.tail=1 (that corresponds to cfg.clustertail in > statistics_montecarlo itself). But from your cfg I do not see that > you explicitely define a positive-tailed test, and the default set at > the level of statistics_montecarlo should be two-tailed. Do you have > any ideas about this yourself? Everything works now with the new clusterstat.m! Here you are my cfg at the point where it crashed before: cfg = design: [2x6 double] ivar: 1 uvar: 2 statistic: 'depsamplesT' numrandomization: 'all' alpha: 0.0500 clusterstatistics: 'maxsum' clusterthreshold: 'parametric' clusteralpha: 0.0500 neighbourdist: 0.8000 neighbours: {1x129 cell} latency: [0 0.5000] method: 'montecarlo' correctm: 'cluster' channel: {129x1 cell} frequency: [] avgoverchan: 'no' avgovertime: 'no' avgoverfreq: 'no' channelcmb: [] precision: 'double' version: [1x1 struct] previous: {1x6 cell} dim: [129 1 126] tail: 0 feedback: 'text' cvar: [] wvar: [] clusterstatistic: 'maxsum' clustercritval: 2.9200 clustertail: 0 factor: 1 unitfactor: 2 orderedstats: 'no' multivariate: 'no' minnbchan: 0 As you see, cfg.tail=0 but I have only one value of cfg.clustercritval (while the former clusterstat required two). I checked that results are totally compatible with the ones I obtained with clusterrandanalysis, and I easily transformed the spatial data I have (what I erroneously called scalar in my initial e-mail in this thread) to perform cluster randomization analysis. Thank you again for the follow up. Marco -- Marco Buiatti - Post Doc ************************************************************** Cognitive Neuroimaging Unit - INSERM U562 Service Hospitalier Frederic Joliot, CEA/DRM/DSV 4 Place du general Leclerc, 91401 Orsay cedex, France Telephone: +33 1 69 86 77 65 Fax: +33 1 69 86 78 16 E-mail: marco.buiatti at gmail.com Web: www.unicog.org *************************************************************** From lorina_naci at YAHOO.CO.UK Mon Oct 23 19:18:01 2006 From: lorina_naci at YAHOO.CO.UK (Lorina Naci) Date: Mon, 23 Oct 2006 18:18:01 +0100 Subject: Within-subject coherence statististics for virtual sources Message-ID: Dear FIELDTRIP members, I have used BESA to perform source coherence calculations for a multiple-subject/multiple-condition experiment. I have 14 subjects, and 2 conditions for which I’d like to compare coherence values. I have calculated coherence values in the Time-Frequency domain for each person. Given that BESA cannot calculate statistics in a multiple-subject study, their support personnel directed me towards FieldTrip. I would like to use your existing script ‘clusterrandanalysis on TFRs of power that were computed with BESA,’ but I cannot relate this to my data as the coherence values have been calculated for ROI sources, (8 per hemisphere - 16 sources total), and not for electrodes (I had 128). Do you have any advice regarding how I may adopt the script to for source coherence as opposed to electrode coherence? How do I import the source locations? Many thanks is advance for your help, Lorina Send instant messages to your online friends http://uk.messenger.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jaredvs at GMAIL.COM Mon Oct 23 22:28:28 2006 From: jaredvs at GMAIL.COM (Jared Van Snellenberg) Date: Mon, 23 Oct 2006 16:28:28 -0400 Subject: Incorrect coordinates? In-Reply-To: <2992F646-2E64-452D-8E51-9F9C121A63E0@fcdonders.ru.nl> Message-ID: Hi Robert, I just wanted to let you know that your suggestion was correct (I was working on a deadline for Friday, otherwise I would've responded sooner), the problem was created by the fact that the out of brain voxels were not masked out in the BESA data. The results of the analysis after masking appropriately were drastically different, and were all within-brain and make sense in light of the experimental task. I used the following code to obtain the mask: inside=[]; for k=1:length(files) src(k)=besa2fieldtrip([files(k).name]); in=find(src(k).avg.pow); inside(end+1:end+length(in))=in; end inside=unique(inside); outside=1:49708; outside(inside)=[]; for k=1:length(files) src(k).inside=inside; src(k).outside=outside; end This ensured that all the subjects had the same mask, and only values that were 0 in all the subjects were masked out. I manually checked all the subjects and there was at most a difference of 3 in the number of nonzero voxels in any two subjects. You might want to document this somewhere for other users, as it's not immediately apparent that specification of the .inside and .outside fields in the source structure are critical for further processing steps to behave correctly. Thanks for your help, -Jared On 10/16/06, Robert Oostenveld wrote: > > Hi Jared, > > On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > > I've rerun the analysis with mri's that were reoriented to MNI, and > > the same problem has emerged. > > I would guess that the anatomical MRIs themselves do not influence > the coordinate system of the source reconstruction. That would > influence the interpolation though. > > If you do > source = besa2fieldtrip(filename1) > and > mri = read_fcdc_mri(filename) > then the source structure is defined using the source.pos field that > describes the position of each source. SInce in this case the > positions are on a regular 3D grid, there is additional structure in > the arrangement of source.pos, which is described using source.xgrid, > source.ygrid, source.zgrid. > > If you do > tmp = reshape(source.avg.pow, source.dim) > you will get a 3D array with along the first dimension the voxels > along the x-axis, etc. The 1..Nth voxels along the xasix have the X > coordinates source.xgrid(1)..source.xgrid(N). Similar for the Y and Z > coordinates. That allows you to determine the coordinate of each voxel. > > Since the anatomical MRI is typically of much higher resolution, you > can use sourceinterpolate which interpolates the source (or stat) > volumes onto the voxel locations that are in the anatomical MRI. I.e. > sourceinterpolate upsamples the functional data to the anatomical > MRI. Normally you would do sourceinterpolate AFTER calling > sourcestatistics, since the source positions in all subjects are all > based on the same standard realistic head moidel in BESA and hence > the source positions in all subjects are the same (please check > whether positions are all the same over subjects/conditions). > > If you work with MEG or with EEG individual headmodels, the source > positions in all subjects are all different, which requires > sourceanalysis->sourceinterpolate->volumenormalize as shown in the > schema for http://www2.ru.nl/fcdonders/fieldtrip/doku.php? > id=fieldtrip:documentation:analysis_protocols#source_reconstruction_for_ > multiple_subjects > > > The typo you noted in your last email was indeed the reason for the > > empty src plot. Plotting src, interp, volume, and grandavg, > > everything looks ok. The 'pow' parameter values all appear within > > the brain. The tscore and p values in stat, however, are all messed > > up. I've attached .bmp's from using sourceplot on grandavg and stat > > to this email. The quality is poor (matlab's figure window doesn't > > ever save bmp's very well), but it should demonstrate the problem > > clearly. Note all the large values outside of the brain. > > In your case you should be able to do besa2fieldtrip -> > sourcestatistics, and then the source positions with the statistical > data on them should stll be the same as the positions with the > original functional data on them. After doing the statistics (or > after doing sourcegrandaverage), you can interpolate the functional/ > statistical data onto the MRI. But since the statistical data and the > functional (beamed power) data are on the same coordinates, there > should not be a difference between them. > > > Any comments you have would be greatly appreciated. I've considered > > just masking out everything that's not in the brain, but I'm not > > confident that the within-brain values are accurate. > > Looking at the bitmaps, I cannot see teh anatomy, but I do see a > brain-shaped outline with some blobs in them. I cannot recognise the > problem from these figures, to me they seem ok. The only problem that > I can see is the one that you also mention, and that is for the > masking. In the original source data (i.e. output from > besa2fieldtrip) there is an source.inside and source.outside field. > Those should contain the indices of the voxels (linear indices, so > voxel [1 1 1] has index 1 and voxel [2 1 1] has index 2...) of the > sources that are inside the brain and outside the brain. Only the > inside voxels are considered for sourcestatistics and for > sourceinterpolation. However, the problem with BESA data is that it > does not describe the inside/outside voxels and therefoer by default > all voxels are marked as inside. Perhaps you can determine the inside/ > outside voxels manually, e.g. > source.inside = find(source.avg.pow(:)>eps); > source.outside = find(source.avg.pow(:) After fixing the inside/outside, you can rerun sourcestatistics and > the rest. See the related FAQ http://www2.ru.nl/fcdonders/fieldtrip/ > doku.php? > id=fieldtrip:documentation:frequently_asked_questions#why_is_there_a_rim > _around_the_brain_for_which_the_source_reconstruction_is_not_computed > > To me it seems that the outside brain mess is caused by an > interpolation artifact, which can well be explained by the missing > inside/outside specification of besa. After fixing the inside/outside > vectors in the source structure, and passing it through > sourceinterpolate, you will get an interp.inside 3D boolean volume > with 0s and 1s for outside and inside voxels. You can element-wise > multiply the data with it, to mask the outside, or you can specify > cfg.mask='inside' in sourceplot (which uses opacity). > > Hope this helps, if not, please put some data (source, mri, stat, > interp) in a zip file on ftp://ftp.fcdonders.nl/pub/incoming > > Robert > -- Jared Van Snellenberg Social Cognitive Affective Neuroscience Unit http://scan.psych.columbia.edu (212) 854-7858 p (212) 854-3609 f Department of Psychology, Columbia University 406 Schermerhorn Hall 1190 Amsterdam Avenue, Mail Code 5501 New York, NY 10027 -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jan.Schoffelen at FCDONDERS.RU.NL Tue Oct 24 15:31:57 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Tue, 24 Oct 2006 15:31:57 +0200 Subject: Within-subject coherence statististics for virtual sources In-Reply-To: <20061023171801.37444.qmail@web28106.mail.ukl.yahoo.com> Message-ID: Dear Lorina, For the time being, I assume that you have your data imported into a fieldtrip-like format, using besa2fieldtrip. I am not familiar with this function, but when I read the help of besa2fieldtrip I guess that your besa file was a .tfc file. So probably your data-object looks like what fieldtrip considers to be a frequency-structure, containing a TFR for each ROI. I guess you have two data-objects for each subject. What you would like to do is possible within fieldtrip, but I would advise you not to use clusterrandanalysis to get there. Quite some correspondence has been devoted to the new statistical interface, you can read about it on the discussion list's website (follow the appropriate links on the fieldtrip website), concerning Re: clusterrandanalysis on scalar values + problem with topoplotER during the past month, but which started in August. In a nutshell: instead of using clusterrandanalysis you could use freqstatistics (under the above assumption that your data resembles a fieldtrip-frequency structure) with the appropriate settings to get your statistics done. Freqstatistics relies on statistics_montecarlo, when you specify cfg.method = 'montecarlo'. Please have a try following the thread on the discussion list, and the following configuration settings, as well as the information in statistics_montecarlo and other dependent functions. You'll probably need the attached function as well, which computes your statistic of interest. Cfg = []; Cfg.method = 'montecarlo'; Cfg.statistic = 'diff'; Cfg.parameter = 'cohspctrm'; %This is at least what I expect your data objects to contain! Cfg.numrandomization = a number; Cfg.design = [1 1 2 2 3 3 with all the numbers in between 14 14; . 1 2 1 2 1 2 with all the numbers in between 1 2]; %this specifies how the data has to be interpreted Cfg.ivar = 2; %row-index of independent variable, which is the condition in your case Cfg.uvar = 1; %row-index of the 'unit'-variable, your unit of observation, which are your individual subjects. %the design-matrix will be shuffled, by swapping the 1 and 2's in the ivar-row, while keeping the uvar-doublets together. Cfg.correctm = 'yes'; %keep it at this for the time being, we have to develop a cunning strategy to incorporate something about the neighbourhood structure of your ROIs %as soon as you get your script running, you can try to incorporate fancy multiple-comparison correction strategies, such as clustering in time and frequency. Stat = freqstatistics(cfg, subj1cond1, subj1cond2, subj2cond1, subj2cond2 ..); %take care that this corresponds with how you specified your design. Subjxconx should then be the data-structure containing your TFRs in a field called cohspctrm. I hope this puts you on track, Yours, Jan-Mathijs _____ From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf Of Lorina Naci Sent: Monday, October 23, 2006 7:18 PM To: FIELDTRIP at NIC.SURFNET.NL Subject: [FIELDTRIP] Within-subject coherence statististics for virtual sources Dear FIELDTRIP members, I have used BESA to perform source coherence calculations for a multiple-subject/multiple-condition experiment. I have 14 subjects, and 2 conditions for which I'd like to compare coherence values. I have calculated coherence values in the Time-Frequency domain for each person. Given that BESA cannot calculate statistics in a multiple-subject study, their support personnel directed me towards FieldTrip. I would like to use your existing script 'clusterrandanalysis on TFRs of power that were computed with BESA,' but I cannot relate this to my data as the coherence values have been calculated for ROI sources, (8 per hemisphere - 16 sources total), and not for electrodes (I had 128). Do you have any advice regarding how I may adopt the script to for source coherence as opposed to electrode coherence? How do I import the source locations? Many thanks is advance for your help, Lorina Send instant messages to your online friends http://uk.messenger.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: statfun_diff.m Type: application/octet-stream Size: 990 bytes Desc: not available URL: From r.oostenveld at FCDONDERS.RU.NL Wed Oct 25 08:05:27 2006 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Wed, 25 Oct 2006 08:05:27 +0200 Subject: Incorrect coordinates? In-Reply-To: <51d499680610231328y1b3d2093xe9b02abf4b3af113@mail.gmail.com> Message-ID: Hi Jared, Thanks for your detailled feedback. I think that it is a good idea to document these steps for other BESA users. I am rather busy, but maybe you could do it yourself? The FieldTrip website is a Wiki, and anyone can edit and contribute to it by pressing the "edit this page" button that you see on every page. Regarding this information: I would put it under a subheading (with some introductory comments, which probably can be copied-pasted from our previous mails) on the BESA-related page, i.e. on http://www2.ru.nl/fcdonders/fieldtrip/ doku.php?id=fieldtrip:documentation:integrating_with_besa best regards, Robert On 23 Oct 2006, at 22:28, Jared Van Snellenberg wrote: > Hi Robert, > > I just wanted to let you know that your suggestion was correct (I > was working on a deadline for Friday, otherwise I would've > responded sooner), the problem was created by the fact that the out > of brain voxels were not masked out in the BESA data. The results > of the analysis after masking appropriately were drastically > different, and were all within-brain and make sense in light of the > experimental task. > > I used the following code to obtain the mask: > > inside=[]; > > > for k=1:length(files) > src(k)=besa2fieldtrip([ > > files(k).name]); > in=find(src(k).avg.pow); > > inside(end+1:end+length(in))=in; > > > end > inside=unique(inside); > > outside=1:49708; > > outside(inside)=[]; > > > for k=1:length(files) > src(k).inside=inside; > > src(k).outside=outside; > > > endThis ensured that all the subjects had the same mask, and only > values that were 0 in all the subjects were masked out. I manually > checked all the subjects and there was at most a difference of 3 in > the number of nonzero voxels in any two subjects. > > You might want to document this somewhere for other users, as it's > not immediately apparent that specification of the .inside > and .outside fields in the source structure are critical for > further processing steps to behave correctly. > > Thanks for your help, > > -Jared > > > > > On 10/16/06, Robert Oostenveld > wrote: Hi Jared, > > On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote: > > I've rerun the analysis with mri's that were reoriented to MNI, and > > the same problem has emerged. > > I would guess that the anatomical MRIs themselves do not influence > the coordinate system of the source reconstruction. That would > influence the interpolation though. > > If you do > source = besa2fieldtrip(filename1) > and > mri = read_fcdc_mri(filename) > then the source structure is defined using the source.pos field that > describes the position of each source. SInce in this case the > positions are on a regular 3D grid, there is additional structure in > the arrangement of source.pos, which is described using source.xgrid, > source.ygrid, source.zgrid. > > If you do > tmp = reshape(source.avg.pow , source.dim) > you will get a 3D array with along the first dimension the voxels > along the x-axis, etc. The 1..Nth voxels along the xasix have the X > coordinates source.xgrid(1)..source.xgrid(N). Similar for the Y and Z > coordinates. That allows you to determine the coordinate of each > voxel. > > Since the anatomical MRI is typically of much higher resolution, you > can use sourceinterpolate which interpolates the source (or stat) > volumes onto the voxel locations that are in the anatomical MRI. I.e. > sourceinterpolate upsamples the functional data to the anatomical > MRI. Normally you would do sourceinterpolate AFTER calling > sourcestatistics, since the source positions in all subjects are all > based on the same standard realistic head moidel in BESA and hence > the source positions in all subjects are the same (please check > whether positions are all the same over subjects/conditions). > > If you work with MEG or with EEG individual headmodels, the source > positions in all subjects are all different, which requires > sourceanalysis->sourceinterpolate->volumenormalize as shown in the > schema for http://www2.ru.nl/fcdonders/fieldtrip/doku.php ? > id=fieldtrip:documentation:analysis_protocols#source_reconstruction_fo > r_ > multiple_subjects > > > The typo you noted in your last email was indeed the reason for the > > empty src plot. Plotting src, interp, volume, and grandavg, > > everything looks ok. The 'pow' parameter values all appear within > > the brain. The tscore and p values in stat, however, are all messed > > up. I've attached .bmp's from using sourceplot on grandavg and stat > > to this email. The quality is poor (matlab's figure window doesn't > > ever save bmp's very well), but it should demonstrate the problem > > clearly. Note all the large values outside of the brain. > > In your case you should be able to do besa2fieldtrip -> > sourcestatistics, and then the source positions with the statistical > data on them should stll be the same as the positions with the > original functional data on them. After doing the statistics (or > after doing sourcegrandaverage), you can interpolate the functional/ > statistical data onto the MRI. But since the statistical data and the > functional (beamed power) data are on the same coordinates, there > should not be a difference between them. > > > Any comments you have would be greatly appreciated. I've considered > > just masking out everything that's not in the brain, but I'm not > > confident that the within-brain values are accurate. > > Looking at the bitmaps, I cannot see teh anatomy, but I do see a > brain-shaped outline with some blobs in them. I cannot recognise the > problem from these figures, to me they seem ok. The only problem that > I can see is the one that you also mention, and that is for the > masking. In the original source data (i.e. output from > besa2fieldtrip) there is an source.inside and source.outside field. > Those should contain the indices of the voxels (linear indices, so > voxel [1 1 1] has index 1 and voxel [2 1 1] has index 2...) of the > sources that are inside the brain and outside the brain. Only the > inside voxels are considered for sourcestatistics and for > sourceinterpolation. However, the problem with BESA data is that it > does not describe the inside/outside voxels and therefoer by default > all voxels are marked as inside. Perhaps you can determine the inside/ > outside voxels manually, e.g. > source.inside = find(source.avg.pow(:)>eps); > source.outside = find(source.avg.pow(:) After fixing the inside/outside, you can rerun sourcestatistics and > the rest. See the related FAQ http://www2.ru.nl/fcdonders/fieldtrip/ > doku.php? > id=fieldtrip:documentation:frequently_asked_questions#why_is_there_a_r > im > _around_the_brain_for_which_the_source_reconstruction_is_not_computed > > To me it seems that the outside brain mess is caused by an > interpolation artifact, which can well be explained by the missing > inside/outside specification of besa. After fixing the inside/outside > vectors in the source structure, and passing it through > sourceinterpolate, you will get an interp.inside 3D boolean volume > with 0s and 1s for outside and inside voxels. You can element-wise > multiply the data with it, to mask the outside, or you can specify > cfg.mask='inside ' in sourceplot (which uses opacity). > > Hope this helps, if not, please put some data (source, mri, stat, > interp) in a zip file on ftp://ftp.fcdonders.nl/pub/incoming > > Robert > > > > -- > Jared Van Snellenberg > Social Cognitive Affective Neuroscience Unit > http://scan.psych.columbia.edu > (212) 854-7858 p > (212) 854-3609 f > Department of Psychology, Columbia University > 406 Schermerhorn Hall > 1190 Amsterdam Avenue, Mail Code 5501 > New York, NY 10027 From litvak at TX.TECHNION.AC.IL Tue Oct 31 15:06:21 2006 From: litvak at TX.TECHNION.AC.IL (Vladimir Litvak) Date: Tue, 31 Oct 2006 14:06:21 -0000 Subject: SPM integration Message-ID: Dear Robert and all, I'm starting to work on a project where I will analyze data preprocessed in FT with SPM5 (www.fil.ion.ucl.ac.uk/spm/). For this purpose I'd like to develop FT/SPM integration routines. I'll probably start with my immediate needs but I think I'm motivated enough at the moment to eventually turn it into something of general usefulness. If anyone has already worked in this direction and has some code or would like to collaborate please let me know. I'm affiliated to the methods group at FIL so I can get help from SPM developers if necessary. Right now I'd like to be able to use FT to read any FT supported format to SPM. Additional question: how does one create low-level routines for a new (rare) data format to be used by FT preprocessing? Is there a template or some interface they should adhere to? Thanks, Vladimir Litvak -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jan.Schoffelen at FCDONDERS.RU.NL Tue Oct 31 15:33:24 2006 From: Jan.Schoffelen at FCDONDERS.RU.NL (Jan Mathijs Schoffelen) Date: Tue, 31 Oct 2006 15:33:24 +0100 Subject: Picturing wavelet shape In-Reply-To: <454238CD.4090706@psych.york.ac.uk> Message-ID: >Dear Jan > >Please can you advise me how to visualize the actual shape of the wavelets >produced by the two parameters: > >width and gwidth > >I am getting some interesting/frustrating effects whereby small changes in >both values (varying width between 3-5, and gwidth between 1-4) and can >flip the polarity in my spectral plots. In other words, the location in >time and frequency of significant power doesn't really change, but whether >these are assigned an increase(red) or decrease >(blue) in power does change relative to baseline. The spectrograms are >created with singleplotTFR , combined with a baseline. I know I am at the >resolution limits for these analyses, because of our relatively short time >windows, but I am hoping that these effects can be explained by subtle >changes in wavelet shape, and therefore I needn't worry too much. >Alternatively, I may be pushing the analysis to breaking point, where it is >too unreliable to report. But to help me decide, picturing the wavelet >structure would be a real help (I think). Dear Piers, Hmmm, the easy answer to your question is to extract some of the relevant lines to a new script and play around with that. When you look into the code, in my version (revision version 1.16) the wavelets are constructed, starting in line 214: (for foilop = 1:numfoi) dt = 1/data.fsample; sf = cfg.foi(foilop)/cfg.width(foilop); st = 1/(2*pi*sf); toi2 = -cfg.gwidth*st:dt:cfg.gwidth*st; A = 1/sqrt(st*sqrt(pi)); tap = (A*exp(-toi2.^2/(2*st^2)))'; ... (end) The vector tap contains the wavelet, which you can visualize with plot(tap); So far the easy part. However, it is a bit obscure that you get opposite effects by slightly adjusting your wavelet-parameters, and I suspect that that is not a wavelet issue, but rather a baseline-issue. If we look at your configuration for the plotting: cfg5 = []; cfg5.baseline = [-0.2 0.0]; %cfg5.baselinetype = 'relative'; cfg5.baselinetype = 'absolute'; cfg5.zlim = 'maxmin'; cfg5.xlim = [-0.0 0.3]; cfg5.ylim = [7 30]; cfg5.channel = 'V0'; singleplotTFR(cfg5, freq); You use a baseline-interval between -0.2 and 0. This essentially means, that you are subtracting the estimated baseline, averaged between -0.2 and 0. However, timepoint 0 contains quite some post-stimulus-onset stuff, because of the width of your wavelet kernel (which scales with frequency, so I would expect more of your strange effects in these ranges). If there's a strong evoked component in your data, which bleeds into your baseline estimate, this might lead to an overestimation of your baseline-power, and to a subsequent stimulus-locked decrease in power post-stimulus. If there's less bleeding into the baseline, the baseline estimate is lower, which would lead to a stimulus-locked increase in power, which I would expect at a earlier latency than the decrease described before. Best Jan-Mathijs From luca.ciancetta at TISCALI.IT Tue Oct 31 18:28:50 2006 From: luca.ciancetta at TISCALI.IT (Luca Ciancetta) Date: Tue, 31 Oct 2006 18:28:50 +0100 Subject: lcmv localization Message-ID: Dear List members, I'm trying to localize a source with the lcmv method. Following, it's the configuration I use: time_step = 1/h.smpfq; % the time step depends by sampling frequency time = 0:time_step:(500*time_step); % I want to see 500 points of data data.trial{1} = data_raw(gch,0:500); % gch: list of good channels data.time{1} = time; cfg = []; cfg.method = 'lcmv'; cfg.grid.pos = model; % model is a matrix [number_of_sources X 3]. This represent position of dipoles in the reference of the sphere which contains them. cfg.grad.tra = zeros(nch,nch); % number of good sensors ( size of 'gch' list ) for i=1:nch cfg.grad.pnt(i,: ) = h.ch(gch(i)+offset).pos(1).r_s.comp'; % positions of MEG sensors in the reference of the spherical model cfg.grad.ori(i,: ) = h.ch(gch(i)+offset).pos(1).u_s.comp'; % orientations of MEG sensors in the reference of the spherical model cfg.grad.tra(i,i) = 1; cfg.grad.label{i} = sprintf('MZ_%d\n',gch(i)-1); end cfg.vol = []; cfg.vol.r = 65; cfg.bpfilter = 'yes'; cfg.bpfreq = [1 100]; data.avg = squeeze(data.trial{1}); source = sourceanalysis(cfg,data); In this case I used only one trial and the result is a localization in the center of the sphere ( the source is a dipole simulation, it was placed on the surface of my spherical model). Also analyzing over more trials or using different data set, for example a median nerve stimulation, the result was the same. can you help me? Thanks, Luca.