From matsuham at NINDS.NIH.GOV Wed Oct 6 01:32:13 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Tue, 5 Oct 2004 19:32:13 -0400 Subject: Question: Read_ctf_rc usw.. Message-ID: Hi, I am interested in DICS and now started to struggle with FieldTrip 0.92. I was very impressed by Dr. Schoffelen's presentation at BIOMAG 2004. First, I thank you very much for your effort to make this fascinating and promising toolbox to public. Then, among lots of questions, 1) I couldn't find the script 'read_ctf_hc' as described in the document 'Localizing oscillatory sources using beamformer techniques'. How can I obtain one? 2) I am almost at a loss how to start. Can I have some brief description of how to do DICS kind of analysis? Let me say, 600Hz, 4 min single trial dataset: Foo_trial_01.ds (a folder in current directory) Reference signal vector of the same length: RefSignal (14400 x 1 double array in matlab workspace) MRI/head information in Foo.mri, Foo.hdm, Foo.shape and Foo_trial_01.ds/localSpheres.hdm. If the cross-spectra should be calculated before using FieldTrip, I can do the calculation and the cross-spectra between RefSignal and all channels in Foo_trial_01 will be stored in Fxy_trial_01 (274 x 1024 double array (complex)) --- 274 is the number of MEG sensors. What should I do next? Thank you for your attention, Masao ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From Jan.Schoffelen at FCDONDERS.RU.NL Thu Oct 7 14:58:46 2004 From: Jan.Schoffelen at FCDONDERS.RU.NL (J.M. Schoffelen) Date: Thu, 7 Oct 2004 14:58:46 +0200 Subject: Question: Read_ctf_rc usw.. Message-ID: -----Original Message----- From: J.M. Schoffelen [mailto:Jan.Schoffelen at fcdonders.ru.nl] Sent: Thursday, October 07, 2004 2:48 PM To: 'FieldTrip discussion list' Subject: RE: [FIELDTRIP] Question: Read_ctf_rc usw.. Dear Masao, >I am interested in DICS and now started to struggle with FieldTrip 0.92. Glad to hear that. >1) I couldn't find the script 'read_ctf_hc' as described in the document >'Localizing oscillatory sources using beamformer techniques'. How can I >obtain one? First of all, we are very sorry, but the tutorials to which you have access are not really up-to-date. That's important to realize. So the best information about the functions is to be found in the help-documentation of the function itself. So, don't worry about read_ctf_hc, since that is an old function, and not needed any more, since its functionality is covered by other functions. >2) I am almost at a loss how to start. Can I have some brief description of >how to do DICS kind of analysis? Let me say, >600Hz, 4 min single trial dataset: Foo_trial_01.ds (a folder in current >directory) >Reference signal vector of the same length: RefSignal (14400 x 1 double >array in matlab workspace) >MRI/head information in Foo.mri, Foo.hdm, Foo.shape and >Foo_trial_01.ds/localSpheres.hdm. >If the cross-spectra should be calculated before using FieldTrip, I can do >the calculation and the cross-spectra between RefSignal and all channels in >Foo_trial_01 will be stored in Fxy_trial_01 (274 x 1024 double array >(complex)) --- 274 is the number of MEG sensors. >What should I do next? In general, I would tackle the problem in the following way: from your description of your data I cannot judge if your reference-signal is also present in the .meg4-file, or that it is obtained from somewhere else. But that's a minor point. I would not calculate my csd's outside fieldtrip, but I would use the preprocessing-function to read in my data, not as a single trial, but cut in, say, 5-second pieces (I guess you will not need a frequency-resolution of 1/240 Hz/bin). Consecutively, I would read in my reference signal, using the same trial-configuration as used in your meg-data. (This would only work if your reference signal is in your .meg4 file, otherwise you have to find out a smart trick to combine the corresponding meg-data/reference-data.) Then you have to apply a trick, and store your reference-data and meg-data in the same structure. So, if your meg-data is contained in data, and your reference data in refdata (with identical trials), I would do this: for loop = 1:length(data.trial) data.trial{loop}=[data.trial{loop};refdata.trial{loop}]; end data.label=[data.label;refdata.label]; Now you're ready to compute your crosspectra (apparently you already obtained something like that), by using freqanalysis, and your coherencespectra by using freqdescriptives on the output of freqanalysis. By visualising the coherence on the sensor-level, you are able to locate the frequencies, at which the coherence might be interesting. Then (following the tutorial, with some variations), go back to frequency-analysis, taking as cfg.foilim your frequency-band of interest, and for your signal-combinations: cfg.sgncmb = channelcombination({'MEG' 'MEG';'MEG' '$label of your reference signal'},data.label); If you then run freqanalysis you'll end up with an awful lot of csd's. This will be your input into sourceanalysis. For this, you could perfectly well follow the tutorial, but you have to change "cfg.method='power'" into "cfg.method = 'coh_refchan'", and you have to add to your configuration: cfg.refchannel = '$label of your reference signal'. Hopefully this helps you a bit to get on track, Jan-Mathijs From matsuham at NINDS.NIH.GOV Fri Oct 8 03:46:19 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Thu, 7 Oct 2004 21:46:19 -0400 Subject: Question: Read_ctf_rc usw.. Message-ID: Dear Jan-Mathijs, Thank you very much for the description. Now I am trying... Actually the reference signal is not included in the dataset, so I did as follows: ======================== % load data, in 5 sec segments cfg.dataset='X:\raid\DOSTPIDM_track_20040826_01.ds' % 6+ min, 600Hz data, 219600 time points cfg.trl=[[1:3000:219600-3000]',[3000:3000:219600]',zeros(fix(219600/3000),1) ] cfg.channel='MEG' cfg.detrend='yes' data=preprocessing(cfg) %take some time, so do it only neccesory. % combine with ref signal w{} for loop = 1:length(data.trial) data.trial{loop}=[data.trial{loop}; w{1}([1:3000]+3000*(loop-1),1)']; %w is a cell array of ref signals (219600 x 2 matrix) end data.label=[data.label;{'REF'}]; % freq analysis cfg=[]; cfg.method = 'fft'; cfg.sgncmb = channelcombination({'MEG' 'REF'},data.label); cfg.output = 'powandcsd' cfg.foilim = [0,20] cfg.tapsmofrq=0.5; cfg.pad='maxperlen'; [freq] = freqanalysis(cfg, data) freq=freqdescriptives(cfg, freq) ========================== And I encountered an error: ========================== .... processing trial 71, nfft: 3000 samples, taper length: 3000 samples, 4 tapers processing trial 72, nfft: 3000 samples, taper length: 3000 samples, 4 tapers processing trial 73, nfft: 3000 samples, taper length: 3000 samples, 4 tapers freq = label: {275x1 cell} sgn: {275x1 cell} dimord: 'sgncmb_frq' powspctrm: [275x101 double] sgncmb: {274x2 cell} labelcmb: {274x2 cell} crsspctrm: [274x101 double] foi: [1x101 double] grad: [1x1 struct] cfg: [1x1 struct] ??? Reference to non-existent field 'pow'. Error in ==> C:\MATLAB\fieldtrip\freqdescriptives.m On line 207 ==> frqjck.powspctrm = frqjck.pow; >> =========================== I think I am doing something wrong...... ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From Jan.Schoffelen at FCDONDERS.RU.NL Fri Oct 8 08:40:40 2004 From: Jan.Schoffelen at FCDONDERS.RU.NL (J.M. Schoffelen) Date: Fri, 8 Oct 2004 08:40:40 +0200 Subject: freqdescriptives In-Reply-To: <6EF659D3CB8D724BBA76CF97214D8DAC0B640BE4@nihexchange17.nih.gov> Message-ID: Dear Masao, =========================== freq = label: {275x1 cell} sgn: {275x1 cell} dimord: 'sgncmb_frq' powspctrm: [275x101 double] sgncmb: {274x2 cell} labelcmb: {274x2 cell} crsspctrm: [274x101 double] foi: [1x101 double] grad: [1x1 struct] cfg: [1x1 struct] ??? Reference to non-existent field 'pow'. Error in ==> C:\MATLAB\fieldtrip\freqdescriptives.m On line 207 ==> frqjck.powspctrm = frqjck.pow; >> =========================== This is not your fault, it is an innocent but annoying bug in the function. If you re-run the freqanalysis-part, while putting in the configuration: cfg.keeptrials = 'yes'; then it should work fine. Yours, Jan-Mathijs From matsuham at NINDS.NIH.GOV Sun Oct 10 02:17:42 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Sat, 9 Oct 2004 20:17:42 -0400 Subject: freqdescriptives Message-ID: Dear Jan-Mathijs, Thank you. Now that error is gone and I can see the the distribution of something. As often the case with a beginer, despite the nice distribution of coherence itself in the occipital area as shown by multiplotER and topoplotER, the distribution of coherent source activity is somewhat odd (symmetric medial orbitofrontal). Here is my procedure. If you find any mistake, they are very, very appreciated. The head-model is the one I am using for SAM analysis, so it should be all right. ====================================================================== load data % DICS step1 cfg=[]; cfg.method = 'fft'; cfg.output = 'powandcsd' cfg.tapsmofrq=0.5; cfg.pad='maxperlen'; cfg.keeptrials = 'yes' cfg.foilim = [5.8,6.2]; cfg.sgncmb = channelcombination({'MEG' 'MEG';'MEG' 'REF'},data.label); [freqDICS] = freqanalysis(cfg, data) % DICS step 2 cfg=[]; cfg.refchannel ='REF'; cfg.method = 'coh_refchan'; cfg.projectnoise='yes'; cfg.hdmfile='X:\raid\DOSTPIDM_track_20040826_01.ds\localSpheres.hdm' cfg.frequency=6; cfg.lambda=1e-31; cfg.xgrid='auto'; cfg.ygrid='auto'; cfg.zgrid='auto'; cfg.resolution=2; cfg.keepleadfield='no'; source=sourceanalysis(cfg,freqDICS); mriFile='X:\raid\mri\DOSTPIDM.mri'; cfg.downsample=2; cfg.parameter='pow'; cfg.funparameter='pow'; sourceInterp=sourceinterpolate(cfg,source,mriFile); figure;sliceinterp(cfg,sourceInterp); ======================================================================= To check my data farther, I want to use megplanar to check the gradient contour map but it doesn't accept freqanalysis data... (T^T) Thank you again for your kind help, Masao ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From r.oostenveld at FCDONDERS.RU.NL Mon Oct 11 09:50:53 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 11 Oct 2004 09:50:53 +0200 Subject: freqdescriptives In-Reply-To: <6EF659D3CB8D724BBA76CF97214D8DAC0B640CE8@nihexchange17.nih.gov> Message-ID: Dear Masao, On 10 Oct 2004, at 2:17, Matsuhashi, Masao (NIH/NINDS) wrote: > To check my data farther, I want to use megplanar to check the gradient > contour map but it doesn't accept freqanalysis data... (T^T) It is theoretically not possible to compute the planar gradient from a frequency representation of the data. However, you can compute the frequency representation of a planar gradient. In your case therefore the computation of planar gradients has to be done before the computation of the frequency representation of that data, i.e. the sequence is preprocessing->megplanar->freqanalysis. Subsequently you have to combine the coherence between the reference channel and both planar gradients on a given sensor location into a single number. That single number (e.g. average or maximum coherence for the two planar gradients on that sensor location) can be plotted topographically. Combining coherence over the planar channels and topoplotting it is not yet implemented in FieldTrip in a straightforward way, therefore you have to fiddle with the datastructures yourself. Since you note that you see something symmetric medial orbitofrontal which is not expected, I also suggest that you carefully check whether you are not merely looking at some EOG artefacts in your data. There is a EOG artifact detection algorithm which you can use, and you should look at your raw data after preprocessing to ensure that it is clean. best regards, Robert ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Thu Oct 21 17:23:15 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Thu, 21 Oct 2004 11:23:15 -0400 Subject: coherence normalization Message-ID: When running a coherence volume using a reference dipole, one naturally expects the coherence will be high around the reference dipole. This effect tends to dominate the images. Is there a way to normalize the coherence volume to eliminate this effect? Perhaps by dividing by the coherence in a "control" state? Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From r.oostenveld at FCDONDERS.RU.NL Thu Oct 21 17:48:40 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 21 Oct 2004 17:48:40 +0200 Subject: coherence normalization In-Reply-To: Message-ID: On 21 Oct 2004, at 17:23, Tom Holroyd wrote: > When running a coherence volume using a reference dipole, one > naturally expects the coherence will be high around the reference > dipole. > > This effect tends to dominate the images. > > Is there a way to normalize the coherence volume to eliminate > this effect? Perhaps by dividing by the coherence in a "control" > state? Hi Tom, The dominating effect of the refdip is indeed very problematic. I just happened to have discussed this with Joachim Gross, and I have included our email exchange below. Please first read that ... Basically I agree with Joachim, and I don't trust the supdip that is implemented in FieldTrip's sourceanalysis function. Better test and map the significance of the difference in coherence between two conditions using randomization of the trials before the coherence is beamed (that is implemented in sourceanalysis + sourcestatistics). Robert -------------------------------------------------------------------- my question to Joachim was ---------------------------------------------------------------------- Begin forwarded message: > From: Robert Oostenveld > Date: 1 October 2004 10:26:02 GMT+02:00 > To: Joachim Gross > Subject: dipole suppression > > Hi Joachim, > > What I always still had to ask you is how you do supression of dipoles > in DICS, especially in the case of coherence imaging. I have thought > of two ways of projecting them out: > > 1) compute supdip leadfield and its projection on the COV/CSD matrix, > then project it out of the COV/CSD matrix (which looses 2 or 3 from > its rank). > > 2) compute supdip leadfield and add it to the leadfield of the dipole > with which is scanned (scandip). Subsequently compute the source > COV/CSD on those 6 leadfield components and select the 3x3 submatrix > that corresponds with the scandip to continue the computations with. > > Both methods don't really gave me very convincing results. A third > approach would be to add the supdip leadfield to the (identity) noise > matrix and project it through the filters. Then nai=pow/noise is > corrected for the presence of the supdip, but that does not result in > a supressed source coherence distribution. What is your idea or > approach for this? > > best regards > Robert > ---------------------------------------------------------------------- and his answer (Joachim, I hope you don't mind me sharing this on the list) ---------------------------------------------------------------------- Begin forwarded message: > From: Joachim Gross > Date: 14 October 2004 17:20:45 GMT+02:00 > To: "robert.oostenveld at fcdonders.kun.nl" > > Subject: dipole suppression > > Hi Robert, > > sorry for the delay. > > The dipole suppression is indeed a complex issue. > We first implemented it because it facilitates visualization and the > exact identification of the first > strongest local maxima. > Nevertheless, it is quite dangerous because the map is (locally) > distorted in a non-trivial way. > We are now trying to move away from suppressing the sources. I think > it would be better to identify the > significant local maxima (significance based on > randomization/permutation). > But what we are doing at the moment is your approach 3. > So we add the supdip leadfield to the noise covariance matrix and look > at pow/noise. > > For coherence we are basically doing the same thing. > So we divide the coherence map (or actually the map of cross spectral > densities) by a noise map > that peaks at the locations of the "unwanted" dipoles. > With this procedure we loose absolute coherence values. > This is not so important for us since we get the absolute values from > the coherence and partial coherence spectra > that are computed afterwards. > It works surprisingly well but should be used with care. > > A better approach would be to map partial coherence (with the unwanted > dipoles removed). But we have not implemented > this so far. > > Again, I think it is better to have regions of interest identified by > their significance. > > Joachim ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Fri Oct 22 17:15:49 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Fri, 22 Oct 2004 11:15:49 -0400 Subject: coherence normalization In-Reply-To: Message-ID: On Thu, 21 Oct 2004, Robert Oostenveld wrote: > The dominating effect of the refdip is indeed very problematic. > ... Better test and map the significance of the difference in > coherence between two conditions using randomization of the > trials before the coherence is beamed ... Yes. What I finally did was to export the coherence volumes to AFNI, and run an ANOVA (four conditions by eight subjects; it took 24 hours for Matlab to calculate the volumes at 1 cm resolution, and I don't even have as many trials as I would like). The means across conditions of course show the refdip source but the contrasts in the ANOVA (which are basically subtractions) nicely cancelled them out, leaving cool-looking effects. :-) Now, how can I extract the phase? Is that stored somehere? Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From r.oostenveld at FCDONDERS.RU.NL Fri Oct 22 17:55:17 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 22 Oct 2004 17:55:17 +0200 Subject: coherence normalization In-Reply-To: Message-ID: Hi Tom On 22 Oct 2004, at 17:15, Tom Holroyd wrote: > Yes. What I finally did was to export the coherence volumes to > AFNI, and run an ANOVA (four conditions by eight subjects; it > took 24 hours for Matlab to calculate the volumes at 1 cm > resolution, and I don't even have as many trials as I would > like). The means across conditions of course show the refdip > source but the contrasts in the ANOVA (which are basically > subtractions) nicely cancelled them out, leaving cool-looking > effects. :-) Sounds interesting. But why are you running an ANOVA? The coherence in a voxel will not be normally distributed. Furthermore, it does not allow for a decent multiple comparison correction (except bonferoni), since GRFT does not apply. Did you try sourcestatistics with method randomization or randcluster? They do multiple comparison correction. > Now, how can I extract the phase? Is that stored somehere? Hmm, no it's not, neither is the orientation. Source.avg.coh is only the coherence in the dominant direction. I think that the sourceanalysis option keepcsd=yes will help you here, but am not 100% sure (should look into it). Conceptually, there are 6 dipoles (2*xyz) and hence a 6x6 cross-spectral density matrix will be returned as source.avg.csd (cell-array). That will tell you exactly what the coherence is in which combination of directions of the two source locations. Sofar no one ever asker me for the phase, but it would be interesting to do some more postprocessing of the source.avg.csd matrices to make something like phase easier to plot. I would like to hear suggestions. (Same applies for beamed power, where there is also a dominant dipole orientation which is neglecetd sofar). best regards Robert PS there are some "hidden" options for paralellization in Fieldtrip, of which not all code is shared under GPL. Contact me directly if you have a bunch of linux nodes and if you are interested. ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Fri Oct 22 18:25:17 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Fri, 22 Oct 2004 12:25:17 -0400 Subject: coherence normalization In-Reply-To: Message-ID: > Sounds interesting. But why are you running an ANOVA? The coherence in > a voxel will not be normally distributed. You'd think that, wouldn't you? :-) [By the way, that's an American expression meaning roughly, I'm just as surprised as you are.] Here's a random sample, from subject 6, condition 4: #Magnitude Freq Cum_Freq -2.124902 21 21 -1.874683 47 68 -1.624463 74 142 -1.374243 134 276 -1.124023 180 456 -0.873804 208 664 -0.623584 249 913 -0.373364 323 1236 -0.123144 2052 3288 0.127076 343 3631 0.377295 264 3895 0.627515 219 4114 0.877735 161 4275 1.127955 114 4389 1.378175 72 4461 1.628394 47 4508 1.878614 33 4541 2.128834 16 4557 2.379054 2 4559 2.629274 1 4560 These coherence values have already been z-scored. That's something I forgot to mention before -- since the coherence values turn out to be not too badly distributed, and since I'm only interested in the differences anyway, I z-scored 'em. > Furthermore, it does not allow for a decent multiple comparison > correction (except bonferoni), since GRFT does not apply. That's true, but my experience has been that normalizing the distributions (so that individual differences in power levels between subjects are eliminated) has almost exactly the same effect as a random permutation analysis (which I have done, but not on these data). The beamformers apparently provide quite a lot of independence already (you know, it's all coming from the same CSD matrix, but each voxel has a large prior in the form of the forward solution -- somebody should write a paper about that). And since the coherence is normalized anyway, it's fine. I can always do a permutation analysis later, by shuffling the conditions and rerunning the ANOVAs a few thousand times (they are very fast). > Did you try sourcestatistics with method randomization or > randcluster? They do multiple comparison correction. You mean sourcedescriptives? No, I haven't, but I will. I was in a hurry (Neuroscience is next week, you know). Did I mention it took 24 hours to calculate all the volumes? (Yes, I know, use the Beowulf cluster. NIH's cluster is called "Biowulf". Ha ha.) > Sofar no one ever asker me for the phase, but it would be interesting > to do some more postprocessing of the source.avg.csd matrices to make > something like phase easier to plot. I would like to hear suggestions. Let me think about that for a while. Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From t.montez at VUMC.NL Mon Oct 25 12:12:47 2004 From: t.montez at VUMC.NL (Montez, T.) Date: Mon, 25 Oct 2004 12:12:47 +0200 Subject: old Matlab version gives errors Message-ID: Hi, When using Matlab version 6.0.0.88 Release 12 and trying to read the header from the .res4 file I run into this error message: >> hdr = read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012-4channels.res4'); ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file written by a newer version of MATLAB and cannot be read. Error in ==> E:\Matlab\fieldtrip-0.9.2\read_fcdc_header.m On line 71 ==> hdr = read_ctf_res4(headerfile); Best regards, Teresa Montez From r.oostenveld at FCDONDERS.RU.NL Mon Oct 25 14:43:49 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 25 Oct 2004 14:43:49 +0200 Subject: old Matlab version gives errors In-Reply-To: <04Oct25.121455cest.335087@nucleus.azvu.nl> Message-ID: Dear Teresa, Matlab version 6.0 (release 12) is already quite old and, since around 2001, release versions 12.1, 13, 14 and 14.1 have been released. In general the development of Fieldtrip is done with the most recent matlab versions, or one version older. Since I do not have access to Matlab 6.0, I cannot help you with your problem. Please upgrade to a newer version of Matlab. I do still have Matlab 6.1, and know that the p-files and the mex-files will work with that version. That means that Matlab 6.1 is the minimum requirement. best regards, Robert On 25 Oct 2004, at 12:12, Montez, T. wrote: > Hi, > > When using Matlab version 6.0.0.88 Release 12 and trying to read the > header > from the .res4 file I run into this error message: > >>> hdr = > read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012 > -4channels.res4'); > ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file > written by > a newer > version of MATLAB and cannot be read. > > Error in ==> E:\Matlab\fieldtrip-0.9.2\read_fcdc_header.m > On line 71 ==> hdr = read_ctf_res4(headerfile); > > Best regards, > Teresa Montez ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Mon Oct 25 17:04:28 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Mon, 25 Oct 2004 11:04:28 -0400 Subject: old Matlab version gives errors In-Reply-To: <04Oct25.121455cest.335087@nucleus.azvu.nl> Message-ID: > read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012-4channels.res4'); > ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file written by > a newer > version of MATLAB and cannot be read. Maybe some nice person can incorporate this code: http://kurage.nimh.nih.gov/software/ctf2matlab.tgz Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From matsuham at NINDS.NIH.GOV Sun Oct 31 20:32:14 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Sun, 31 Oct 2004 14:32:14 -0500 Subject: freqdescriptives Message-ID: Dear Robert, 1. Thanks to your suggestion, now I can somehow calculate and plot the planar distribution of coherence. It goes something like this. ============================= % data -> planar gradiometer interpolation (before freq analysis) cfg.planar = 'yes'; cfg.planarmethod='fitplane'; dataP=meginterpolate(cfg,data); %Huge!! % freq analysis (MTM) cfg=[]; cfg.method = 'fft'; cfg.foilim = [0,20] cfg.tapsmofrq=0.5; cfg.sgncmb = channelcombination({'MEG' 'REF'},dataP.label); cfg.output = 'powandcsd' cfg.pad='maxperlen'; cfg.keeptrials = 'yes' [freqP] = freqanalysis(cfg, dataP) % calc coherence freqPR=freqdescriptives(cfg, freqP) % combine V/H channels for n=1:274 freqPRC.powspctrm(n,:)=mean(freqPR.powspctrm([n;n+274],:)); freqPRC.powspctrmsem(n,:)=mean(freqPR.powspctrmsem([n;n+274],:)); freqPRC.cohspctrm(n,:)=mean(freqPR.cohspctrm([n;n+274],:)); freqPRC.cohspctrmsem(n,:)=mean(freqPR.cohspctrmsem([n;n+274],:)); freqPRC.labelcmb(n,:)=freqPR.labelcmb(n,:); freqPRC.label{n}=freqPR.label{n}(1:5); end n=275 %REF channel freqPRC.powspctrm(n,:)=mean(freqPR.powspctrm([n+274],:)); freqPRC.powspctrmsem(n,:)=mean(freqPR.powspctrmsem([n+274],:)); freqPRC.label(n,:)=freqPR.label(n+274,:) ================================ 2. Do you have any suggestion which of three simple interpolation method ('orig' | 'sincos' | 'fitplane') to use in megplanar? The 'orig' method requires less memory, but seems less reliable.... I checked with SEF N20m data and the 'orig' method produced four peaks in the gradient contour map. The 'fitplane' seems best among the three in this respect, am I right? 3. Thank you for the suggestion of EOG artifact. Finally, I noticed it was my silly mistake that I found such strange source distribution. I am now using >> cfg.funparameter='coh'; Instead of >> cfg.funparameter='pow'; This way I can see nice picture. Thank you again!! Regards, Masaa ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From matsuham at NINDS.NIH.GOV Wed Oct 6 01:32:13 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Tue, 5 Oct 2004 19:32:13 -0400 Subject: Question: Read_ctf_rc usw.. Message-ID: Hi, I am interested in DICS and now started to struggle with FieldTrip 0.92. I was very impressed by Dr. Schoffelen's presentation at BIOMAG 2004. First, I thank you very much for your effort to make this fascinating and promising toolbox to public. Then, among lots of questions, 1) I couldn't find the script 'read_ctf_hc' as described in the document 'Localizing oscillatory sources using beamformer techniques'. How can I obtain one? 2) I am almost at a loss how to start. Can I have some brief description of how to do DICS kind of analysis? Let me say, 600Hz, 4 min single trial dataset: Foo_trial_01.ds (a folder in current directory) Reference signal vector of the same length: RefSignal (14400 x 1 double array in matlab workspace) MRI/head information in Foo.mri, Foo.hdm, Foo.shape and Foo_trial_01.ds/localSpheres.hdm. If the cross-spectra should be calculated before using FieldTrip, I can do the calculation and the cross-spectra between RefSignal and all channels in Foo_trial_01 will be stored in Fxy_trial_01 (274 x 1024 double array (complex)) --- 274 is the number of MEG sensors. What should I do next? Thank you for your attention, Masao ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From Jan.Schoffelen at FCDONDERS.RU.NL Thu Oct 7 14:58:46 2004 From: Jan.Schoffelen at FCDONDERS.RU.NL (J.M. Schoffelen) Date: Thu, 7 Oct 2004 14:58:46 +0200 Subject: Question: Read_ctf_rc usw.. Message-ID: -----Original Message----- From: J.M. Schoffelen [mailto:Jan.Schoffelen at fcdonders.ru.nl] Sent: Thursday, October 07, 2004 2:48 PM To: 'FieldTrip discussion list' Subject: RE: [FIELDTRIP] Question: Read_ctf_rc usw.. Dear Masao, >I am interested in DICS and now started to struggle with FieldTrip 0.92. Glad to hear that. >1) I couldn't find the script 'read_ctf_hc' as described in the document >'Localizing oscillatory sources using beamformer techniques'. How can I >obtain one? First of all, we are very sorry, but the tutorials to which you have access are not really up-to-date. That's important to realize. So the best information about the functions is to be found in the help-documentation of the function itself. So, don't worry about read_ctf_hc, since that is an old function, and not needed any more, since its functionality is covered by other functions. >2) I am almost at a loss how to start. Can I have some brief description of >how to do DICS kind of analysis? Let me say, >600Hz, 4 min single trial dataset: Foo_trial_01.ds (a folder in current >directory) >Reference signal vector of the same length: RefSignal (14400 x 1 double >array in matlab workspace) >MRI/head information in Foo.mri, Foo.hdm, Foo.shape and >Foo_trial_01.ds/localSpheres.hdm. >If the cross-spectra should be calculated before using FieldTrip, I can do >the calculation and the cross-spectra between RefSignal and all channels in >Foo_trial_01 will be stored in Fxy_trial_01 (274 x 1024 double array >(complex)) --- 274 is the number of MEG sensors. >What should I do next? In general, I would tackle the problem in the following way: from your description of your data I cannot judge if your reference-signal is also present in the .meg4-file, or that it is obtained from somewhere else. But that's a minor point. I would not calculate my csd's outside fieldtrip, but I would use the preprocessing-function to read in my data, not as a single trial, but cut in, say, 5-second pieces (I guess you will not need a frequency-resolution of 1/240 Hz/bin). Consecutively, I would read in my reference signal, using the same trial-configuration as used in your meg-data. (This would only work if your reference signal is in your .meg4 file, otherwise you have to find out a smart trick to combine the corresponding meg-data/reference-data.) Then you have to apply a trick, and store your reference-data and meg-data in the same structure. So, if your meg-data is contained in data, and your reference data in refdata (with identical trials), I would do this: for loop = 1:length(data.trial) data.trial{loop}=[data.trial{loop};refdata.trial{loop}]; end data.label=[data.label;refdata.label]; Now you're ready to compute your crosspectra (apparently you already obtained something like that), by using freqanalysis, and your coherencespectra by using freqdescriptives on the output of freqanalysis. By visualising the coherence on the sensor-level, you are able to locate the frequencies, at which the coherence might be interesting. Then (following the tutorial, with some variations), go back to frequency-analysis, taking as cfg.foilim your frequency-band of interest, and for your signal-combinations: cfg.sgncmb = channelcombination({'MEG' 'MEG';'MEG' '$label of your reference signal'},data.label); If you then run freqanalysis you'll end up with an awful lot of csd's. This will be your input into sourceanalysis. For this, you could perfectly well follow the tutorial, but you have to change "cfg.method='power'" into "cfg.method = 'coh_refchan'", and you have to add to your configuration: cfg.refchannel = '$label of your reference signal'. Hopefully this helps you a bit to get on track, Jan-Mathijs From matsuham at NINDS.NIH.GOV Fri Oct 8 03:46:19 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Thu, 7 Oct 2004 21:46:19 -0400 Subject: Question: Read_ctf_rc usw.. Message-ID: Dear Jan-Mathijs, Thank you very much for the description. Now I am trying... Actually the reference signal is not included in the dataset, so I did as follows: ======================== % load data, in 5 sec segments cfg.dataset='X:\raid\DOSTPIDM_track_20040826_01.ds' % 6+ min, 600Hz data, 219600 time points cfg.trl=[[1:3000:219600-3000]',[3000:3000:219600]',zeros(fix(219600/3000),1) ] cfg.channel='MEG' cfg.detrend='yes' data=preprocessing(cfg) %take some time, so do it only neccesory. % combine with ref signal w{} for loop = 1:length(data.trial) data.trial{loop}=[data.trial{loop}; w{1}([1:3000]+3000*(loop-1),1)']; %w is a cell array of ref signals (219600 x 2 matrix) end data.label=[data.label;{'REF'}]; % freq analysis cfg=[]; cfg.method = 'fft'; cfg.sgncmb = channelcombination({'MEG' 'REF'},data.label); cfg.output = 'powandcsd' cfg.foilim = [0,20] cfg.tapsmofrq=0.5; cfg.pad='maxperlen'; [freq] = freqanalysis(cfg, data) freq=freqdescriptives(cfg, freq) ========================== And I encountered an error: ========================== .... processing trial 71, nfft: 3000 samples, taper length: 3000 samples, 4 tapers processing trial 72, nfft: 3000 samples, taper length: 3000 samples, 4 tapers processing trial 73, nfft: 3000 samples, taper length: 3000 samples, 4 tapers freq = label: {275x1 cell} sgn: {275x1 cell} dimord: 'sgncmb_frq' powspctrm: [275x101 double] sgncmb: {274x2 cell} labelcmb: {274x2 cell} crsspctrm: [274x101 double] foi: [1x101 double] grad: [1x1 struct] cfg: [1x1 struct] ??? Reference to non-existent field 'pow'. Error in ==> C:\MATLAB\fieldtrip\freqdescriptives.m On line 207 ==> frqjck.powspctrm = frqjck.pow; >> =========================== I think I am doing something wrong...... ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From Jan.Schoffelen at FCDONDERS.RU.NL Fri Oct 8 08:40:40 2004 From: Jan.Schoffelen at FCDONDERS.RU.NL (J.M. Schoffelen) Date: Fri, 8 Oct 2004 08:40:40 +0200 Subject: freqdescriptives In-Reply-To: <6EF659D3CB8D724BBA76CF97214D8DAC0B640BE4@nihexchange17.nih.gov> Message-ID: Dear Masao, =========================== freq = label: {275x1 cell} sgn: {275x1 cell} dimord: 'sgncmb_frq' powspctrm: [275x101 double] sgncmb: {274x2 cell} labelcmb: {274x2 cell} crsspctrm: [274x101 double] foi: [1x101 double] grad: [1x1 struct] cfg: [1x1 struct] ??? Reference to non-existent field 'pow'. Error in ==> C:\MATLAB\fieldtrip\freqdescriptives.m On line 207 ==> frqjck.powspctrm = frqjck.pow; >> =========================== This is not your fault, it is an innocent but annoying bug in the function. If you re-run the freqanalysis-part, while putting in the configuration: cfg.keeptrials = 'yes'; then it should work fine. Yours, Jan-Mathijs From matsuham at NINDS.NIH.GOV Sun Oct 10 02:17:42 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Sat, 9 Oct 2004 20:17:42 -0400 Subject: freqdescriptives Message-ID: Dear Jan-Mathijs, Thank you. Now that error is gone and I can see the the distribution of something. As often the case with a beginer, despite the nice distribution of coherence itself in the occipital area as shown by multiplotER and topoplotER, the distribution of coherent source activity is somewhat odd (symmetric medial orbitofrontal). Here is my procedure. If you find any mistake, they are very, very appreciated. The head-model is the one I am using for SAM analysis, so it should be all right. ====================================================================== load data % DICS step1 cfg=[]; cfg.method = 'fft'; cfg.output = 'powandcsd' cfg.tapsmofrq=0.5; cfg.pad='maxperlen'; cfg.keeptrials = 'yes' cfg.foilim = [5.8,6.2]; cfg.sgncmb = channelcombination({'MEG' 'MEG';'MEG' 'REF'},data.label); [freqDICS] = freqanalysis(cfg, data) % DICS step 2 cfg=[]; cfg.refchannel ='REF'; cfg.method = 'coh_refchan'; cfg.projectnoise='yes'; cfg.hdmfile='X:\raid\DOSTPIDM_track_20040826_01.ds\localSpheres.hdm' cfg.frequency=6; cfg.lambda=1e-31; cfg.xgrid='auto'; cfg.ygrid='auto'; cfg.zgrid='auto'; cfg.resolution=2; cfg.keepleadfield='no'; source=sourceanalysis(cfg,freqDICS); mriFile='X:\raid\mri\DOSTPIDM.mri'; cfg.downsample=2; cfg.parameter='pow'; cfg.funparameter='pow'; sourceInterp=sourceinterpolate(cfg,source,mriFile); figure;sliceinterp(cfg,sourceInterp); ======================================================================= To check my data farther, I want to use megplanar to check the gradient contour map but it doesn't accept freqanalysis data... (T^T) Thank you again for your kind help, Masao ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From r.oostenveld at FCDONDERS.RU.NL Mon Oct 11 09:50:53 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 11 Oct 2004 09:50:53 +0200 Subject: freqdescriptives In-Reply-To: <6EF659D3CB8D724BBA76CF97214D8DAC0B640CE8@nihexchange17.nih.gov> Message-ID: Dear Masao, On 10 Oct 2004, at 2:17, Matsuhashi, Masao (NIH/NINDS) wrote: > To check my data farther, I want to use megplanar to check the gradient > contour map but it doesn't accept freqanalysis data... (T^T) It is theoretically not possible to compute the planar gradient from a frequency representation of the data. However, you can compute the frequency representation of a planar gradient. In your case therefore the computation of planar gradients has to be done before the computation of the frequency representation of that data, i.e. the sequence is preprocessing->megplanar->freqanalysis. Subsequently you have to combine the coherence between the reference channel and both planar gradients on a given sensor location into a single number. That single number (e.g. average or maximum coherence for the two planar gradients on that sensor location) can be plotted topographically. Combining coherence over the planar channels and topoplotting it is not yet implemented in FieldTrip in a straightforward way, therefore you have to fiddle with the datastructures yourself. Since you note that you see something symmetric medial orbitofrontal which is not expected, I also suggest that you carefully check whether you are not merely looking at some EOG artefacts in your data. There is a EOG artifact detection algorithm which you can use, and you should look at your raw data after preprocessing to ensure that it is clean. best regards, Robert ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Thu Oct 21 17:23:15 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Thu, 21 Oct 2004 11:23:15 -0400 Subject: coherence normalization Message-ID: When running a coherence volume using a reference dipole, one naturally expects the coherence will be high around the reference dipole. This effect tends to dominate the images. Is there a way to normalize the coherence volume to eliminate this effect? Perhaps by dividing by the coherence in a "control" state? Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From r.oostenveld at FCDONDERS.RU.NL Thu Oct 21 17:48:40 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 21 Oct 2004 17:48:40 +0200 Subject: coherence normalization In-Reply-To: Message-ID: On 21 Oct 2004, at 17:23, Tom Holroyd wrote: > When running a coherence volume using a reference dipole, one > naturally expects the coherence will be high around the reference > dipole. > > This effect tends to dominate the images. > > Is there a way to normalize the coherence volume to eliminate > this effect? Perhaps by dividing by the coherence in a "control" > state? Hi Tom, The dominating effect of the refdip is indeed very problematic. I just happened to have discussed this with Joachim Gross, and I have included our email exchange below. Please first read that ... Basically I agree with Joachim, and I don't trust the supdip that is implemented in FieldTrip's sourceanalysis function. Better test and map the significance of the difference in coherence between two conditions using randomization of the trials before the coherence is beamed (that is implemented in sourceanalysis + sourcestatistics). Robert -------------------------------------------------------------------- my question to Joachim was ---------------------------------------------------------------------- Begin forwarded message: > From: Robert Oostenveld > Date: 1 October 2004 10:26:02 GMT+02:00 > To: Joachim Gross > Subject: dipole suppression > > Hi Joachim, > > What I always still had to ask you is how you do supression of dipoles > in DICS, especially in the case of coherence imaging. I have thought > of two ways of projecting them out: > > 1) compute supdip leadfield and its projection on the COV/CSD matrix, > then project it out of the COV/CSD matrix (which looses 2 or 3 from > its rank). > > 2) compute supdip leadfield and add it to the leadfield of the dipole > with which is scanned (scandip). Subsequently compute the source > COV/CSD on those 6 leadfield components and select the 3x3 submatrix > that corresponds with the scandip to continue the computations with. > > Both methods don't really gave me very convincing results. A third > approach would be to add the supdip leadfield to the (identity) noise > matrix and project it through the filters. Then nai=pow/noise is > corrected for the presence of the supdip, but that does not result in > a supressed source coherence distribution. What is your idea or > approach for this? > > best regards > Robert > ---------------------------------------------------------------------- and his answer (Joachim, I hope you don't mind me sharing this on the list) ---------------------------------------------------------------------- Begin forwarded message: > From: Joachim Gross > Date: 14 October 2004 17:20:45 GMT+02:00 > To: "robert.oostenveld at fcdonders.kun.nl" > > Subject: dipole suppression > > Hi Robert, > > sorry for the delay. > > The dipole suppression is indeed a complex issue. > We first implemented it because it facilitates visualization and the > exact identification of the first > strongest local maxima. > Nevertheless, it is quite dangerous because the map is (locally) > distorted in a non-trivial way. > We are now trying to move away from suppressing the sources. I think > it would be better to identify the > significant local maxima (significance based on > randomization/permutation). > But what we are doing at the moment is your approach 3. > So we add the supdip leadfield to the noise covariance matrix and look > at pow/noise. > > For coherence we are basically doing the same thing. > So we divide the coherence map (or actually the map of cross spectral > densities) by a noise map > that peaks at the locations of the "unwanted" dipoles. > With this procedure we loose absolute coherence values. > This is not so important for us since we get the absolute values from > the coherence and partial coherence spectra > that are computed afterwards. > It works surprisingly well but should be used with care. > > A better approach would be to map partial coherence (with the unwanted > dipoles removed). But we have not implemented > this so far. > > Again, I think it is better to have regions of interest identified by > their significance. > > Joachim ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Fri Oct 22 17:15:49 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Fri, 22 Oct 2004 11:15:49 -0400 Subject: coherence normalization In-Reply-To: Message-ID: On Thu, 21 Oct 2004, Robert Oostenveld wrote: > The dominating effect of the refdip is indeed very problematic. > ... Better test and map the significance of the difference in > coherence between two conditions using randomization of the > trials before the coherence is beamed ... Yes. What I finally did was to export the coherence volumes to AFNI, and run an ANOVA (four conditions by eight subjects; it took 24 hours for Matlab to calculate the volumes at 1 cm resolution, and I don't even have as many trials as I would like). The means across conditions of course show the refdip source but the contrasts in the ANOVA (which are basically subtractions) nicely cancelled them out, leaving cool-looking effects. :-) Now, how can I extract the phase? Is that stored somehere? Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From r.oostenveld at FCDONDERS.RU.NL Fri Oct 22 17:55:17 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 22 Oct 2004 17:55:17 +0200 Subject: coherence normalization In-Reply-To: Message-ID: Hi Tom On 22 Oct 2004, at 17:15, Tom Holroyd wrote: > Yes. What I finally did was to export the coherence volumes to > AFNI, and run an ANOVA (four conditions by eight subjects; it > took 24 hours for Matlab to calculate the volumes at 1 cm > resolution, and I don't even have as many trials as I would > like). The means across conditions of course show the refdip > source but the contrasts in the ANOVA (which are basically > subtractions) nicely cancelled them out, leaving cool-looking > effects. :-) Sounds interesting. But why are you running an ANOVA? The coherence in a voxel will not be normally distributed. Furthermore, it does not allow for a decent multiple comparison correction (except bonferoni), since GRFT does not apply. Did you try sourcestatistics with method randomization or randcluster? They do multiple comparison correction. > Now, how can I extract the phase? Is that stored somehere? Hmm, no it's not, neither is the orientation. Source.avg.coh is only the coherence in the dominant direction. I think that the sourceanalysis option keepcsd=yes will help you here, but am not 100% sure (should look into it). Conceptually, there are 6 dipoles (2*xyz) and hence a 6x6 cross-spectral density matrix will be returned as source.avg.csd (cell-array). That will tell you exactly what the coherence is in which combination of directions of the two source locations. Sofar no one ever asker me for the phase, but it would be interesting to do some more postprocessing of the source.avg.csd matrices to make something like phase easier to plot. I would like to hear suggestions. (Same applies for beamed power, where there is also a dominant dipole orientation which is neglecetd sofar). best regards Robert PS there are some "hidden" options for paralellization in Fieldtrip, of which not all code is shared under GPL. Contact me directly if you have a bunch of linux nodes and if you are interested. ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Fri Oct 22 18:25:17 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Fri, 22 Oct 2004 12:25:17 -0400 Subject: coherence normalization In-Reply-To: Message-ID: > Sounds interesting. But why are you running an ANOVA? The coherence in > a voxel will not be normally distributed. You'd think that, wouldn't you? :-) [By the way, that's an American expression meaning roughly, I'm just as surprised as you are.] Here's a random sample, from subject 6, condition 4: #Magnitude Freq Cum_Freq -2.124902 21 21 -1.874683 47 68 -1.624463 74 142 -1.374243 134 276 -1.124023 180 456 -0.873804 208 664 -0.623584 249 913 -0.373364 323 1236 -0.123144 2052 3288 0.127076 343 3631 0.377295 264 3895 0.627515 219 4114 0.877735 161 4275 1.127955 114 4389 1.378175 72 4461 1.628394 47 4508 1.878614 33 4541 2.128834 16 4557 2.379054 2 4559 2.629274 1 4560 These coherence values have already been z-scored. That's something I forgot to mention before -- since the coherence values turn out to be not too badly distributed, and since I'm only interested in the differences anyway, I z-scored 'em. > Furthermore, it does not allow for a decent multiple comparison > correction (except bonferoni), since GRFT does not apply. That's true, but my experience has been that normalizing the distributions (so that individual differences in power levels between subjects are eliminated) has almost exactly the same effect as a random permutation analysis (which I have done, but not on these data). The beamformers apparently provide quite a lot of independence already (you know, it's all coming from the same CSD matrix, but each voxel has a large prior in the form of the forward solution -- somebody should write a paper about that). And since the coherence is normalized anyway, it's fine. I can always do a permutation analysis later, by shuffling the conditions and rerunning the ANOVAs a few thousand times (they are very fast). > Did you try sourcestatistics with method randomization or > randcluster? They do multiple comparison correction. You mean sourcedescriptives? No, I haven't, but I will. I was in a hurry (Neuroscience is next week, you know). Did I mention it took 24 hours to calculate all the volumes? (Yes, I know, use the Beowulf cluster. NIH's cluster is called "Biowulf". Ha ha.) > Sofar no one ever asker me for the phase, but it would be interesting > to do some more postprocessing of the source.avg.csd matrices to make > something like phase easier to plot. I would like to hear suggestions. Let me think about that for a while. Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From t.montez at VUMC.NL Mon Oct 25 12:12:47 2004 From: t.montez at VUMC.NL (Montez, T.) Date: Mon, 25 Oct 2004 12:12:47 +0200 Subject: old Matlab version gives errors Message-ID: Hi, When using Matlab version 6.0.0.88 Release 12 and trying to read the header from the .res4 file I run into this error message: >> hdr = read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012-4channels.res4'); ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file written by a newer version of MATLAB and cannot be read. Error in ==> E:\Matlab\fieldtrip-0.9.2\read_fcdc_header.m On line 71 ==> hdr = read_ctf_res4(headerfile); Best regards, Teresa Montez From r.oostenveld at FCDONDERS.RU.NL Mon Oct 25 14:43:49 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 25 Oct 2004 14:43:49 +0200 Subject: old Matlab version gives errors In-Reply-To: <04Oct25.121455cest.335087@nucleus.azvu.nl> Message-ID: Dear Teresa, Matlab version 6.0 (release 12) is already quite old and, since around 2001, release versions 12.1, 13, 14 and 14.1 have been released. In general the development of Fieldtrip is done with the most recent matlab versions, or one version older. Since I do not have access to Matlab 6.0, I cannot help you with your problem. Please upgrade to a newer version of Matlab. I do still have Matlab 6.1, and know that the p-files and the mex-files will work with that version. That means that Matlab 6.1 is the minimum requirement. best regards, Robert On 25 Oct 2004, at 12:12, Montez, T. wrote: > Hi, > > When using Matlab version 6.0.0.88 Release 12 and trying to read the > header > from the .res4 file I run into this error message: > >>> hdr = > read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012 > -4channels.res4'); > ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file > written by > a newer > version of MATLAB and cannot be read. > > Error in ==> E:\Matlab\fieldtrip-0.9.2\read_fcdc_header.m > On line 71 ==> hdr = read_ctf_res4(headerfile); > > Best regards, > Teresa Montez ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Mon Oct 25 17:04:28 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Mon, 25 Oct 2004 11:04:28 -0400 Subject: old Matlab version gives errors In-Reply-To: <04Oct25.121455cest.335087@nucleus.azvu.nl> Message-ID: > read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012-4channels.res4'); > ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file written by > a newer > version of MATLAB and cannot be read. Maybe some nice person can incorporate this code: http://kurage.nimh.nih.gov/software/ctf2matlab.tgz Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From matsuham at NINDS.NIH.GOV Sun Oct 31 20:32:14 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Sun, 31 Oct 2004 14:32:14 -0500 Subject: freqdescriptives Message-ID: Dear Robert, 1. Thanks to your suggestion, now I can somehow calculate and plot the planar distribution of coherence. It goes something like this. ============================= % data -> planar gradiometer interpolation (before freq analysis) cfg.planar = 'yes'; cfg.planarmethod='fitplane'; dataP=meginterpolate(cfg,data); %Huge!! % freq analysis (MTM) cfg=[]; cfg.method = 'fft'; cfg.foilim = [0,20] cfg.tapsmofrq=0.5; cfg.sgncmb = channelcombination({'MEG' 'REF'},dataP.label); cfg.output = 'powandcsd' cfg.pad='maxperlen'; cfg.keeptrials = 'yes' [freqP] = freqanalysis(cfg, dataP) % calc coherence freqPR=freqdescriptives(cfg, freqP) % combine V/H channels for n=1:274 freqPRC.powspctrm(n,:)=mean(freqPR.powspctrm([n;n+274],:)); freqPRC.powspctrmsem(n,:)=mean(freqPR.powspctrmsem([n;n+274],:)); freqPRC.cohspctrm(n,:)=mean(freqPR.cohspctrm([n;n+274],:)); freqPRC.cohspctrmsem(n,:)=mean(freqPR.cohspctrmsem([n;n+274],:)); freqPRC.labelcmb(n,:)=freqPR.labelcmb(n,:); freqPRC.label{n}=freqPR.label{n}(1:5); end n=275 %REF channel freqPRC.powspctrm(n,:)=mean(freqPR.powspctrm([n+274],:)); freqPRC.powspctrmsem(n,:)=mean(freqPR.powspctrmsem([n+274],:)); freqPRC.label(n,:)=freqPR.label(n+274,:) ================================ 2. Do you have any suggestion which of three simple interpolation method ('orig' | 'sincos' | 'fitplane') to use in megplanar? The 'orig' method requires less memory, but seems less reliable.... I checked with SEF N20m data and the 'orig' method produced four peaks in the gradient contour map. The 'fitplane' seems best among the three in this respect, am I right? 3. Thank you for the suggestion of EOG artifact. Finally, I noticed it was my silly mistake that I found such strange source distribution. I am now using >> cfg.funparameter='coh'; Instead of >> cfg.funparameter='pow'; This way I can see nice picture. Thank you again!! Regards, Masaa ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From matsuham at NINDS.NIH.GOV Wed Oct 6 01:32:13 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Tue, 5 Oct 2004 19:32:13 -0400 Subject: Question: Read_ctf_rc usw.. Message-ID: Hi, I am interested in DICS and now started to struggle with FieldTrip 0.92. I was very impressed by Dr. Schoffelen's presentation at BIOMAG 2004. First, I thank you very much for your effort to make this fascinating and promising toolbox to public. Then, among lots of questions, 1) I couldn't find the script 'read_ctf_hc' as described in the document 'Localizing oscillatory sources using beamformer techniques'. How can I obtain one? 2) I am almost at a loss how to start. Can I have some brief description of how to do DICS kind of analysis? Let me say, 600Hz, 4 min single trial dataset: Foo_trial_01.ds (a folder in current directory) Reference signal vector of the same length: RefSignal (14400 x 1 double array in matlab workspace) MRI/head information in Foo.mri, Foo.hdm, Foo.shape and Foo_trial_01.ds/localSpheres.hdm. If the cross-spectra should be calculated before using FieldTrip, I can do the calculation and the cross-spectra between RefSignal and all channels in Foo_trial_01 will be stored in Fxy_trial_01 (274 x 1024 double array (complex)) --- 274 is the number of MEG sensors. What should I do next? Thank you for your attention, Masao ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From Jan.Schoffelen at FCDONDERS.RU.NL Thu Oct 7 14:58:46 2004 From: Jan.Schoffelen at FCDONDERS.RU.NL (J.M. Schoffelen) Date: Thu, 7 Oct 2004 14:58:46 +0200 Subject: Question: Read_ctf_rc usw.. Message-ID: -----Original Message----- From: J.M. Schoffelen [mailto:Jan.Schoffelen at fcdonders.ru.nl] Sent: Thursday, October 07, 2004 2:48 PM To: 'FieldTrip discussion list' Subject: RE: [FIELDTRIP] Question: Read_ctf_rc usw.. Dear Masao, >I am interested in DICS and now started to struggle with FieldTrip 0.92. Glad to hear that. >1) I couldn't find the script 'read_ctf_hc' as described in the document >'Localizing oscillatory sources using beamformer techniques'. How can I >obtain one? First of all, we are very sorry, but the tutorials to which you have access are not really up-to-date. That's important to realize. So the best information about the functions is to be found in the help-documentation of the function itself. So, don't worry about read_ctf_hc, since that is an old function, and not needed any more, since its functionality is covered by other functions. >2) I am almost at a loss how to start. Can I have some brief description of >how to do DICS kind of analysis? Let me say, >600Hz, 4 min single trial dataset: Foo_trial_01.ds (a folder in current >directory) >Reference signal vector of the same length: RefSignal (14400 x 1 double >array in matlab workspace) >MRI/head information in Foo.mri, Foo.hdm, Foo.shape and >Foo_trial_01.ds/localSpheres.hdm. >If the cross-spectra should be calculated before using FieldTrip, I can do >the calculation and the cross-spectra between RefSignal and all channels in >Foo_trial_01 will be stored in Fxy_trial_01 (274 x 1024 double array >(complex)) --- 274 is the number of MEG sensors. >What should I do next? In general, I would tackle the problem in the following way: from your description of your data I cannot judge if your reference-signal is also present in the .meg4-file, or that it is obtained from somewhere else. But that's a minor point. I would not calculate my csd's outside fieldtrip, but I would use the preprocessing-function to read in my data, not as a single trial, but cut in, say, 5-second pieces (I guess you will not need a frequency-resolution of 1/240 Hz/bin). Consecutively, I would read in my reference signal, using the same trial-configuration as used in your meg-data. (This would only work if your reference signal is in your .meg4 file, otherwise you have to find out a smart trick to combine the corresponding meg-data/reference-data.) Then you have to apply a trick, and store your reference-data and meg-data in the same structure. So, if your meg-data is contained in data, and your reference data in refdata (with identical trials), I would do this: for loop = 1:length(data.trial) data.trial{loop}=[data.trial{loop};refdata.trial{loop}]; end data.label=[data.label;refdata.label]; Now you're ready to compute your crosspectra (apparently you already obtained something like that), by using freqanalysis, and your coherencespectra by using freqdescriptives on the output of freqanalysis. By visualising the coherence on the sensor-level, you are able to locate the frequencies, at which the coherence might be interesting. Then (following the tutorial, with some variations), go back to frequency-analysis, taking as cfg.foilim your frequency-band of interest, and for your signal-combinations: cfg.sgncmb = channelcombination({'MEG' 'MEG';'MEG' '$label of your reference signal'},data.label); If you then run freqanalysis you'll end up with an awful lot of csd's. This will be your input into sourceanalysis. For this, you could perfectly well follow the tutorial, but you have to change "cfg.method='power'" into "cfg.method = 'coh_refchan'", and you have to add to your configuration: cfg.refchannel = '$label of your reference signal'. Hopefully this helps you a bit to get on track, Jan-Mathijs From matsuham at NINDS.NIH.GOV Fri Oct 8 03:46:19 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Thu, 7 Oct 2004 21:46:19 -0400 Subject: Question: Read_ctf_rc usw.. Message-ID: Dear Jan-Mathijs, Thank you very much for the description. Now I am trying... Actually the reference signal is not included in the dataset, so I did as follows: ======================== % load data, in 5 sec segments cfg.dataset='X:\raid\DOSTPIDM_track_20040826_01.ds' % 6+ min, 600Hz data, 219600 time points cfg.trl=[[1:3000:219600-3000]',[3000:3000:219600]',zeros(fix(219600/3000),1) ] cfg.channel='MEG' cfg.detrend='yes' data=preprocessing(cfg) %take some time, so do it only neccesory. % combine with ref signal w{} for loop = 1:length(data.trial) data.trial{loop}=[data.trial{loop}; w{1}([1:3000]+3000*(loop-1),1)']; %w is a cell array of ref signals (219600 x 2 matrix) end data.label=[data.label;{'REF'}]; % freq analysis cfg=[]; cfg.method = 'fft'; cfg.sgncmb = channelcombination({'MEG' 'REF'},data.label); cfg.output = 'powandcsd' cfg.foilim = [0,20] cfg.tapsmofrq=0.5; cfg.pad='maxperlen'; [freq] = freqanalysis(cfg, data) freq=freqdescriptives(cfg, freq) ========================== And I encountered an error: ========================== .... processing trial 71, nfft: 3000 samples, taper length: 3000 samples, 4 tapers processing trial 72, nfft: 3000 samples, taper length: 3000 samples, 4 tapers processing trial 73, nfft: 3000 samples, taper length: 3000 samples, 4 tapers freq = label: {275x1 cell} sgn: {275x1 cell} dimord: 'sgncmb_frq' powspctrm: [275x101 double] sgncmb: {274x2 cell} labelcmb: {274x2 cell} crsspctrm: [274x101 double] foi: [1x101 double] grad: [1x1 struct] cfg: [1x1 struct] ??? Reference to non-existent field 'pow'. Error in ==> C:\MATLAB\fieldtrip\freqdescriptives.m On line 207 ==> frqjck.powspctrm = frqjck.pow; >> =========================== I think I am doing something wrong...... ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From Jan.Schoffelen at FCDONDERS.RU.NL Fri Oct 8 08:40:40 2004 From: Jan.Schoffelen at FCDONDERS.RU.NL (J.M. Schoffelen) Date: Fri, 8 Oct 2004 08:40:40 +0200 Subject: freqdescriptives In-Reply-To: <6EF659D3CB8D724BBA76CF97214D8DAC0B640BE4@nihexchange17.nih.gov> Message-ID: Dear Masao, =========================== freq = label: {275x1 cell} sgn: {275x1 cell} dimord: 'sgncmb_frq' powspctrm: [275x101 double] sgncmb: {274x2 cell} labelcmb: {274x2 cell} crsspctrm: [274x101 double] foi: [1x101 double] grad: [1x1 struct] cfg: [1x1 struct] ??? Reference to non-existent field 'pow'. Error in ==> C:\MATLAB\fieldtrip\freqdescriptives.m On line 207 ==> frqjck.powspctrm = frqjck.pow; >> =========================== This is not your fault, it is an innocent but annoying bug in the function. If you re-run the freqanalysis-part, while putting in the configuration: cfg.keeptrials = 'yes'; then it should work fine. Yours, Jan-Mathijs From matsuham at NINDS.NIH.GOV Sun Oct 10 02:17:42 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Sat, 9 Oct 2004 20:17:42 -0400 Subject: freqdescriptives Message-ID: Dear Jan-Mathijs, Thank you. Now that error is gone and I can see the the distribution of something. As often the case with a beginer, despite the nice distribution of coherence itself in the occipital area as shown by multiplotER and topoplotER, the distribution of coherent source activity is somewhat odd (symmetric medial orbitofrontal). Here is my procedure. If you find any mistake, they are very, very appreciated. The head-model is the one I am using for SAM analysis, so it should be all right. ====================================================================== load data % DICS step1 cfg=[]; cfg.method = 'fft'; cfg.output = 'powandcsd' cfg.tapsmofrq=0.5; cfg.pad='maxperlen'; cfg.keeptrials = 'yes' cfg.foilim = [5.8,6.2]; cfg.sgncmb = channelcombination({'MEG' 'MEG';'MEG' 'REF'},data.label); [freqDICS] = freqanalysis(cfg, data) % DICS step 2 cfg=[]; cfg.refchannel ='REF'; cfg.method = 'coh_refchan'; cfg.projectnoise='yes'; cfg.hdmfile='X:\raid\DOSTPIDM_track_20040826_01.ds\localSpheres.hdm' cfg.frequency=6; cfg.lambda=1e-31; cfg.xgrid='auto'; cfg.ygrid='auto'; cfg.zgrid='auto'; cfg.resolution=2; cfg.keepleadfield='no'; source=sourceanalysis(cfg,freqDICS); mriFile='X:\raid\mri\DOSTPIDM.mri'; cfg.downsample=2; cfg.parameter='pow'; cfg.funparameter='pow'; sourceInterp=sourceinterpolate(cfg,source,mriFile); figure;sliceinterp(cfg,sourceInterp); ======================================================================= To check my data farther, I want to use megplanar to check the gradient contour map but it doesn't accept freqanalysis data... (T^T) Thank you again for your kind help, Masao ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From r.oostenveld at FCDONDERS.RU.NL Mon Oct 11 09:50:53 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 11 Oct 2004 09:50:53 +0200 Subject: freqdescriptives In-Reply-To: <6EF659D3CB8D724BBA76CF97214D8DAC0B640CE8@nihexchange17.nih.gov> Message-ID: Dear Masao, On 10 Oct 2004, at 2:17, Matsuhashi, Masao (NIH/NINDS) wrote: > To check my data farther, I want to use megplanar to check the gradient > contour map but it doesn't accept freqanalysis data... (T^T) It is theoretically not possible to compute the planar gradient from a frequency representation of the data. However, you can compute the frequency representation of a planar gradient. In your case therefore the computation of planar gradients has to be done before the computation of the frequency representation of that data, i.e. the sequence is preprocessing->megplanar->freqanalysis. Subsequently you have to combine the coherence between the reference channel and both planar gradients on a given sensor location into a single number. That single number (e.g. average or maximum coherence for the two planar gradients on that sensor location) can be plotted topographically. Combining coherence over the planar channels and topoplotting it is not yet implemented in FieldTrip in a straightforward way, therefore you have to fiddle with the datastructures yourself. Since you note that you see something symmetric medial orbitofrontal which is not expected, I also suggest that you carefully check whether you are not merely looking at some EOG artefacts in your data. There is a EOG artifact detection algorithm which you can use, and you should look at your raw data after preprocessing to ensure that it is clean. best regards, Robert ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Thu Oct 21 17:23:15 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Thu, 21 Oct 2004 11:23:15 -0400 Subject: coherence normalization Message-ID: When running a coherence volume using a reference dipole, one naturally expects the coherence will be high around the reference dipole. This effect tends to dominate the images. Is there a way to normalize the coherence volume to eliminate this effect? Perhaps by dividing by the coherence in a "control" state? Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From r.oostenveld at FCDONDERS.RU.NL Thu Oct 21 17:48:40 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 21 Oct 2004 17:48:40 +0200 Subject: coherence normalization In-Reply-To: Message-ID: On 21 Oct 2004, at 17:23, Tom Holroyd wrote: > When running a coherence volume using a reference dipole, one > naturally expects the coherence will be high around the reference > dipole. > > This effect tends to dominate the images. > > Is there a way to normalize the coherence volume to eliminate > this effect? Perhaps by dividing by the coherence in a "control" > state? Hi Tom, The dominating effect of the refdip is indeed very problematic. I just happened to have discussed this with Joachim Gross, and I have included our email exchange below. Please first read that ... Basically I agree with Joachim, and I don't trust the supdip that is implemented in FieldTrip's sourceanalysis function. Better test and map the significance of the difference in coherence between two conditions using randomization of the trials before the coherence is beamed (that is implemented in sourceanalysis + sourcestatistics). Robert -------------------------------------------------------------------- my question to Joachim was ---------------------------------------------------------------------- Begin forwarded message: > From: Robert Oostenveld > Date: 1 October 2004 10:26:02 GMT+02:00 > To: Joachim Gross > Subject: dipole suppression > > Hi Joachim, > > What I always still had to ask you is how you do supression of dipoles > in DICS, especially in the case of coherence imaging. I have thought > of two ways of projecting them out: > > 1) compute supdip leadfield and its projection on the COV/CSD matrix, > then project it out of the COV/CSD matrix (which looses 2 or 3 from > its rank). > > 2) compute supdip leadfield and add it to the leadfield of the dipole > with which is scanned (scandip). Subsequently compute the source > COV/CSD on those 6 leadfield components and select the 3x3 submatrix > that corresponds with the scandip to continue the computations with. > > Both methods don't really gave me very convincing results. A third > approach would be to add the supdip leadfield to the (identity) noise > matrix and project it through the filters. Then nai=pow/noise is > corrected for the presence of the supdip, but that does not result in > a supressed source coherence distribution. What is your idea or > approach for this? > > best regards > Robert > ---------------------------------------------------------------------- and his answer (Joachim, I hope you don't mind me sharing this on the list) ---------------------------------------------------------------------- Begin forwarded message: > From: Joachim Gross > Date: 14 October 2004 17:20:45 GMT+02:00 > To: "robert.oostenveld at fcdonders.kun.nl" > > Subject: dipole suppression > > Hi Robert, > > sorry for the delay. > > The dipole suppression is indeed a complex issue. > We first implemented it because it facilitates visualization and the > exact identification of the first > strongest local maxima. > Nevertheless, it is quite dangerous because the map is (locally) > distorted in a non-trivial way. > We are now trying to move away from suppressing the sources. I think > it would be better to identify the > significant local maxima (significance based on > randomization/permutation). > But what we are doing at the moment is your approach 3. > So we add the supdip leadfield to the noise covariance matrix and look > at pow/noise. > > For coherence we are basically doing the same thing. > So we divide the coherence map (or actually the map of cross spectral > densities) by a noise map > that peaks at the locations of the "unwanted" dipoles. > With this procedure we loose absolute coherence values. > This is not so important for us since we get the absolute values from > the coherence and partial coherence spectra > that are computed afterwards. > It works surprisingly well but should be used with care. > > A better approach would be to map partial coherence (with the unwanted > dipoles removed). But we have not implemented > this so far. > > Again, I think it is better to have regions of interest identified by > their significance. > > Joachim ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Fri Oct 22 17:15:49 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Fri, 22 Oct 2004 11:15:49 -0400 Subject: coherence normalization In-Reply-To: Message-ID: On Thu, 21 Oct 2004, Robert Oostenveld wrote: > The dominating effect of the refdip is indeed very problematic. > ... Better test and map the significance of the difference in > coherence between two conditions using randomization of the > trials before the coherence is beamed ... Yes. What I finally did was to export the coherence volumes to AFNI, and run an ANOVA (four conditions by eight subjects; it took 24 hours for Matlab to calculate the volumes at 1 cm resolution, and I don't even have as many trials as I would like). The means across conditions of course show the refdip source but the contrasts in the ANOVA (which are basically subtractions) nicely cancelled them out, leaving cool-looking effects. :-) Now, how can I extract the phase? Is that stored somehere? Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From r.oostenveld at FCDONDERS.RU.NL Fri Oct 22 17:55:17 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 22 Oct 2004 17:55:17 +0200 Subject: coherence normalization In-Reply-To: Message-ID: Hi Tom On 22 Oct 2004, at 17:15, Tom Holroyd wrote: > Yes. What I finally did was to export the coherence volumes to > AFNI, and run an ANOVA (four conditions by eight subjects; it > took 24 hours for Matlab to calculate the volumes at 1 cm > resolution, and I don't even have as many trials as I would > like). The means across conditions of course show the refdip > source but the contrasts in the ANOVA (which are basically > subtractions) nicely cancelled them out, leaving cool-looking > effects. :-) Sounds interesting. But why are you running an ANOVA? The coherence in a voxel will not be normally distributed. Furthermore, it does not allow for a decent multiple comparison correction (except bonferoni), since GRFT does not apply. Did you try sourcestatistics with method randomization or randcluster? They do multiple comparison correction. > Now, how can I extract the phase? Is that stored somehere? Hmm, no it's not, neither is the orientation. Source.avg.coh is only the coherence in the dominant direction. I think that the sourceanalysis option keepcsd=yes will help you here, but am not 100% sure (should look into it). Conceptually, there are 6 dipoles (2*xyz) and hence a 6x6 cross-spectral density matrix will be returned as source.avg.csd (cell-array). That will tell you exactly what the coherence is in which combination of directions of the two source locations. Sofar no one ever asker me for the phase, but it would be interesting to do some more postprocessing of the source.avg.csd matrices to make something like phase easier to plot. I would like to hear suggestions. (Same applies for beamed power, where there is also a dominant dipole orientation which is neglecetd sofar). best regards Robert PS there are some "hidden" options for paralellization in Fieldtrip, of which not all code is shared under GPL. Contact me directly if you have a bunch of linux nodes and if you are interested. ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Fri Oct 22 18:25:17 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Fri, 22 Oct 2004 12:25:17 -0400 Subject: coherence normalization In-Reply-To: Message-ID: > Sounds interesting. But why are you running an ANOVA? The coherence in > a voxel will not be normally distributed. You'd think that, wouldn't you? :-) [By the way, that's an American expression meaning roughly, I'm just as surprised as you are.] Here's a random sample, from subject 6, condition 4: #Magnitude Freq Cum_Freq -2.124902 21 21 -1.874683 47 68 -1.624463 74 142 -1.374243 134 276 -1.124023 180 456 -0.873804 208 664 -0.623584 249 913 -0.373364 323 1236 -0.123144 2052 3288 0.127076 343 3631 0.377295 264 3895 0.627515 219 4114 0.877735 161 4275 1.127955 114 4389 1.378175 72 4461 1.628394 47 4508 1.878614 33 4541 2.128834 16 4557 2.379054 2 4559 2.629274 1 4560 These coherence values have already been z-scored. That's something I forgot to mention before -- since the coherence values turn out to be not too badly distributed, and since I'm only interested in the differences anyway, I z-scored 'em. > Furthermore, it does not allow for a decent multiple comparison > correction (except bonferoni), since GRFT does not apply. That's true, but my experience has been that normalizing the distributions (so that individual differences in power levels between subjects are eliminated) has almost exactly the same effect as a random permutation analysis (which I have done, but not on these data). The beamformers apparently provide quite a lot of independence already (you know, it's all coming from the same CSD matrix, but each voxel has a large prior in the form of the forward solution -- somebody should write a paper about that). And since the coherence is normalized anyway, it's fine. I can always do a permutation analysis later, by shuffling the conditions and rerunning the ANOVAs a few thousand times (they are very fast). > Did you try sourcestatistics with method randomization or > randcluster? They do multiple comparison correction. You mean sourcedescriptives? No, I haven't, but I will. I was in a hurry (Neuroscience is next week, you know). Did I mention it took 24 hours to calculate all the volumes? (Yes, I know, use the Beowulf cluster. NIH's cluster is called "Biowulf". Ha ha.) > Sofar no one ever asker me for the phase, but it would be interesting > to do some more postprocessing of the source.avg.csd matrices to make > something like phase easier to plot. I would like to hear suggestions. Let me think about that for a while. Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From t.montez at VUMC.NL Mon Oct 25 12:12:47 2004 From: t.montez at VUMC.NL (Montez, T.) Date: Mon, 25 Oct 2004 12:12:47 +0200 Subject: old Matlab version gives errors Message-ID: Hi, When using Matlab version 6.0.0.88 Release 12 and trying to read the header from the .res4 file I run into this error message: >> hdr = read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012-4channels.res4'); ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file written by a newer version of MATLAB and cannot be read. Error in ==> E:\Matlab\fieldtrip-0.9.2\read_fcdc_header.m On line 71 ==> hdr = read_ctf_res4(headerfile); Best regards, Teresa Montez From r.oostenveld at FCDONDERS.RU.NL Mon Oct 25 14:43:49 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 25 Oct 2004 14:43:49 +0200 Subject: old Matlab version gives errors In-Reply-To: <04Oct25.121455cest.335087@nucleus.azvu.nl> Message-ID: Dear Teresa, Matlab version 6.0 (release 12) is already quite old and, since around 2001, release versions 12.1, 13, 14 and 14.1 have been released. In general the development of Fieldtrip is done with the most recent matlab versions, or one version older. Since I do not have access to Matlab 6.0, I cannot help you with your problem. Please upgrade to a newer version of Matlab. I do still have Matlab 6.1, and know that the p-files and the mex-files will work with that version. That means that Matlab 6.1 is the minimum requirement. best regards, Robert On 25 Oct 2004, at 12:12, Montez, T. wrote: > Hi, > > When using Matlab version 6.0.0.88 Release 12 and trying to read the > header > from the .res4 file I run into this error message: > >>> hdr = > read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012 > -4channels.res4'); > ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file > written by > a newer > version of MATLAB and cannot be read. > > Error in ==> E:\Matlab\fieldtrip-0.9.2\read_fcdc_header.m > On line 71 ==> hdr = read_ctf_res4(headerfile); > > Best regards, > Teresa Montez ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Mon Oct 25 17:04:28 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Mon, 25 Oct 2004 11:04:28 -0400 Subject: old Matlab version gives errors In-Reply-To: <04Oct25.121455cest.335087@nucleus.azvu.nl> Message-ID: > read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012-4channels.res4'); > ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file written by > a newer > version of MATLAB and cannot be read. Maybe some nice person can incorporate this code: http://kurage.nimh.nih.gov/software/ctf2matlab.tgz Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From matsuham at NINDS.NIH.GOV Sun Oct 31 20:32:14 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Sun, 31 Oct 2004 14:32:14 -0500 Subject: freqdescriptives Message-ID: Dear Robert, 1. Thanks to your suggestion, now I can somehow calculate and plot the planar distribution of coherence. It goes something like this. ============================= % data -> planar gradiometer interpolation (before freq analysis) cfg.planar = 'yes'; cfg.planarmethod='fitplane'; dataP=meginterpolate(cfg,data); %Huge!! % freq analysis (MTM) cfg=[]; cfg.method = 'fft'; cfg.foilim = [0,20] cfg.tapsmofrq=0.5; cfg.sgncmb = channelcombination({'MEG' 'REF'},dataP.label); cfg.output = 'powandcsd' cfg.pad='maxperlen'; cfg.keeptrials = 'yes' [freqP] = freqanalysis(cfg, dataP) % calc coherence freqPR=freqdescriptives(cfg, freqP) % combine V/H channels for n=1:274 freqPRC.powspctrm(n,:)=mean(freqPR.powspctrm([n;n+274],:)); freqPRC.powspctrmsem(n,:)=mean(freqPR.powspctrmsem([n;n+274],:)); freqPRC.cohspctrm(n,:)=mean(freqPR.cohspctrm([n;n+274],:)); freqPRC.cohspctrmsem(n,:)=mean(freqPR.cohspctrmsem([n;n+274],:)); freqPRC.labelcmb(n,:)=freqPR.labelcmb(n,:); freqPRC.label{n}=freqPR.label{n}(1:5); end n=275 %REF channel freqPRC.powspctrm(n,:)=mean(freqPR.powspctrm([n+274],:)); freqPRC.powspctrmsem(n,:)=mean(freqPR.powspctrmsem([n+274],:)); freqPRC.label(n,:)=freqPR.label(n+274,:) ================================ 2. Do you have any suggestion which of three simple interpolation method ('orig' | 'sincos' | 'fitplane') to use in megplanar? The 'orig' method requires less memory, but seems less reliable.... I checked with SEF N20m data and the 'orig' method produced four peaks in the gradient contour map. The 'fitplane' seems best among the three in this respect, am I right? 3. Thank you for the suggestion of EOG artifact. Finally, I noticed it was my silly mistake that I found such strange source distribution. I am now using >> cfg.funparameter='coh'; Instead of >> cfg.funparameter='pow'; This way I can see nice picture. Thank you again!! Regards, Masaa ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From matsuham at NINDS.NIH.GOV Wed Oct 6 01:32:13 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Tue, 5 Oct 2004 19:32:13 -0400 Subject: Question: Read_ctf_rc usw.. Message-ID: Hi, I am interested in DICS and now started to struggle with FieldTrip 0.92. I was very impressed by Dr. Schoffelen's presentation at BIOMAG 2004. First, I thank you very much for your effort to make this fascinating and promising toolbox to public. Then, among lots of questions, 1) I couldn't find the script 'read_ctf_hc' as described in the document 'Localizing oscillatory sources using beamformer techniques'. How can I obtain one? 2) I am almost at a loss how to start. Can I have some brief description of how to do DICS kind of analysis? Let me say, 600Hz, 4 min single trial dataset: Foo_trial_01.ds (a folder in current directory) Reference signal vector of the same length: RefSignal (14400 x 1 double array in matlab workspace) MRI/head information in Foo.mri, Foo.hdm, Foo.shape and Foo_trial_01.ds/localSpheres.hdm. If the cross-spectra should be calculated before using FieldTrip, I can do the calculation and the cross-spectra between RefSignal and all channels in Foo_trial_01 will be stored in Fxy_trial_01 (274 x 1024 double array (complex)) --- 274 is the number of MEG sensors. What should I do next? Thank you for your attention, Masao ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From Jan.Schoffelen at FCDONDERS.RU.NL Thu Oct 7 14:58:46 2004 From: Jan.Schoffelen at FCDONDERS.RU.NL (J.M. Schoffelen) Date: Thu, 7 Oct 2004 14:58:46 +0200 Subject: Question: Read_ctf_rc usw.. Message-ID: -----Original Message----- From: J.M. Schoffelen [mailto:Jan.Schoffelen at fcdonders.ru.nl] Sent: Thursday, October 07, 2004 2:48 PM To: 'FieldTrip discussion list' Subject: RE: [FIELDTRIP] Question: Read_ctf_rc usw.. Dear Masao, >I am interested in DICS and now started to struggle with FieldTrip 0.92. Glad to hear that. >1) I couldn't find the script 'read_ctf_hc' as described in the document >'Localizing oscillatory sources using beamformer techniques'. How can I >obtain one? First of all, we are very sorry, but the tutorials to which you have access are not really up-to-date. That's important to realize. So the best information about the functions is to be found in the help-documentation of the function itself. So, don't worry about read_ctf_hc, since that is an old function, and not needed any more, since its functionality is covered by other functions. >2) I am almost at a loss how to start. Can I have some brief description of >how to do DICS kind of analysis? Let me say, >600Hz, 4 min single trial dataset: Foo_trial_01.ds (a folder in current >directory) >Reference signal vector of the same length: RefSignal (14400 x 1 double >array in matlab workspace) >MRI/head information in Foo.mri, Foo.hdm, Foo.shape and >Foo_trial_01.ds/localSpheres.hdm. >If the cross-spectra should be calculated before using FieldTrip, I can do >the calculation and the cross-spectra between RefSignal and all channels in >Foo_trial_01 will be stored in Fxy_trial_01 (274 x 1024 double array >(complex)) --- 274 is the number of MEG sensors. >What should I do next? In general, I would tackle the problem in the following way: from your description of your data I cannot judge if your reference-signal is also present in the .meg4-file, or that it is obtained from somewhere else. But that's a minor point. I would not calculate my csd's outside fieldtrip, but I would use the preprocessing-function to read in my data, not as a single trial, but cut in, say, 5-second pieces (I guess you will not need a frequency-resolution of 1/240 Hz/bin). Consecutively, I would read in my reference signal, using the same trial-configuration as used in your meg-data. (This would only work if your reference signal is in your .meg4 file, otherwise you have to find out a smart trick to combine the corresponding meg-data/reference-data.) Then you have to apply a trick, and store your reference-data and meg-data in the same structure. So, if your meg-data is contained in data, and your reference data in refdata (with identical trials), I would do this: for loop = 1:length(data.trial) data.trial{loop}=[data.trial{loop};refdata.trial{loop}]; end data.label=[data.label;refdata.label]; Now you're ready to compute your crosspectra (apparently you already obtained something like that), by using freqanalysis, and your coherencespectra by using freqdescriptives on the output of freqanalysis. By visualising the coherence on the sensor-level, you are able to locate the frequencies, at which the coherence might be interesting. Then (following the tutorial, with some variations), go back to frequency-analysis, taking as cfg.foilim your frequency-band of interest, and for your signal-combinations: cfg.sgncmb = channelcombination({'MEG' 'MEG';'MEG' '$label of your reference signal'},data.label); If you then run freqanalysis you'll end up with an awful lot of csd's. This will be your input into sourceanalysis. For this, you could perfectly well follow the tutorial, but you have to change "cfg.method='power'" into "cfg.method = 'coh_refchan'", and you have to add to your configuration: cfg.refchannel = '$label of your reference signal'. Hopefully this helps you a bit to get on track, Jan-Mathijs From matsuham at NINDS.NIH.GOV Fri Oct 8 03:46:19 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Thu, 7 Oct 2004 21:46:19 -0400 Subject: Question: Read_ctf_rc usw.. Message-ID: Dear Jan-Mathijs, Thank you very much for the description. Now I am trying... Actually the reference signal is not included in the dataset, so I did as follows: ======================== % load data, in 5 sec segments cfg.dataset='X:\raid\DOSTPIDM_track_20040826_01.ds' % 6+ min, 600Hz data, 219600 time points cfg.trl=[[1:3000:219600-3000]',[3000:3000:219600]',zeros(fix(219600/3000),1) ] cfg.channel='MEG' cfg.detrend='yes' data=preprocessing(cfg) %take some time, so do it only neccesory. % combine with ref signal w{} for loop = 1:length(data.trial) data.trial{loop}=[data.trial{loop}; w{1}([1:3000]+3000*(loop-1),1)']; %w is a cell array of ref signals (219600 x 2 matrix) end data.label=[data.label;{'REF'}]; % freq analysis cfg=[]; cfg.method = 'fft'; cfg.sgncmb = channelcombination({'MEG' 'REF'},data.label); cfg.output = 'powandcsd' cfg.foilim = [0,20] cfg.tapsmofrq=0.5; cfg.pad='maxperlen'; [freq] = freqanalysis(cfg, data) freq=freqdescriptives(cfg, freq) ========================== And I encountered an error: ========================== .... processing trial 71, nfft: 3000 samples, taper length: 3000 samples, 4 tapers processing trial 72, nfft: 3000 samples, taper length: 3000 samples, 4 tapers processing trial 73, nfft: 3000 samples, taper length: 3000 samples, 4 tapers freq = label: {275x1 cell} sgn: {275x1 cell} dimord: 'sgncmb_frq' powspctrm: [275x101 double] sgncmb: {274x2 cell} labelcmb: {274x2 cell} crsspctrm: [274x101 double] foi: [1x101 double] grad: [1x1 struct] cfg: [1x1 struct] ??? Reference to non-existent field 'pow'. Error in ==> C:\MATLAB\fieldtrip\freqdescriptives.m On line 207 ==> frqjck.powspctrm = frqjck.pow; >> =========================== I think I am doing something wrong...... ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From Jan.Schoffelen at FCDONDERS.RU.NL Fri Oct 8 08:40:40 2004 From: Jan.Schoffelen at FCDONDERS.RU.NL (J.M. Schoffelen) Date: Fri, 8 Oct 2004 08:40:40 +0200 Subject: freqdescriptives In-Reply-To: <6EF659D3CB8D724BBA76CF97214D8DAC0B640BE4@nihexchange17.nih.gov> Message-ID: Dear Masao, =========================== freq = label: {275x1 cell} sgn: {275x1 cell} dimord: 'sgncmb_frq' powspctrm: [275x101 double] sgncmb: {274x2 cell} labelcmb: {274x2 cell} crsspctrm: [274x101 double] foi: [1x101 double] grad: [1x1 struct] cfg: [1x1 struct] ??? Reference to non-existent field 'pow'. Error in ==> C:\MATLAB\fieldtrip\freqdescriptives.m On line 207 ==> frqjck.powspctrm = frqjck.pow; >> =========================== This is not your fault, it is an innocent but annoying bug in the function. If you re-run the freqanalysis-part, while putting in the configuration: cfg.keeptrials = 'yes'; then it should work fine. Yours, Jan-Mathijs From matsuham at NINDS.NIH.GOV Sun Oct 10 02:17:42 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Sat, 9 Oct 2004 20:17:42 -0400 Subject: freqdescriptives Message-ID: Dear Jan-Mathijs, Thank you. Now that error is gone and I can see the the distribution of something. As often the case with a beginer, despite the nice distribution of coherence itself in the occipital area as shown by multiplotER and topoplotER, the distribution of coherent source activity is somewhat odd (symmetric medial orbitofrontal). Here is my procedure. If you find any mistake, they are very, very appreciated. The head-model is the one I am using for SAM analysis, so it should be all right. ====================================================================== load data % DICS step1 cfg=[]; cfg.method = 'fft'; cfg.output = 'powandcsd' cfg.tapsmofrq=0.5; cfg.pad='maxperlen'; cfg.keeptrials = 'yes' cfg.foilim = [5.8,6.2]; cfg.sgncmb = channelcombination({'MEG' 'MEG';'MEG' 'REF'},data.label); [freqDICS] = freqanalysis(cfg, data) % DICS step 2 cfg=[]; cfg.refchannel ='REF'; cfg.method = 'coh_refchan'; cfg.projectnoise='yes'; cfg.hdmfile='X:\raid\DOSTPIDM_track_20040826_01.ds\localSpheres.hdm' cfg.frequency=6; cfg.lambda=1e-31; cfg.xgrid='auto'; cfg.ygrid='auto'; cfg.zgrid='auto'; cfg.resolution=2; cfg.keepleadfield='no'; source=sourceanalysis(cfg,freqDICS); mriFile='X:\raid\mri\DOSTPIDM.mri'; cfg.downsample=2; cfg.parameter='pow'; cfg.funparameter='pow'; sourceInterp=sourceinterpolate(cfg,source,mriFile); figure;sliceinterp(cfg,sourceInterp); ======================================================================= To check my data farther, I want to use megplanar to check the gradient contour map but it doesn't accept freqanalysis data... (T^T) Thank you again for your kind help, Masao ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------ From r.oostenveld at FCDONDERS.RU.NL Mon Oct 11 09:50:53 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 11 Oct 2004 09:50:53 +0200 Subject: freqdescriptives In-Reply-To: <6EF659D3CB8D724BBA76CF97214D8DAC0B640CE8@nihexchange17.nih.gov> Message-ID: Dear Masao, On 10 Oct 2004, at 2:17, Matsuhashi, Masao (NIH/NINDS) wrote: > To check my data farther, I want to use megplanar to check the gradient > contour map but it doesn't accept freqanalysis data... (T^T) It is theoretically not possible to compute the planar gradient from a frequency representation of the data. However, you can compute the frequency representation of a planar gradient. In your case therefore the computation of planar gradients has to be done before the computation of the frequency representation of that data, i.e. the sequence is preprocessing->megplanar->freqanalysis. Subsequently you have to combine the coherence between the reference channel and both planar gradients on a given sensor location into a single number. That single number (e.g. average or maximum coherence for the two planar gradients on that sensor location) can be plotted topographically. Combining coherence over the planar channels and topoplotting it is not yet implemented in FieldTrip in a straightforward way, therefore you have to fiddle with the datastructures yourself. Since you note that you see something symmetric medial orbitofrontal which is not expected, I also suggest that you carefully check whether you are not merely looking at some EOG artefacts in your data. There is a EOG artifact detection algorithm which you can use, and you should look at your raw data after preprocessing to ensure that it is clean. best regards, Robert ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Thu Oct 21 17:23:15 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Thu, 21 Oct 2004 11:23:15 -0400 Subject: coherence normalization Message-ID: When running a coherence volume using a reference dipole, one naturally expects the coherence will be high around the reference dipole. This effect tends to dominate the images. Is there a way to normalize the coherence volume to eliminate this effect? Perhaps by dividing by the coherence in a "control" state? Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From r.oostenveld at FCDONDERS.RU.NL Thu Oct 21 17:48:40 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Thu, 21 Oct 2004 17:48:40 +0200 Subject: coherence normalization In-Reply-To: Message-ID: On 21 Oct 2004, at 17:23, Tom Holroyd wrote: > When running a coherence volume using a reference dipole, one > naturally expects the coherence will be high around the reference > dipole. > > This effect tends to dominate the images. > > Is there a way to normalize the coherence volume to eliminate > this effect? Perhaps by dividing by the coherence in a "control" > state? Hi Tom, The dominating effect of the refdip is indeed very problematic. I just happened to have discussed this with Joachim Gross, and I have included our email exchange below. Please first read that ... Basically I agree with Joachim, and I don't trust the supdip that is implemented in FieldTrip's sourceanalysis function. Better test and map the significance of the difference in coherence between two conditions using randomization of the trials before the coherence is beamed (that is implemented in sourceanalysis + sourcestatistics). Robert -------------------------------------------------------------------- my question to Joachim was ---------------------------------------------------------------------- Begin forwarded message: > From: Robert Oostenveld > Date: 1 October 2004 10:26:02 GMT+02:00 > To: Joachim Gross > Subject: dipole suppression > > Hi Joachim, > > What I always still had to ask you is how you do supression of dipoles > in DICS, especially in the case of coherence imaging. I have thought > of two ways of projecting them out: > > 1) compute supdip leadfield and its projection on the COV/CSD matrix, > then project it out of the COV/CSD matrix (which looses 2 or 3 from > its rank). > > 2) compute supdip leadfield and add it to the leadfield of the dipole > with which is scanned (scandip). Subsequently compute the source > COV/CSD on those 6 leadfield components and select the 3x3 submatrix > that corresponds with the scandip to continue the computations with. > > Both methods don't really gave me very convincing results. A third > approach would be to add the supdip leadfield to the (identity) noise > matrix and project it through the filters. Then nai=pow/noise is > corrected for the presence of the supdip, but that does not result in > a supressed source coherence distribution. What is your idea or > approach for this? > > best regards > Robert > ---------------------------------------------------------------------- and his answer (Joachim, I hope you don't mind me sharing this on the list) ---------------------------------------------------------------------- Begin forwarded message: > From: Joachim Gross > Date: 14 October 2004 17:20:45 GMT+02:00 > To: "robert.oostenveld at fcdonders.kun.nl" > > Subject: dipole suppression > > Hi Robert, > > sorry for the delay. > > The dipole suppression is indeed a complex issue. > We first implemented it because it facilitates visualization and the > exact identification of the first > strongest local maxima. > Nevertheless, it is quite dangerous because the map is (locally) > distorted in a non-trivial way. > We are now trying to move away from suppressing the sources. I think > it would be better to identify the > significant local maxima (significance based on > randomization/permutation). > But what we are doing at the moment is your approach 3. > So we add the supdip leadfield to the noise covariance matrix and look > at pow/noise. > > For coherence we are basically doing the same thing. > So we divide the coherence map (or actually the map of cross spectral > densities) by a noise map > that peaks at the locations of the "unwanted" dipoles. > With this procedure we loose absolute coherence values. > This is not so important for us since we get the absolute values from > the coherence and partial coherence spectra > that are computed afterwards. > It works surprisingly well but should be used with care. > > A better approach would be to map partial coherence (with the unwanted > dipoles removed). But we have not implemented > this so far. > > Again, I think it is better to have regions of interest identified by > their significance. > > Joachim ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Fri Oct 22 17:15:49 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Fri, 22 Oct 2004 11:15:49 -0400 Subject: coherence normalization In-Reply-To: Message-ID: On Thu, 21 Oct 2004, Robert Oostenveld wrote: > The dominating effect of the refdip is indeed very problematic. > ... Better test and map the significance of the difference in > coherence between two conditions using randomization of the > trials before the coherence is beamed ... Yes. What I finally did was to export the coherence volumes to AFNI, and run an ANOVA (four conditions by eight subjects; it took 24 hours for Matlab to calculate the volumes at 1 cm resolution, and I don't even have as many trials as I would like). The means across conditions of course show the refdip source but the contrasts in the ANOVA (which are basically subtractions) nicely cancelled them out, leaving cool-looking effects. :-) Now, how can I extract the phase? Is that stored somehere? Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From r.oostenveld at FCDONDERS.RU.NL Fri Oct 22 17:55:17 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Fri, 22 Oct 2004 17:55:17 +0200 Subject: coherence normalization In-Reply-To: Message-ID: Hi Tom On 22 Oct 2004, at 17:15, Tom Holroyd wrote: > Yes. What I finally did was to export the coherence volumes to > AFNI, and run an ANOVA (four conditions by eight subjects; it > took 24 hours for Matlab to calculate the volumes at 1 cm > resolution, and I don't even have as many trials as I would > like). The means across conditions of course show the refdip > source but the contrasts in the ANOVA (which are basically > subtractions) nicely cancelled them out, leaving cool-looking > effects. :-) Sounds interesting. But why are you running an ANOVA? The coherence in a voxel will not be normally distributed. Furthermore, it does not allow for a decent multiple comparison correction (except bonferoni), since GRFT does not apply. Did you try sourcestatistics with method randomization or randcluster? They do multiple comparison correction. > Now, how can I extract the phase? Is that stored somehere? Hmm, no it's not, neither is the orientation. Source.avg.coh is only the coherence in the dominant direction. I think that the sourceanalysis option keepcsd=yes will help you here, but am not 100% sure (should look into it). Conceptually, there are 6 dipoles (2*xyz) and hence a 6x6 cross-spectral density matrix will be returned as source.avg.csd (cell-array). That will tell you exactly what the coherence is in which combination of directions of the two source locations. Sofar no one ever asker me for the phase, but it would be interesting to do some more postprocessing of the source.avg.csd matrices to make something like phase easier to plot. I would like to hear suggestions. (Same applies for beamed power, where there is also a dominant dipole orientation which is neglecetd sofar). best regards Robert PS there are some "hidden" options for paralellization in Fieldtrip, of which not all code is shared under GPL. Contact me directly if you have a bunch of linux nodes and if you are interested. ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Fri Oct 22 18:25:17 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Fri, 22 Oct 2004 12:25:17 -0400 Subject: coherence normalization In-Reply-To: Message-ID: > Sounds interesting. But why are you running an ANOVA? The coherence in > a voxel will not be normally distributed. You'd think that, wouldn't you? :-) [By the way, that's an American expression meaning roughly, I'm just as surprised as you are.] Here's a random sample, from subject 6, condition 4: #Magnitude Freq Cum_Freq -2.124902 21 21 -1.874683 47 68 -1.624463 74 142 -1.374243 134 276 -1.124023 180 456 -0.873804 208 664 -0.623584 249 913 -0.373364 323 1236 -0.123144 2052 3288 0.127076 343 3631 0.377295 264 3895 0.627515 219 4114 0.877735 161 4275 1.127955 114 4389 1.378175 72 4461 1.628394 47 4508 1.878614 33 4541 2.128834 16 4557 2.379054 2 4559 2.629274 1 4560 These coherence values have already been z-scored. That's something I forgot to mention before -- since the coherence values turn out to be not too badly distributed, and since I'm only interested in the differences anyway, I z-scored 'em. > Furthermore, it does not allow for a decent multiple comparison > correction (except bonferoni), since GRFT does not apply. That's true, but my experience has been that normalizing the distributions (so that individual differences in power levels between subjects are eliminated) has almost exactly the same effect as a random permutation analysis (which I have done, but not on these data). The beamformers apparently provide quite a lot of independence already (you know, it's all coming from the same CSD matrix, but each voxel has a large prior in the form of the forward solution -- somebody should write a paper about that). And since the coherence is normalized anyway, it's fine. I can always do a permutation analysis later, by shuffling the conditions and rerunning the ANOVAs a few thousand times (they are very fast). > Did you try sourcestatistics with method randomization or > randcluster? They do multiple comparison correction. You mean sourcedescriptives? No, I haven't, but I will. I was in a hurry (Neuroscience is next week, you know). Did I mention it took 24 hours to calculate all the volumes? (Yes, I know, use the Beowulf cluster. NIH's cluster is called "Biowulf". Ha ha.) > Sofar no one ever asker me for the phase, but it would be interesting > to do some more postprocessing of the source.avg.csd matrices to make > something like phase easier to plot. I would like to hear suggestions. Let me think about that for a while. Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From t.montez at VUMC.NL Mon Oct 25 12:12:47 2004 From: t.montez at VUMC.NL (Montez, T.) Date: Mon, 25 Oct 2004 12:12:47 +0200 Subject: old Matlab version gives errors Message-ID: Hi, When using Matlab version 6.0.0.88 Release 12 and trying to read the header from the .res4 file I run into this error message: >> hdr = read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012-4channels.res4'); ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file written by a newer version of MATLAB and cannot be read. Error in ==> E:\Matlab\fieldtrip-0.9.2\read_fcdc_header.m On line 71 ==> hdr = read_ctf_res4(headerfile); Best regards, Teresa Montez From r.oostenveld at FCDONDERS.RU.NL Mon Oct 25 14:43:49 2004 From: r.oostenveld at FCDONDERS.RU.NL (Robert Oostenveld) Date: Mon, 25 Oct 2004 14:43:49 +0200 Subject: old Matlab version gives errors In-Reply-To: <04Oct25.121455cest.335087@nucleus.azvu.nl> Message-ID: Dear Teresa, Matlab version 6.0 (release 12) is already quite old and, since around 2001, release versions 12.1, 13, 14 and 14.1 have been released. In general the development of Fieldtrip is done with the most recent matlab versions, or one version older. Since I do not have access to Matlab 6.0, I cannot help you with your problem. Please upgrade to a newer version of Matlab. I do still have Matlab 6.1, and know that the p-files and the mex-files will work with that version. That means that Matlab 6.1 is the minimum requirement. best regards, Robert On 25 Oct 2004, at 12:12, Montez, T. wrote: > Hi, > > When using Matlab version 6.0.0.88 Release 12 and trying to read the > header > from the .res4 file I run into this error message: > >>> hdr = > read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012 > -4channels.res4'); > ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file > written by > a newer > version of MATLAB and cannot be read. > > Error in ==> E:\Matlab\fieldtrip-0.9.2\read_fcdc_header.m > On line 71 ==> hdr = read_ctf_res4(headerfile); > > Best regards, > Teresa Montez ---------------------------------------------------------------------- Robert Oostenveld, PhD Center for Sensory-Motor Interaction (SMI) Aalborg University, Denmark and F.C. Donders Centre for Cognitive Neuroimaging University Nijmegen P.O. Box 9101 NL-6500 AH Nijmegen The Netherlands Tel: +31 (0)24 3619695 Fax: +31 (0)24 3610989 ---------------------------------------------------------------------- N.B. Starting from 1 September 2004, the University of Nijmegen has changed its name to Radboud University Nijmegen. All web- and email-addresses ending in ".kun.nl" should therefore be changed into ".ru.nl". Please update your address book and links. From tomh at KURAGE.NIMH.NIH.GOV Mon Oct 25 17:04:28 2004 From: tomh at KURAGE.NIMH.NIH.GOV (Tom Holroyd) Date: Mon, 25 Oct 2004 11:04:28 -0400 Subject: old Matlab version gives errors In-Reply-To: <04Oct25.121455cest.335087@nucleus.azvu.nl> Message-ID: > read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012-4channels.res4'); > ??? E:\Matlab\fieldtrip-0.9.2\private\read_ctf_res4.p is a P-file written by > a newer > version of MATLAB and cannot be read. Maybe some nice person can incorporate this code: http://kurage.nimh.nih.gov/software/ctf2matlab.tgz Dr. Tom Holroyd "A man of genius makes no mistakes. His errors are volitional and are the portals of discovery." -- James Joyce From matsuham at NINDS.NIH.GOV Sun Oct 31 20:32:14 2004 From: matsuham at NINDS.NIH.GOV (Matsuhashi, Masao (NIH/NINDS)) Date: Sun, 31 Oct 2004 14:32:14 -0500 Subject: freqdescriptives Message-ID: Dear Robert, 1. Thanks to your suggestion, now I can somehow calculate and plot the planar distribution of coherence. It goes something like this. ============================= % data -> planar gradiometer interpolation (before freq analysis) cfg.planar = 'yes'; cfg.planarmethod='fitplane'; dataP=meginterpolate(cfg,data); %Huge!! % freq analysis (MTM) cfg=[]; cfg.method = 'fft'; cfg.foilim = [0,20] cfg.tapsmofrq=0.5; cfg.sgncmb = channelcombination({'MEG' 'REF'},dataP.label); cfg.output = 'powandcsd' cfg.pad='maxperlen'; cfg.keeptrials = 'yes' [freqP] = freqanalysis(cfg, dataP) % calc coherence freqPR=freqdescriptives(cfg, freqP) % combine V/H channels for n=1:274 freqPRC.powspctrm(n,:)=mean(freqPR.powspctrm([n;n+274],:)); freqPRC.powspctrmsem(n,:)=mean(freqPR.powspctrmsem([n;n+274],:)); freqPRC.cohspctrm(n,:)=mean(freqPR.cohspctrm([n;n+274],:)); freqPRC.cohspctrmsem(n,:)=mean(freqPR.cohspctrmsem([n;n+274],:)); freqPRC.labelcmb(n,:)=freqPR.labelcmb(n,:); freqPRC.label{n}=freqPR.label{n}(1:5); end n=275 %REF channel freqPRC.powspctrm(n,:)=mean(freqPR.powspctrm([n+274],:)); freqPRC.powspctrmsem(n,:)=mean(freqPR.powspctrmsem([n+274],:)); freqPRC.label(n,:)=freqPR.label(n+274,:) ================================ 2. Do you have any suggestion which of three simple interpolation method ('orig' | 'sincos' | 'fitplane') to use in megplanar? The 'orig' method requires less memory, but seems less reliable.... I checked with SEF N20m data and the 'orig' method produced four peaks in the gradient contour map. The 'fitplane' seems best among the three in this respect, am I right? 3. Thank you for the suggestion of EOG artifact. Finally, I noticed it was my silly mistake that I found such strange source distribution. I am now using >> cfg.funparameter='coh'; Instead of >> cfg.funparameter='pow'; This way I can see nice picture. Thank you again!! Regards, Masaa ------------------------------------------------ Masao Matsuhashi, MD, DMS NINDS, NIH Tel: 1-301-594-9139 E-mail: MatsuhaM at ninds.nih.gov ------------------------------------------------