<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    <font size="+1">Dear Monika,<br>
      <br>
      Indeed, Coh cannot be calculated on single trials, it requires
      averaging of the cross-spectrum over (some) trials. Customarily,
      people average ALL trials recorded in a subject and end up with
      just only one coherence measurement for this subject. Then
      obviously stats cannot be run on the individual level and only a
      group analysis can be done (e.g., you have 20 subjects, they give
      you 20 coherence values and you run your stats on those 20
      values). Does this mean that coherence can be analyzed only on a
      group level? Perhaps not. <br>
      <br>
      I suggest the following approach. Coherence can be considered as a
      'sample', or 'population', statistic (similar to means, medians,
      variances etc, which are calculated from a set of data points).
      Methods of estimating statistical properties of those 'population'
      measures are well known, they are based on resampling, jackknifing
      and bootstrapping. Simply put, you can take a SUBSET of your
      trials (e.g., selecting  randomly 50 trials from all 100 trials in
      a particular subject) and calculate coherence over those 50
      selected trials. Then repeat the process of random selection (with
      replacement, as in jackknifing) a certain number of times (N) and
      you would have a set of N 'sample' coherences for this subject.
      Then you can run your stats on those 'sample' coherences for this
      particular subject thus achieving your goal of the individual
      subject analysis.<br>
      <br>
      Any feedback from the fellows Fieldtripers about this approach?<br>
      <br>
      Thank you,<br>
      <br>
      Andrei Medvedev<br>
      Georgetown University.<br>
      <br>
    </font><br>
    On 11/27/2012 6:49 AM, jan-mathijs schoffelen wrote:
    <blockquote
      cite="mid:D33AD4F1-279E-40F0-AACF-34E3A4D9A5AB@donders.ru.nl"
      type="cite">Dear Monika,
      <div><br>
      </div>
      <div>It may have escaped your attention while digging to the
        previous posts, but the question has been raised (and answered
        ;-) ) before. Just for the very very last time I will make the
        following statement:</div>
      <div><br>
      </div>
      <div><font class="Apple-style-span" face="Chalkboard"><span
            class="Apple-style-span" style="font-size: 36px;"><b><font
                class="Apple-style-span" color="#ce71fe">Single </font><font
                class="Apple-style-span" color="#e04b3e">trial</font><font
                class="Apple-style-span" color="#ce71fe"> </font><font
                class="Apple-style-span" color="#667cfd">coherence</font><font
                class="Apple-style-span" color="#ce71fe"> </font><font
                class="Apple-style-span" color="#9afa67">estimates</font><font
                class="Apple-style-span" color="#ce71fe"> </font><font
                class="Apple-style-span" color="#df3c73">cannot</font><font
                class="Apple-style-span" color="#ce71fe"> </font><font
                class="Apple-style-span" color="#0d0103">be</font><font
                class="Apple-style-span" color="#ce71fe"> computed!</font></b></span></font></div>
      <div><font class="Apple-style-span" color="#ce71fe"
          face="Chalkboard"><span class="Apple-style-span"
            style="font-size: 36px;"><b><br>
            </b></span></font></div>
      <div>Perhaps the font size and color will make it memorable ;-).
        This is due to the simple fact that coherence is defined across
        observations. If you have just a single observation, due to the
        mathematics involved, the coherence value will be 1.</div>
      <div>Since you want to do group analysis, I think you really
        should compute the coherence per condition, where each condition
        should consist of a sufficient number of trials. Assuming that
        the time domain data is organised such that you have all trials
        (irrespective of the condition) in a single structure, do
        something like this.</div>
      <div><br>
      </div>
      <div>for each subject</div>
      <div>  cfg = [];</div>
      <div>  cfg.output = 'fourier';</div>
      <div>  cfg.method = 'mtmfft'/'mtmconvol'</div>
      <div>  cfg.keeptrials = 'yes';</div>
      <div>  ...</div>
      <div>  freq = ft_freqanalysis(cfg, data);</div>
      <div><br>
      </div>
      <div>  cfg = [];</div>
      <div>  cfg.channelcmb = {something here}</div>
      <div>  cfg.trials = [indices of trials belonging to condition 1];</div>
      <div>  coh1 = ft_connectivityanalysis(cfg, freq); % compute
        coherence across the trials for condition 1</div>
      <div>  cfg.trials = [indices of trials belonging to condition 2];</div>
      <div>  coh2 = ft_connectivityanalysis(cfg, freq); % compute
        coherence across the trials for condition 2</div>
      <div>end</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>Good luck,</div>
      <div><br>
      </div>
      <div>Jan-Mathijs</div>
      <div><br>
      </div>
      <div><br>
        <div>
          <div>On Nov 27, 2012, at 12:25 PM, Monika Mellem wrote:</div>
          <br class="Apple-interchange-newline">
          <blockquote type="cite">Thank you Sheraz and Jan-Mathijs for
            your help!  <br>
            Sheraz, if you do have the code to keep single-trial
            coherence estimates, I would much appreciate it if you could
            pass it along (<a moz-do-not-send="true"
              href="mailto:monikamellem@gmail.com">monikamellem@gmail.com</a>). 
            <br>
            And Jan-Mathijs, okay, the necessary statistics make sense,
            and I will z-transform the data too.  But as far as you
            know, is there no implementation already in Fieldtrip to
            keep the single-trial coherence estimates?  I assumed
            setting cfg.keeptrials = 'yes' would do this, but is there
            something else I'm missing as this doesn't seem to work?  I
            would prefer to try what Fieldtrip has implemented first
            before integrating Sheraz's code into my version of
            Fieldtrip.<br>
            <br>
            Thank you very much!<br>
            Monika<br>
            <div class="gmail_extra"><br>
              <br>
              <div class="gmail_quote">On Tue, Nov 27, 2012 at 3:14 AM,
                jan-mathijs schoffelen <span dir="ltr"><<a
                    moz-do-not-send="true"
                    href="mailto:jan.schoffelen@donders.ru.nl"
                    target="_blank">jan.schoffelen@donders.ru.nl</a>></span>
                wrote:<br>
                <blockquote class="gmail_quote" style="margin: 0pt 0pt
                  0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204);
                  padding-left: 1ex;">
                  <div style="word-wrap: break-word;">Hi Monika,
                    <div><br>
                    </div>
                    <div>If you want to test across subjects in  a
                      paired fashion, you can use depsamplesT. Your
                      dependent variable then should contain for each
                      subject and condition the coherence (which of
                      course should be estimated across all trials
                      belonging to that condition). Even better would be
                      to perform a so-called Z-transformation to the
                      data. For some inspiration you could have a look
                      at the following paper: <a moz-do-not-send="true"
href="http://www.jneurosci.org/content/31/18/6750.long" target="_blank">http://www.jneurosci.org/content/31/18/6750.long</a></div>
                    <div><br>
                    </div>
                    <div>Best,</div>
                    <div><br>
                    </div>
                    <div>Jan-Mathijs</div>
                    <div><br>
                      <div>
                        <div>
                          <div class="h5">
                            <div>On Nov 27, 2012, at 12:22 AM, Monika
                              Mellem wrote:</div>
                            <br>
                          </div>
                        </div>
                        <blockquote type="cite">
                          <div>
                            <div class="h5">
                              Dear Fieldtrippers,<br>
                              <br>
                              I am trying to calculate coherence
                              estimates on individual trials of our EEG
                              data and then want to perform a
                              within-subjects statistical test, but so
                              far I have not been able to figure out how
                              to do this.  I am able to calculate
                              coherence for our 22 subjects and then
                              perform statistics on the grand average,
                              so I understand the basic usage of these
                              functions (ft_freqanalysis,
                              ft_connectivityanalysis,
                              ft_freqgrandaverage, ft_freqstatistics). 
                              But now we want to do statistical testing
                              on individual subjects.  Is it possible to
                              keep coherence for individual trials in
                              Fieldtrip as they seem necessary for this
                              statistical analysis?<br>
                              <br>
                              I am setting cfg.keeptrials = 'yes' as an
                              input to ft_freqanalysis, and get the
                              cross-spectra of individual trials (I also
                              tried computing the fourier spectra but it
                              made no difference in the following
                              step).  However, when computing the
                              coherence in ft_connectivityanalysis,
                              Fieldtrip averages over the trials.  Is
                              there a way to output coherence for
                              individual trials instead?  Please see the
                              full cfg structure settings below.<br>
                              <br>
                              Also, I did look into the option of
                              cfg.statistic = 'indepsamplesZcoh' as an
                              input to ft_freqstatistics since previous
                              posts suggested this was for single
                              subject coherence statistics, but our data
                              is paired as the same stimulus appears in
                              the 2 conditions we are comparing.  Is
                              there a paired test for single subject
                              coherence testing, or should we use
                              cfg.statistic = 'depsamplesT'?<br>
                              <br>
                              Many thanks for any suggestions you may
                              have!<br>
                              Monika<br>
                              ________________
                              <div>
                                <div><img moz-do-not-send="true"
                                    src="https://mail.google.com/mail/u/0/images/cleardot.gif">Monika
                                  Mellem<br>
                                </div>
                              </div>
                              <span><font color="#888888"><span><font
                                      color="#888888">PhD Candidate<br>
                                      Interdisciplinary Program in
                                      Neuroscience<br>
                                      Georgetown University<br>
                                      Washington, DC<br>
                                      <a moz-do-not-send="true"
                                        href="mailto:msm79@georgetown.edu"
                                        target="_blank">msm79@georgetown.edu</a><br>
                                      <a moz-do-not-send="true"
                                        href="tel:202-687-2687"
                                        value="+12026872687"
                                        target="_blank">202-687-2687</a></font></span>
                                </font></span><br>
                              <br>
***********************************************************************<br>
                              cfg settings for ft_freqanalysis and
                              ft_connectivityanalysis<br>
***********************************************************************<br>
                              cfg = [];<br>
                              cfg.prestim = -0.5;  <br>
                              cfg.poststim = 1.5;  <br>
                              cfg.foilim = [2 30];<br>
                              cfg.freqrange = 'low';<br>
                              % cfg.output     = 'fourier';<br>
                              cfg.output     = 'powandcsd';<br>
                              cfg.method = 'mtmconvol';<br>
                              cfg.keeptrials = 'yes';  <br>
                              cfg.channel    = {'all'};  <br>
                              cfg.channelcmb = {refchan 'all'}; <br>
                              <br>
                              cfgcoh=[];<br>
                              cfgcoh.channelcmb = cfg.channelcmb;<br>
                              cfgcoh.method = 'coh';<br>
                              <br>
                              v = genvarname(['CRSP_' condition
                              '_low']);<br>
                              eval([v '= ft_multitaper_powcoh_EGI(cfg,
                              data);']);  %Wrapper around
                              ft_freqanalysis <br>
                              <br>
                              w = genvarname(['COH_' condition '_low']);<br>
                              eval([w '= ft_connectivityanalysis(cfgcoh,
                              ' v ');']);<br>
                              <br>
                              <br>
                            </div>
                          </div>
                          <div class="im">
_______________________________________________<br>
                            fieldtrip mailing list<br>
                            <a moz-do-not-send="true"
                              href="mailto:fieldtrip@donders.ru.nl"
                              target="_blank">fieldtrip@donders.ru.nl</a><br>
                            <a moz-do-not-send="true"
                              href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip"
                              target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></div>
                        </blockquote>
                      </div>
                      <br>
                      <div>
                        <span style="text-indent: 0px; letter-spacing:
                          normal; font-variant: normal; font-style:
                          normal; font-weight: normal; line-height:
                          normal; border-collapse: separate;
                          text-transform: none; font-size: medium;
                          white-space: normal; font-family: Helvetica;
                          word-spacing: 0px;"><span style="text-indent:
                            0px; letter-spacing: normal; font-variant:
                            normal; font-style: normal; font-weight:
                            normal; line-height: normal;
                            border-collapse: separate; text-transform:
                            none; font-size: medium; white-space:
                            normal; font-family: Helvetica;
                            word-spacing: 0px;">
                            <div style="word-wrap: break-word;">
                              <span style="text-indent: 0px;
                                letter-spacing: normal; font-variant:
                                normal; font-style: normal; font-weight:
                                normal; line-height: normal;
                                border-collapse: separate;
                                text-transform: none; font-size: medium;
                                white-space: normal; font-family:
                                Helvetica; word-spacing: 0px;">
                                <div style="word-wrap: break-word;">
                                  <span style="text-indent: 0px;
                                    letter-spacing: normal;
                                    font-variant: normal; font-style:
                                    normal; font-weight: normal;
                                    line-height: normal;
                                    border-collapse: separate;
                                    text-transform: none; font-size:
                                    medium; white-space: normal;
                                    font-family: Helvetica;
                                    word-spacing: 0px;">
                                    <div style="word-wrap: break-word;">
                                      <span style="text-indent: 0px;
                                        letter-spacing: normal;
                                        font-variant: normal;
                                        font-style: normal; font-weight:
                                        normal; line-height: normal;
                                        border-collapse: separate;
                                        text-transform: none; font-size:
                                        medium; white-space: normal;
                                        font-family: Helvetica;
                                        word-spacing: 0px;">
                                        <div style="word-wrap:
                                          break-word;">
                                          <span style="text-indent: 0px;
                                            letter-spacing: normal;
                                            font-variant: normal;
                                            font-style: normal;
                                            font-weight: normal;
                                            line-height: normal;
                                            border-collapse: separate;
                                            text-transform: none;
                                            font-size: medium;
                                            white-space: normal;
                                            font-family: Helvetica;
                                            word-spacing: 0px;">
                                            <div style="word-wrap:
                                              break-word;">
                                              <div>Jan-Mathijs
                                                Schoffelen, MD PhD </div>
                                              <div><br>
                                              </div>
                                              <div>Donders Institute for
                                                Brain, Cognition and
                                                Behaviour, <br>
                                                Centre for Cognitive
                                                Neuroimaging,<br>
                                                Radboud University
                                                Nijmegen, The
                                                Netherlands</div>
                                              <div><br>
                                              </div>
                                              <div>Max Planck Institute
                                                for Psycholinguistics,</div>
                                              <div>Nijmegen, The
                                                Netherlands</div>
                                              <div><br>
                                              </div>
                                              <div><a
                                                  moz-do-not-send="true"
href="mailto:J.Schoffelen@donders.ru.nl" target="_blank">J.Schoffelen@donders.ru.nl</a></div>
                                              <div>Telephone: <a
                                                  moz-do-not-send="true"
href="tel:%2B31-24-3614793" value="+31243614793" target="_blank">+31-24-3614793</a></div>
                                            </div>
                                          </span></div>
                                      </span></div>
                                  </span></div>
                              </span></div>
                          </span></span>
                      </div>
                      <br>
                    </div>
                  </div>
                  <br>
                  _______________________________________________<br>
                  fieldtrip mailing list<br>
                  <a moz-do-not-send="true"
                    href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
                  <a moz-do-not-send="true"
                    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>
            _______________________________________________<br>
            fieldtrip mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
            <a class="moz-txt-link-freetext" href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></blockquote>
        </div>
        <br>
        <div>
          <span class="Apple-style-span" style="border-collapse:
            separate; color: rgb(0, 0, 0); font-family: Helvetica;
            font-style: normal; font-variant: normal; font-weight:
            normal; letter-spacing: normal; line-height: normal;
            orphans: 2; text-indent: 0px; text-transform: none;
            white-space: normal; widows: 2; word-spacing: 0px;
            font-size: medium;"><span class="Apple-style-span"
              style="border-collapse: separate; color: rgb(0, 0, 0);
              font-family: Helvetica; font-style: normal; font-variant:
              normal; font-weight: normal; letter-spacing: normal;
              line-height: normal; orphans: 2; text-indent: 0px;
              text-transform: none; white-space: normal; widows: 2;
              word-spacing: 0px; font-size: medium;">
              <div style="word-wrap: break-word;"><span
                  class="Apple-style-span" style="border-collapse:
                  separate; color: rgb(0, 0, 0); font-family: Helvetica;
                  font-style: normal; font-variant: normal; font-weight:
                  normal; letter-spacing: normal; line-height: normal;
                  orphans: 2; text-indent: 0px; text-transform: none;
                  white-space: normal; widows: 2; word-spacing: 0px;
                  font-size: medium;">
                  <div style="word-wrap: break-word;"><span
                      class="Apple-style-span" style="border-collapse:
                      separate; color: rgb(0, 0, 0); font-family:
                      Helvetica; font-style: normal; font-variant:
                      normal; font-weight: normal; letter-spacing:
                      normal; line-height: normal; orphans: 2;
                      text-indent: 0px; text-transform: none;
                      white-space: normal; widows: 2; word-spacing: 0px;
                      font-size: medium;">
                      <div style="word-wrap: break-word;"><span
                          class="Apple-style-span"
                          style="border-collapse: separate; color:
                          rgb(0, 0, 0); font-family: Helvetica;
                          font-style: normal; font-variant: normal;
                          font-weight: normal; letter-spacing: normal;
                          line-height: normal; orphans: 2; text-indent:
                          0px; text-transform: none; white-space:
                          normal; widows: 2; word-spacing: 0px;
                          font-size: medium;">
                          <div style="word-wrap: break-word;"><span
                              class="Apple-style-span"
                              style="border-collapse: separate; color:
                              rgb(0, 0, 0); font-family: Helvetica;
                              font-size: medium; font-style: normal;
                              font-variant: normal; font-weight: normal;
                              letter-spacing: normal; line-height:
                              normal; orphans: 2; text-indent: 0px;
                              text-transform: none; white-space: normal;
                              widows: 2; word-spacing: 0px;">
                              <div style="word-wrap: break-word;">
                                <div>Jan-Mathijs Schoffelen, MD PhD </div>
                                <div><br>
                                </div>
                                <div>Donders Institute for Brain,
                                  Cognition and Behaviour, <br>
                                  Centre for Cognitive Neuroimaging,<br>
                                  Radboud University Nijmegen, The
                                  Netherlands</div>
                                <div><br>
                                </div>
                                <div>Max Planck Institute for
                                  Psycholinguistics,</div>
                                <div>Nijmegen, The Netherlands</div>
                                <div><br>
                                </div>
                                <div><a moz-do-not-send="true"
                                    href="mailto:J.Schoffelen@donders.ru.nl">J.Schoffelen@donders.ru.nl</a></div>
                                <div>Telephone: +31-24-3614793</div>
                              </div>
                            </span></div>
                        </span></div>
                    </span></div>
                </span></div>
            </span></span>
        </div>
        <br>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
fieldtrip mailing list
<a class="moz-txt-link-abbreviated" href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a>
<a class="moz-txt-link-freetext" href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Andrei Medvedev, PhD
Assistant Professor,
Center for Functional and Molecular Imaging
Georgetown University
Building D, Room 154
4000 Reservoir Rd, NW
Washington DC, 20057
Tel.: 202-687-5126
</pre>
  </body>
</html>