Dear Alistair,<div><br></div><div>In addition to the informative response from Jörn, I just wanted to add:<br><div><br></div><div>One tiny thing I note is that you type cfg.lmvc.lambda which should be cfg.lcmv.lambda.</div>

<div><br></div><div>Why is your filter of size 3x65?   Shouldn't it be 3x125 (3 source orientations x 125 EEG channels)? <br><br></div><div>Cheers,</div><div>Johanna</div><br><div class="gmail_quote">2012/10/30 "Jörn M. Horschig" <span dir="ltr"><<a href="mailto:jm.horschig@donders.ru.nl" target="_blank">jm.horschig@donders.ru.nl</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div>Dear Alistair,<br>
      <br>
      I am not quite sure whether I understand your request correctly,
      but you are looking for help to get the maximum activity per trial
      in your source reconstructed data? I guess your confusion arises
      because of the different subfields, so here a short explanation:<br>
      <br>
      Every dipole has strengths in 3 directions (think of it as
      magnetic field strength in the x,y and z direction), this is
      stored in .mom<br>
      In order to get it down to one number instead of three, there are
      different possibilities, but what's roughly happening by default
      is that an SVD is computed then the principal direction is taken,
      i.e. the strongest of these three vectors. This is what you find
      back in .pow.  The filter matrix is the filter per grid position
      to get from your sensor data to the source data. Noise is an
      approximation of the noise level per trial.<br>
      <br>
      So, if you want to get the maximum activity, I would suggest to
      take [~, idx] = max(sourceDiff.avg.pow{i}), where idx then is the
      the grid position of maximal power. If you are interested in the
      maximum over e.g. the posterior part of the brain, you should
      limit your search. You can best do that by using sourceDiff.pos
      and an atlas.<br>
      <br>
      If that does not answer your question, feel free to clarify your
      request ;)<br>
      <br>
      Best,<br>
      Jörn<div><div class="h5"><br>
      <br>
      On 10/25/2012 10:40 PM, Alistair Vardy - 3ME wrote:<br>
    </div></div></div>
    <blockquote type="cite"><div><div class="h5">
      
      
      
      <div>
        <p class="MsoNormal"><span lang="EN-US">Hi all,<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">I trying to reconstruct
            the activity in a source using the LCMV beamformer with EEG
            data. My code follows several examples that stop at the
            source localization. Unfortunately, I am unable to
            reconstruct the source.
            <u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">The data is a series of
            198 button presses, self-paced. The two time locked data
            sets are pre- and post-event windows. The data is filtered
            in the beta band (13-30 Hz). There are 128 EEG channels,
            three of which are excluded due to excessive noise. The data
            was re-referenced to the common average. The source that
            provides the normalized difference in power between the two
            time windows has a field avg with subfields, filter, noise,
            pow, and mom:<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">sourceDiff = <u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">        dim: [17 13 14]<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">       time: [1x819
            double]<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">        pos: [3094x3
            double]<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">     inside: [1x1567
            double]<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">    outside: [1x1527
            double]<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">     method: 'average'<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">        avg: [1x1
            struct]<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">        cfg: [1x1
            struct]<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">sourceDiff.avg<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">ans = <u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">       pow: [1x3094
            double]<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">       mom: {1x3094
            cell}<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">     noise: [1x3094
            double]<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">    filter: {1x3094
            cell}<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">The moment entries are
            sized  3 x 819, the filter 3 x 65.<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">I hope someone can help
            me with the code required to reconstruct the source at the
            voxel with the largest power during the entire duration of
            each trial. The code used to determine the source is below.
            MRI, head model and leadfield were computed as well but are
            not included in the code below.<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">Kind regards,<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">Alistair<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span>channel         = {</span><span>'EEG'</span><span>,
          </span><span>'-AFF1'</span><span>,
          </span><span>'-AFZ'</span><span>,
          </span><span>'-AF1'</span><span>};</span><span style="font-size:12.0pt;font-family:"Courier New""><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg1                 =
            [];</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg1.keeptrials      =
          </span><span lang="EN-US">'yes'</span><span lang="EN-US">;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg1.covariance      =
          </span><span lang="EN-US">'yes'</span><span lang="EN-US">;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg1.channel         =
            channel;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">dataPre             =
            ft_redefinetrial(cfg1, data1FIC);</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">timelock1           =
            ft_timelockanalysis(cfg1, dataPre);</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">  
          </span><span lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg2                 =
            [];    
          </span><span lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg2.keeptrials      =
          </span><span lang="EN-US">'yes'</span><span lang="EN-US">;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg2.covariance      =
          </span><span lang="EN-US">'yes'</span><span lang="EN-US">;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg2.channel         =
            channel;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">dataPost            =
            ft_redefinetrial(cfg2, data2FIC);</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">timelock2           =
            ft_timelockanalysis(cfg2, dataPost);</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">%% Source analysis</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg = [];</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg.grid = grid;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg.hdmfile = volname;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg.elec = sens;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg.vol = vol;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg.method =
          </span><span lang="EN-US">'lcmv'</span><span lang="EN-US">;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg.channel = channel;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg.lcmv.keeptrials =
          </span><span lang="EN-US">'yes'</span><span lang="EN-US">;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">%
            cfg.lcmv.projectnoise = 'yes';</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"></span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg.lmvc.lambda     =
          </span><span lang="EN-US">'5%'</span><span lang="EN-US">;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">cfg.lcmv.keepfilter =
          </span><span lang="EN-US">'yes'</span><span lang="EN-US">;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">[source1] =
            ft_sourceanalysis(cfg, timelock1);</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">[source2] =
            ft_sourceanalysis(cfg, timelock2);</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">sourceDiff = source2;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">sourceDiff.avg.pow =
            (source2.avg.pow - source1.avg.pow) ./ source1.avg.pow;</span><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.0pt;font-family:"Courier New"" lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
fieldtrip mailing list
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></pre>
    </blockquote>
    <br>
    <br>
    <pre cols="72">-- 
Jörn M. Horschig
PhD Student
Donders Institute for Brain, Cognition and Behaviour 
Centre for Cognitive Neuroimaging
Radboud University Nijmegen 
Neuronal Oscillations Group
FieldTrip Development Team

P.O. Box 9101
NL-6500 HB Nijmegen
The Netherlands

Contact:
E-Mail: <a href="mailto:jm.horschig@donders.ru.nl" target="_blank">jm.horschig@donders.ru.nl</a>
Tel:    <a href="tel:%2B31-%280%2924-36-68493" value="+31243668493" target="_blank">+31-(0)24-36-68493</a>
Web: <a href="http://www.ru.nl/donders" target="_blank">http://www.ru.nl/donders</a>

Visiting address:
Trigon, room 2.30
Kapittelweg 29
NL-6525 EN Nijmegen
The Netherlands</pre>
  </div>

<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>