<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi Soujatta,</p>
<p><br>
</p>
<p>I hope I understand your question.</p>
<p><br>
</p>
<p>For demeaned data, the covariance is the expected value of sum(xy).  For data with finite mean, we have to get the expected value of sum(x-mu(x))*sum(y-mu(y)).  Removing the mean and trend doesn't have any impact on the denominators used to compute the unbiased
 estimate of E{sum(xy)}.  The unbiased covariance estimated between x and y for a given trial is sum(xy)/(N_times-1), where N _times is the number of time points in an epoch.  When averaging covariance matrices over multiple trials the denominator becomes N_trs-1.
  I hope that helps.</p>
<p><br>
</p>
<p>Best,</p>
<p><br>
</p>
<p>Alexander </p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> fieldtrip-bounces@science.ru.nl <fieldtrip-bounces@science.ru.nl> on behalf of Soujata Borbaruah <s.borbaruah@student.utwente.nl><br>
<b>Sent:</b> Thursday, June 16, 2016 10:19:12 AM<br>
<b>To:</b> fieldtrip, donders<br>
<b>Subject:</b> [FieldTrip] What is the data present in the covariance matrix after using ft_timelockanalysis</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hello, 
<div><br>
</div>
<div>I want to calculate the covariance of the data I provide. In the function ft_timelockanalysis there is a portion where the covariance is being normalised over all trials by the total number of samples in all trials. </div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>% normalize the covariance over all trials by the total number of samples in all trials</div>
<div>if strcmp(cfg.covariance, 'yes')</div>
<div>  if strcmp(cfg.keeptrials,'yes')</div>
<div>    for i=1:ntrial</div>
<div>      if strcmp(cfg.removemean, 'yes')</div>
<div>        covsig(i,:,:) = covsig(i,:,:) / (numcovsigsamples(i)-1);</div>
<div>      else<br>
</div>
<div>        covsig(i,:,:) = covsig(i,:,:) / numcovsigsamples(i);</div>
<div>      end<br>
</div>
<div>    end</div>
<div>  else</div>
<div>    if strcmp(cfg.removemean, 'yes')</div>
<div>      covsig = squeeze(nansum(covsig, 1)) / (sum(numcovsigsamples)-ntrial);</div>
<div>    else<br>
</div>
<div>      covsig = squeeze(nansum(covsig, 1)) / sum(numcovsigsamples);</div>
<div><br>
</div>
<div>    end</div>
<div>  end</div>
<div>end</div>
</div>
<div><br>
</div>
<div>Please note that the cfg.removemean was selected as yes. </div>
<div><br>
</div>
<div>Can someone please explain what is the final data present in my covariance matrix? <br>
<br>
<br>
<br>
<div class=""><font color="#999999" class="">Sent with <a href="https://mailtrack.io/install?source=signature&lang=en&referral=s.borbaruah@student.utwente.nl&idSignature=22" class="">
MailTrack</a></font></div>
</div>
<img width="0" height="0" class="mailtrack-img" src="https://mailtrack.io/trace/mail/6051c1cbfd04bda41343fdf3fd899e094181e326741513.png"></div>
</div>
</body>
</html>