[FieldTrip] ft_channelrepair replaces channel data with NaNs after running PCA

Keith Doelling kd889 at nyu.edu
Tue Feb 21 18:48:10 CET 2012


Hi guys,

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.

Thanks!
Keith

On Fri, Feb 17, 2012 at 12:08 PM, Keith Doelling <kd889 at nyu.edu> wrote:

> Hi guys,
>
> I'm struggling with my attempts to interpolate channel data for some bad
> channels. I put in the following code:
>
> <code>
>     cfg=[];
>     cfg.badchannel = 15;
>     cfg.missingchannel = [];
>     cfg.neighbours = neighbours;
>     cfg.trials = 'all';
>     cleanchdata = ft_channelrepair(cfg,cleandata);
>
> </code>
> the function the displays the following:
>
>     "the input is raw data with 157 channels and 80 trials
>     repairing channel AG015
>     using neighbour AG010
>      using neighbour AG014
>     using neighbour AG062
>     using neighbour AG092"
>
> suggesting that neighbours have been selected successfully.
>
> but a call to chdata.trial(1){15,:) just returns a bunch of NaNs rather
> than interpolated data I need.
>
> 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.
>
> 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.
>
> 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.
>
> <code>
>     % principle component analysis run with 32 components
>     cfg = [];
>     cfg.channel = (1:157);
>     cfg.runica.pca=32;
>     pca_data = ft_componentanalysis(cfg,data);
>
>     % view components in order to select bad ones
>     cfg = [];
>     cfg.layout = layout; % specify the layout file that should be used
> for plotting
>     cfg.viewmode = 'component';
>     ft_databrowser(cfg, pca_data);
>     waitfor(gcf);
>
>     % type bad components as user input
>     % for example: if runica002 and runica0003 should be rejected, type
> "2,3" into the dialogue box
>     badcomps = inputdlg({'Bad Components:'});
>     badcomps = str2double(csv2cell(badcomps{1}));
>
>     % reject bad components
>     cfg = [];
>     cfg.component = badcomps;
>     cleandata = ft_rejectcomponent(cfg,pca_data);
> </code>
>
> the variable 'cleandata'  i get out from this code is the same cleandata i
> put in to ft_channelrepair.
>
> Are there any ideas as to what I've done wrong here? Let me know if I need
> to give you guys more information.
>
> Thanks for your help,
> Keith
>
> --
> Keith Doelling
> Lab Manager and Research Assistant
> David Poeppel Lab
> New York University
>
>


-- 
Keith Doelling
Lab Manager and Research Assistant
David Poeppel Lab
New York University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20120221/96e235c7/attachment.html>


More information about the fieldtrip mailing list