<div dir="ltr">Eelke! I am sure your name translates in Angel actually! Now everthing works!!! And so easily! <div>The version I reinstalled is Matlab R2012a. I had R 2014a for some weeks, but loads of things did not work with that...  Thanks a million for your help, really! Katrin</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-08-19 9:14 GMT+02:00 Eelke Spaak <span dir="ltr"><<a href="mailto:eelke.spaak@donders.ru.nl" target="_blank">eelke.spaak@donders.ru.nl</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Katrin,<br>
<br>
Hmm, the MATLAB version difference points to a potential bug in the<br>
code. Could you tell me which version it now works on, and which<br>
version it did not work on earlier?<br>
<br>
ICA not working on your repaired data makes sense, and the cause is in<br>
fact pretty much what you mentioned yourself. The data in the repaired<br>
channels are now linear combinations (i.e. weighted sums) of the data<br>
in other channels, so the rank of your data (number of orthogonal data<br>
vectors) is now smaller than the number of channels. In other words,<br>
your data is rank deficient. ICA does not work properly on<br>
rank-deficient data. There are a few solutions to this.<br>
<br>
I would not recommend including the bad channels in the ICA. Your<br>
second suggestion would be better: compute ICA on the data without the<br>
bad channels, then interpolate them after backprojecting to channel<br>
space. A third option would be to reduce the dimensionality of the ICA<br>
input data to its 'true' dimensionality. If you specify<br>
cfg.numcomponent = N when calling ft_componentanalysis, the data will<br>
first undergo PCA, keeping N dimensions. In your case you would need<br>
to set N to be maximally the number of recorded channels minus the<br>
number of interpolated ones. This third option is probably the easiest<br>
and best way to go.<br>
<br>
Lastly, the fact that ICA still works if you repair the channels in<br>
other software is possibly due to this other software applying some<br>
form of non-linear algorithm to repair the channels. In that case the<br>
rank of your data might not be altered.<br>
<br>
Best,<br>
Eelke<br>
<div class="HOEnZb"><div class="h5"><br>
On 19 August 2014 00:09, KatrinH Heimann <<a href="mailto:katrinheimann@gmail.com">katrinheimann@gmail.com</a>> wrote:<br>
> Dear Eelke,<br>
><br>
> ok, so i installed an older version of matlab (which also solved some other<br>
> problems with fieldtrip) and now it works. However I am running into another<br>
> problem with it. Maybe you can help too:<br>
> If I try to run the ICA after the bad channel replacement it takes hours and<br>
> wchange just does not get lower. In my naive thinking I thought that might<br>
> be due to the fact that the replaced channels are recognized as<br>
> interpolations of the others??? But what could I do otherwise?: I thought<br>
> about doing the bcr later, but that means that my ica suffers from all the<br>
> electrode jumps from my bad channels. or I just exclude them from the ica -<br>
> but how to proceed then: apply the reject component function on the data<br>
> without the channels and then replace them? sorry, I am just a bit lost. The<br>
> weirdest thing is: if I replace the channels with the help of another<br>
> software before even processing the data, the ica works perfectly later in<br>
> fieldtrip. WHY????<br>
> Would be wonderful if you could give me another hand... Thanks so much in<br>
> advance!!!<br>
> Katrin<br>
><br>
><br>
> 2014-08-18 10:18 GMT+02:00 Eelke Spaak <<a href="mailto:eelke.spaak@donders.ru.nl">eelke.spaak@donders.ru.nl</a>>:<br>
><br>
>> Dear Katrin,<br>
>><br>
>> When I look at the data you've shown me, in fact I do see an effect of<br>
>> ft_channelrepair. I run your code:<br>
>><br>
>> load ('ERP_Francesca17obs90_clean.mat')<br>
>><br>
>> %% Preparing neighbours for channel repair<br>
>><br>
>> cfg_neighb = [];<br>
>> cfg_neighb.feedback = 'yes';<br>
>> cfg_neighb.method = 'triangulation';<br>
>> cfg_neighb.layout = 'GSN-HydroCel-129.sfp';<br>
>> neighbours = ft_prepare_neighbours(cfg_neighb, obs90_data_clean2);<br>
>><br>
>> % Interpolate and put into new data structure<br>
>> cfg = [];<br>
>> cfg.badchannel = {'E49', 'E68'};<br>
>> cfg.layout = 'GSN-HydroCel-129.sfp';<br>
>> cfg.method = 'nearest';<br>
>> cfg.neighbours = neighbours;<br>
>> obs90_data_channelrepaired = ft_channelrepair(cfg,obs90_data_clean2);<br>
>><br>
>> followed by:<br>
>><br>
>> dat1=obs90_data_clean2;<br>
>> dat2=obs90_data_channelrepaired;<br>
>><br>
>> x=dat1.trial{1}(68,:); % 68 is channel index of E68<br>
>> y=dat2.trial{1}(68,:);<br>
>> plot(x);hold on;plot(y,'r');<br>
>><br>
>> x=dat1.trial{1}(49,:);<br>
>> y=dat2.trial{1}(49,:);<br>
>> figure;<br>
>> plot(x);hold on;plot(y,'r')<br>
>><br>
>> and the two figures that come up are shown in the attachments. The<br>
>> original (blue) and channel-repaired (red) traces are clearly<br>
>> different. These plots are for trial 1, but the same result holds when<br>
>> I plot a different trial.<br>
>><br>
>> Does it work on your end too now?<br>
>><br>
>> Best,<br>
>> Eelke<br>
>><br>
>> On 14 August 2014 08:57, Eelke Spaak <<a href="mailto:eelke.spaak@donders.ru.nl">eelke.spaak@donders.ru.nl</a>> wrote:<br>
>> > OK just checking :) In that case, could you post a small snippet of<br>
>> > data and the actual cfg you used (including which channels to repair)<br>
>> > on e.g. dropbox or so? Then I can have a look.<br>
>> ><br>
>> > Best,<br>
>> > Eelke<br>
>> ><br>
>> > On 13 August 2014 22:12, KatrinH Heimann <<a href="mailto:katrinheimann@gmail.com">katrinheimann@gmail.com</a>><br>
>> > wrote:<br>
>> >> Dear Eelke, yes, sure, sorry, I did that. No effect.<br>
>> >><br>
>> >><br>
>> >> 2014-08-13 21:55 GMT+02:00 Eelke Spaak <<a href="mailto:eelke.spaak@donders.ru.nl">eelke.spaak@donders.ru.nl</a>>:<br>
>> >><br>
>> >>> Dear Katrin,<br>
>> >>><br>
>> >>> Have you tried putting the labels of the channels you want<br>
>> >>> interpolated<br>
>> >>> into the cfg.badchannel array?<br>
>> >>><br>
>> >>> Best,<br>
>> >>> Eelke<br>
>> >>><br>
>> >>> Op 13 aug. 2014 19:24 schreef "KatrinH Heimann"<br>
>> >>> <<a href="mailto:katrinheimann@gmail.com">katrinheimann@gmail.com</a>>:<br>
>> >>>><br>
>> >>>> Dear all. I am trying to replace bad channels.<br>
>> >>>> This is my code (very basic I think):%% Preparing neighbours for<br>
>> >>>> channel<br>
>> >>>> repair<br>
>> >>>><br>
>> >>>><br>
>> >>>><br>
>> >>>> cfg_neighb          = [];<br>
>> >>>><br>
>> >>>> cfg_neighb.feedback = 'yes';<br>
>> >>>><br>
>> >>>> cfg_neighb.method   = 'triangulation';<br>
>> >>>><br>
>> >>>> cfg_neighb.layout   = 'GSN-HydroCel-129.sfp';<br>
>> >>>><br>
>> >>>> neighbours          = ft_prepare_neighbours(cfg_neighb, obs_data);<br>
>> >>>><br>
>> >>>><br>
>> >>>><br>
>> >>>> % Interpolate and put into new data structure<br>
>> >>>><br>
>> >>>>  cfg                      = [];<br>
>> >>>><br>
>> >>>>  cfg.badchannel           = {};<br>
>> >>>><br>
>> >>>>  cfg.layout               = 'GSN-HydroCel-129.sfp';<br>
>> >>>><br>
>> >>>>  cfg.method               = 'nearest';<br>
>> >>>><br>
>> >>>>  cfg.neighbours           = neighbours;<br>
>> >>>><br>
>> >>>>  obs_data_channelrepaired       = ft_channelrepair(cfg,obs_data)<br>
>> >>>><br>
>> >>>><br>
>> >>>> I do not get any error but fieldtrip even tells me that the<br>
>> >>>> interpolation<br>
>> >>>> worked. However I do not see ANY trace of it in my data when<br>
>> >>>> inspecting it<br>
>> >>>> afterwards. I also tried to change the method (to average) - no<br>
>> >>>> change.<br>
>> >>>> Anybody who can help me with that?<br>
>> >>>> Thanks a million<br>
>> >>>> Katrin<br>
>> >>>><br>
>> >>>><br>
>> >>>><br>
>> >>>> _______________________________________________<br>
>> >>>> fieldtrip mailing list<br>
>> >>>> <a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
>> >>>> <a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
>> >>><br>
>> >>><br>
>> >>> _______________________________________________<br>
>> >>> fieldtrip mailing list<br>
>> >>> <a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
>> >>> <a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
>> >><br>
>> >><br>
>> >><br>
>> >> _______________________________________________<br>
>> >> fieldtrip mailing list<br>
>> >> <a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
>> >> <a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
>><br>
>> _______________________________________________<br>
>> fieldtrip mailing list<br>
>> <a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
>> <a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> fieldtrip mailing list<br>
> <a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
> <a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
</div></div></blockquote></div><br></div>