Hi guys,<div><br></div><div>For those that are interested I figured out the problem. Somewhere in the process of running component analysis and then component rejection, fieldtrip was taking .chanpos and .chanori in my .grad field and replacing all the values with NaNs. I fixed the problem by adding cleandata.grad = data.grad just after component rejection. It would be great though, if some one could look at the ft_componentanalysis and ft_rejectcomponent functions and figure out why the grad information is being lost.</div>


<div><br></div><div>Thanks!</div><div>Keith<br><div><br><div class="gmail_quote">On Fri, Feb 17, 2012 at 12:08 PM, Keith Doelling <span dir="ltr"><<a href="mailto:kd889@nyu.edu" target="_blank">kd889@nyu.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi guys,<div><br></div><div>I'm struggling with my attempts to interpolate channel data for some bad channels. I put in the following code:</div><div><br></div><div><code></div><div>    cfg=[];</div><div>    cfg.badchannel = 15;</div>



<div>    cfg.missingchannel = [];</div><div>    cfg.neighbours = neighbours;</div><div>    cfg.trials = <span>'all'</span>;</div><div>    cleanchdata = ft_channelrepair(cfg,cleandata);</div><div><p></p>



<div></code></div><div>the function the displays the following:</div><div><div><br></div><div>    "the input is raw data with 157 channels and 80 trials</div><div>    repairing channel AG015</div><div><span style="white-space:pre-wrap">   </span>    using neighbour AG010</div>



<div><span style="white-space:pre-wrap">  </span>    using neighbour AG014</div><div><span style="white-space:pre-wrap">        </span>    using neighbour AG062</div><div><span style="white-space:pre-wrap">        </span>    using neighbour AG092"</div>



</div><div><br></div><div>suggesting that neighbours have been selected successfully.</div><div><br></div><div>but a call to chdata.trial(1){15,:) just returns a bunch of NaNs rather than interpolated data I need.</div><div>



<br></div><div>I found another email thread similar to this but that solution doesn't seem to apply to me as the neighbours seemed to have been selected successfully. </div><div><br></div><div>The other interesting caveat is that ft_channelrepair seems to work fine if i run it without having run pca (to reject eyeblink and heartbeat components) beforehand.</div>



<div><br></div><div>The code for the component analysis and the subsequent rejection are in separate loops. The PCA is saved into a .mat file and then loaded again when i'm ready to reject the bad components. But for simplicity's sake the important code looks like this.</div>



<div><br></div><div><code></div><div>    % principle component analysis run with 32 components</div><div>    cfg = [];</div><div>    cfg.channel = (1:157);</div><div>    cfg.runica.pca=32;                </div><div>



    pca_data = ft_componentanalysis(cfg,data);</div><div><br></div><div>    % view components in order to select bad ones</div><div>    cfg = [];</div><div><span>    cfg.layout = layout; </span>% specify the layout file that should be used for plotting</div>



<div>    cfg.viewmode = <span>'component'</span>;</div><div>    ft_databrowser(cfg, pca_data);</div><div>    waitfor(gcf); </div><div><br></div><div>    % type bad components as user input </div><div>    % for example: if runica002 and runica0003 should be rejected, type "2,3" into the dialogue box</div>



<div>    badcomps = inputdlg({<span>'Bad Components:'</span>});</div><div>    badcomps = str2double(csv2cell(badcomps{1}));</div><div><br></div><div>    % reject bad components</div><div>    cfg = [];</div>
<div>    cfg.component = badcomps; </div><div>    cleandata = ft_rejectcomponent(cfg,pca_data);</div><div></code></div><div><br></div><div>the variable 'cleandata'  i get out from this code is the same cleandata i put in to ft_channelrepair.</div>



<div><br></div><div>Are there any ideas as to what I've done wrong here? Let me know if I need to give you guys more information.</div><div><br></div><div>Thanks for your help,</div><div>Keith</div><span><font color="#888888"><div>


<br></div>-- <br>
<span style="color:rgb(136,136,136);font-size:13px;font-family:arial,sans-serif">Keith Doelling<div>Lab Manager and Research Assistant</div><div>David Poeppel Lab</div><div>New York University</div>
</span><br>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><span style="color:rgb(136,136,136);font-size:13px;font-family:arial,sans-serif">Keith Doelling<div>Lab Manager and Research Assistant</div>
<div>David Poeppel Lab</div><div>New York University</div></span><br>
</div></div>