<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<font face="Courier" class="">Hey. When I am preprocessing my MEG neuromag data, I’m noticing that the signal of my channels are altered depending on how long after the stimulus I include in the trial, even in the portion of the trial that is overlapping between
 the two cases. For instance, if I use cfg.poststim = 2.5 in one run and cfg.poststim = 0.6 in a second, the two signals are not identical up until 0.6 seconds. Please see my code and attached plots of a Grad sensor in these two cases up to 0.6 seconds.</font>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class="">
<div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(34, 139, 34);" class="">
<font face="Courier" class=""><span style="color: rgb(0, 0, 0);" class=""><span class="Apple-tab-span" style="white-space: pre;"></span> </span>% define trials</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg = [];</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.dataset = full_path;</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.trialdef.prestim = 0.175; </font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.trialdef.poststim = 0.6;
<span style="color: #228b22" class="">% compare with 2.5 seconds</span></font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.trialdef.eventvalue = [6 7 9];</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">       </font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.trialdef.eventtype =
<span style="color: #a020f0" class="">'STI101'</span>;</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg = ft_definetrial(cfg);</font></div>
<p style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 12px;" class="">
<font face="Courier" class=""> <br class="webkit-block-placeholder">
</font></p>
<div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(34, 139, 34);" class="">
<font face="Courier" class=""><span style="color: #000000" class="">        </span>
% preprocess</font></div>
<p style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 12px;" class="">
<font face="Courier" class="">        <br class="webkit-block-placeholder">
</font></p>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.demean =
<span style="color: #a020f0" class="">'yes'</span>;</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.baselinewindow = [-0.175 0.025];<br class="">
</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.lpfilter =
<span style="color: #a020f0" class="">'no'</span>;</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.hpfilter =
<span style="color: #a020f0" class="">'no'</span>;</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.dftfilter =
<span style="color: #a020f0" class="">'yes'</span>;</font></div>
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre"></span>split_files{1} = ft_preprocessing(cfg);
<span style="color: rgb(34, 139, 34);" class="">%preprocess</span></font></div>
</div>
<div class=""><span style="color: #228b22" class=""><font face="Courier" class=""><br class="">
</font></span></div>
<div class=""><span style="color: #228b22" class=""><font face="Courier" class=""><br class="">
</font></span></div>
<div class=""><span style="color: rgb(34, 139, 34);" class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space: pre;"></span>%%%%%%%%%%%Downsampling%%%%%%%%%</font></span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class=""> 
<span class="Apple-tab-span" style="white-space:pre"></span>cfg = [];</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">   
<span class="Apple-tab-span" style="white-space:pre"></span>cfg.resamplefs = 250;</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">   
<span class="Apple-tab-span" style="white-space:pre"></span>data = ft_resampledata(cfg, split_files{1});</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre"></span>%%Visualisation</font></div>
<div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre"></span>cfg = [];</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.channel =
<span style="color: #a020f0" class="">'MEGGRAD'</span>;</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        cfg.keeptrials =
<span style="color: #a020f0" class="">'yes'</span>; </font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        data = ft_timelockanalysis(cfg,data);</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre"></span>Xlim([-0.2 0.6])</font></div>
<div class="">
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">        plot(data.time,squeeze(mean(data.trial(:,39,:),1))) </font></div>
</div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class=""><br class="">
</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">As you can see from the plots attached, these signals are not identical when they should be (shouldn’t they?). The first plot is when I Use 2.5 seconds
 post stim and the second is using 0.6. I’ve altered the xlim to show only up to 600ms on both. Also, can anyone explain these huge spikes at the beginning of trials, that’s my next problem to solve.</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class=""><br class="">
</font></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class="">Thanks</font></div>
<div class=""><img apple-inline="yes" id="A1BF5F22-8D25-4EC7-8437-0E1AFA994A0E" src="cid:972C968D-ED1A-418C-B626-5137EF2C8759@home" class=""><img apple-inline="yes" id="BEA436DE-DE1B-4212-84A1-748756FA28DF" src="cid:FA70F34E-C8F5-4FD5-B3EC-60222BB0CD0E@home" class=""></div>
</body>
</html>