<div dir="ltr"><div><div>...sorry, forgot to add to my post that for SAM I use the option cfg.fixedori     = 'robert';<br></div>Best,<br></div>Haris<br><br>Charidimos [Haris] Tzagarakis MD, PhD, MRCPsych
<br>University of Minnesota Dept of Neuroscience and Brain Sciences Center<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 22 October 2013 19:00, Charidimos Tzagarakis <span dir="ltr"><<a href="mailto:haristz@gmail.com" target="_blank">haristz@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi There,<br>I have a question regarding ft_sourceanalysis: I in fact seem to be getting conflicting results depending on the beamformer I use .<br>
<br> In summary (and of course, provided I have not made an error somewhere!), for a given frequency band and a predefined filter LCMV seems to output results that look more as if they are based on the covariance matrix estimated on the evoked response (ie not the covariance matrix coming from averaging one way or the other the covariance matrices resulting from individual trials as is the case with the other beamformers). So in its "vanilla" form, when I test it against SAM and DICS, LCMV gives different results. When I comment out the part of the ft_sourceanalysis code that is executed for LCMV when a filter is input with cfg (this seems to be done to speed up the process), then the results are comparable for all 3 beamformers.<br>



   <br>More in detail (apologies for the rather lenthy post):<br>We are using a motor task and studying beta descynchronisation. The images I link to are "gradnaveraged" relative changes in beta power between a period during baseline and a period during "task" over 10 subjects. I first deform the MNI grid to individual subjects' brains so everything takes place in MNI space.For all 3 beamformers the leadfield and headmodels are calculated in the same way (except for SAM where the singleshell  model is unavailable and I used localspheres instead). All this was done with fieldtrip-20130823 but looking at fieldtrip-20131021 I see no changes in the code for the beamformers or ft_sourceanalysis. <br>



<br>We used DICS (centered on an appororiately chosen frequency), SAM and LCMV with the same data and intervals. For the latter 2 I first bandpass filter the data to the beta band during ft_preprocessing. For the DICS analysis I use exactly the same procedure as in the relevant tutorial. For SAM and LCMV I do the same with the minor change that the common filter is calculated over a much larger interval that includes the  "baseline" and "task" intervals at its edges, instead of creating a dataset through concatenation of the "baseline" and "task" intervals compared.<br>



So code-wise (and per subject), for DICS this is:<br><br><freq_cmb, freq_Pre and freq_Post calculated exacly as in the tutorial><br>and then:<br><br>cfg                   = [];<br>cfg.frequency         = freq_cmb.freq;<br>



cfg.grad        = senscm;<br>cfg.method            = 'dics';<br>cfg.keeptrials        = 'yes';<br>cfg.grid              = sourcemodel_lf;<br>cfg.vol         = volfcm;<br>cfg.keeptrials        = 'yes';<br>



cfg.dics.lambda       = '5%';<br>cfg.dics.keepfilter   = 'yes';<br>cfg.dics.fixedori     = 'yes';<br>cfg.dics.realfilter   = 'yes';<br><br>source                = ft_sourceanalysis(cfg, freq_cmb);<br>



with source_Pre and source_Post calculated with the above cfg *plus* using the filter estimated at "source".<br>cfg.grid.filter  = source.avg.filter;<br><br> and for SAM and LCMV:  <br>cfg=[];<br><br>cfg.bpfilter='yes';<br>



cfg.bpfreq  =[freq-fsmth freq+fsmth];<br>cfg.channel=params.chan;<br>datf=ft_preprocessing(cfg,dat);<br><note, tb and ta are 2 element vectors [tmin tmax]><br><br>cfg = [];<br>cfg.toilim = tb;<br>dataPre = ft_redefinetrial(cfg, datf);<br>



cfg = [];<br>cfg.toilim = ta;<br>dataPost = ft_redefinetrial(cfg, datf);<br>cfg=[];<br>cfg.toilim = [tb(1,1) ta(1,2)];<br>data_cmb=ft_redefinetrial(cfg,datf); % so here I could have also done data_cmb=ft_appenddata(cfg,dataPre,dataPost) and set cfg.vartrllength      = 2; further down but this would change the solution very little<br>



<br>clear('dat');<br><br><br>cfg                   = [];<br>cfg.covariance        = 'yes';<br>cfg.channel           = params.chan;<br>cfg.covariancewindow  = 'all';<br>cfg.removemean='no';<br>



cfg.keeptrials        ='yes';<br>%keyboard<br>d_cmb              = ft_timelockanalysis(cfg, data_cmb);<br>d_Pre              = ft_timelockanalysis(cfg, dataPre);<br>d_Post             = ft_timelockanalysis(cfg, dataPost);<br>



<br><br>cfg                   = [];<br>cfg.grad        = senscm;<br>cfg.method            = 'lcmv';% (or 'sam')<br>cfg.keeptrials        = 'yes';<br>cfg.grid              = sourcemodel_lf;<br>cfg.vol         = volfcm;<br>



cfg.lambda        ='5%';%relevant code added to beamformer_sam to handle this<br>cfg.keepfilter   = 'yes';<br>cfg.fixedori     = 'yes';<br>cfg.projectnoise='yes';<br>source                = ft_sourceanalysis(cfg, d_cmb);<br>



<br>with source_Pre and source_Post calculated with the above cfg *plus* using the filter estimated at "source".<br>cfg.grid.filter  = source.avg.filter;<br><br><br>The results for SAM (<a href="https://db.tt/fhvEAJN0" target="_blank">https://db.tt/fhvEAJN0</a>) and DICS (<a href="https://db.tt/nOxIDA5Y" target="_blank">https://db.tt/nOxIDA5Y</a>) are in fact in good agreement (and make sense physiologically).<br>



LCMV was initially quite different (<a href="https://db.tt/LXCBivfc" target="_blank">https://db.tt/LXCBivfc</a>) and in fact similar to what you'd get if using the covariance matrix of the ERP average, ie:<br>data_cmb              = ft_timelockanalysis([], data_cmb);<br>



dataPre              = ft_timelockanalysis([], dataPre);<br>dataPost             = ft_timelockanalysis([], dataPost);<br>and then (as above)<br>cfg                   = [];<br>cfg.covariance        = 'yes';<br>cfg.channel           = params.chan;<br>



cfg.covariancewindow  = 'all';<br>cfg.removemean='no';<br>cfg.keeptrials        ='yes';<br>%keyboard<br>d_cmb              = ft_timelockanalysis(cfg, data_cmb);<br>d_Pre              = ft_timelockanalysis(cfg, dataPre);<br>



d_Post             = ft_timelockanalysis(cfg, dataPost);<br><br>I in fact tried this with SAM (<a href="https://db.tt/Djy54qgs" target="_blank">https://db.tt/Djy54qgs</a>) and the result is similar to LCMV above.<br><br>


This is however not what we wanted. Going through the code in  ft_sourceanalysis I see there is a part (only for LCMV and when a filter is provided) where the data and covariance matrix are treated differently. I can't say I fully understand the algorithm there but when I commented out that part my LCMV results are in very good agreement with DICS and SAM (<a href="https://db.tt/aNz11ntb" target="_blank">https://db.tt/aNz11ntb</a>).<br>



<br>I would as always be grateful for your feedback and opinions. Am I committing an error somewhere? - should the code behave differently there?<br>With Thanks and Best Wishes,<br>Haris<br><br>Charidimos [Haris] Tzagarakis MD, PhD, MRCPsych
<br>University of Minnesota Dept of Neuroscience and Brain Sciences Center<br></div>
</blockquote></div><br></div>