Problems with rank():  To the best of my recollection, a distinct bug appeared in some Matlab versions of their rank() function (including the version we were using) -- we had to insert a workaround (using lower-level Matlab math functions) to avoid nonsensical consequences ...  If infomax ICA (runica/binica) is set to work using a rank higher than the true rank of the data, then the weights will continue to increase and will then 'blow up' ... But reducing the number of components computed below the actual rank will have negative consequences in most cases.<div>
<br></div><div>Scott Makeig<br><br><div class="gmail_quote">On Mon, Feb 27, 2012 at 6:26 AM, Matthew Stief <span dir="ltr"><<a href="mailto:ms2272@cornell.edu">ms2272@cornell.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hey Tarik,<br><br>You say that it will look ok, but nevertheless a rank has been lost from re-referencing to the average so ICAs run in this way are being overfitted, and are thus suboptimal, are they not?  I've run through most of my data with the rank calculated incorrectly and mostly it looks "normal" but I am going back through it to make sure that everything is correct and I want to make sure I am doing things optimally because some of my results are null and I want to be very sure of them before I publish.<br>

<br>Just to confirm, if pop_runica did in fact opt for the lower of the two candidate ranks represented in that error message, that is if it chose to use the results of this code:<br><br><div style="margin-left:40px"><span style="color:rgb(51,153,153)">covarianceMatrix = cov(tmpdata', 1);</span><br style="color:rgb(51,153,153)">

<span style="color:rgb(51,153,153)">[E, D] = eig (covarianceMatrix);</span><br style="color:rgb(51,153,153)"><span style="color:rgb(51,153,153)">rankTolerance = 1e-7;</span><br style="color:rgb(51,153,153)"><span style="color:rgb(51,153,153)">tmprank2=sum (diag (D) > rankTolerance);</span><br>

</div><br>instead of opting for the result of this code:<br><br style="color:rgb(51,153,153)"><div style="margin-left:40px"><span style="color:rgb(51,153,153)">tmprank = rank(tmpdata);</span><br></div><br>Then because the correct rank is less than the number of channels it would necessarily have to run PCA to not run an ICA with too many ranks?  And this would be exactly identical to overriding the rank calculation by specifying a PCA with a particular number of ranks?  This is what I understand is the case but I can barely understand this stuff so I just want to make absolutely sure.  I understand if there's no definitive solution at this point, but I would be very grateful if anyone had the time to help me understand exactly what the problem is.<br>

<br>What I've done in my data processing code is this...<br><br style="color:rgb(51,153,153)"><div style="margin-left:40px"><span style="color:rgb(51,153,153)">correctRank = EEG.nbchan-1;</span><br style="color:rgb(51,153,153)">

<span style="color:rgb(51,153,153)">EEG = pop_runica(EEG, 'icatype', 'runica', 'pca', correctRank, 'extended', 1);</span><br></div><br>Which seems to work fine.  But I would still love an explanation of why pop_runica is calculating rank in this mysterious way.  I mean, what would be the dangers of me simply changing this bit of code at the end of pop_runica<br>

<br style="color:rgb(51,153,153)"><div style="margin-left:40px"><span style="color:rgb(51,153,153)">tmprank2 = max(tmprank, tmprank2);</span><br></div><br>to this?<br><br><div style="margin-left:40px"><span style="color:rgb(51,153,153)">tmprank2 = min(tmprank, tmprank2);</span><br>

</div><br>Another question about rank calculation in pop_runica.  What exactly is this code doing?<br><br style="color:rgb(51,153,153)"><div style="margin-left:40px"><span style="color:rgb(51,153,153)">tmprank = getrank(tmpdata(:,1:min(3000, size(tmpdata,2))));</span><br>

</div><br>For the life of me I can not figure out exactly what the getrank() function does.  I can't find it anywhere.  How is it different from the normal old rank() function?<br><br>And how does the rank calculation code in the main body of pop_runica relate to the rank calculation at the end, which is the code that seems relevant for the error message that Marco and I keep getting?  How does it decide to go from this <br>

<br><div style="margin-left:40px"><span style="color:rgb(51,153,153)">tmprank = getrank(tmpdata(:,1:min(3000, size(tmpdata,2))));</span><br></div><br>to this?<br><br><div style="margin-left:40px"><span style="color:rgb(51,153,153)">function tmprank2 = getrank(tmpdata);</span><br style="color:rgb(51,153,153)">

<span style="color:rgb(51,153,153)">    tmprank = rank(tmpdata);</span><br style="color:rgb(51,153,153)"><span style="color:rgb(51,153,153)">    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span><br style="color:rgb(51,153,153)">

<span style="color:rgb(51,153,153)">    %Here: alternate computation of the rank by Sven Hoffman</span><br style="color:rgb(51,153,153)"><span style="color:rgb(51,153,153)">    %tmprank = rank(tmpdata(:,1:min(3000, size(tmpdata,2)))); old code</span><br style="color:rgb(51,153,153)">

<span style="color:rgb(51,153,153)">    covarianceMatrix = cov(tmpdata', 1);</span><br style="color:rgb(51,153,153)"><span style="color:rgb(51,153,153)">    [E, D] = eig (covarianceMatrix);</span><br style="color:rgb(51,153,153)">

<span style="color:rgb(51,153,153)">    rankTolerance = 1e-7;</span><br style="color:rgb(51,153,153)"><span style="color:rgb(51,153,153)">    tmprank2=sum (diag (D) > rankTolerance);</span><br style="color:rgb(51,153,153)">

<span style="color:rgb(51,153,153)">    if tmprank ~= tmprank2</span><br style="color:rgb(51,153,153)"><span style="color:rgb(51,153,153)">        fprintf('Warning: fixing rank computation inconsistency (%d vs %d) most likely because running under Linux 64-bit Matlab', tmprank, tmprank2);</span><br style="color:rgb(51,153,153)">

<span style="color:rgb(51,153,153)">        tmprank2 = max(tmprank, tmprank2);</span><br style="color:rgb(51,153,153)"><span style="color:rgb(51,153,153)">    end;</span><br></div>            <br>Thanks for everyone's help as always.<br>

<br>-Matthew Stief<div><div></div><div class="h5"><br><br><br><br><div class="gmail_quote">On Sun, Feb 19, 2012 at 2:24 PM, Tarik S Bel-Bahar <span dir="ltr"><<a href="mailto:tarikbelbahar@gmail.com" target="_blank">tarikbelbahar@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>If using normal runica, you could pca reduce by one dimension, to reflect the reduction by one rank, because of average referencing. Amica from jason palmer should avoid these issues. Overall, your decomposition should look okay and interpretable, even if you are getting those messages, especially if you have followed all other preprocessing steps such as filtering, removing baseline, and artifactual period removal. There was some discussion about rank dimensions in data on previous eeglab discussions, which you can search for, including a note about that warning message that you are getting, but I dont think a final principled solution was setup. </p>

<div><div>

<div class="gmail_quote">On Feb 19, 2012 10:22 AM, "Marco Montalto" <<a href="mailto:montaltomarco@onvol.net" target="_blank">montaltomarco@onvol.net</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Dear all,<br>
<br>
I have data from 13 subjects which I am filtering, removing bad channels, re-referencing to average, epoching and then selecting epochs. When I run ICA I get the following warning (example from one particular dataset):<br>



<br>
Warning: fixing rank computation inconsistency (31 vs 30) most likely because running under Linux 64-bit Matlab<br>
<br>
And I get as many IC components as there are remaining channels.<br>
<br>
But for some datasets, which have been processed similarly to the other datasets, ICA correctly gives one component less than there are remaining channels.<br>
<br>
I have switched from single precision to double precision and now all datasets, after running ICA, give equal number of components as there are remaining channels (but still giving the warning message above).<br>
<br>
I am using EEGLAB version 10.2.5.8b running on MATLAB version 7.12.0.635 (R2011a) on a Macbook Pro (Dual Core).<br>
<br>
Can anyone give me some advise regarding this warning? Should I ignore it and continue working with double precision or am I doing something wrong?<br>
<br>
Thanks!<br>
<br>
Marco<br clear="all"></blockquote></div></div></div></blockquote></div><br></div></div><font color="#888888">-- <br>_________________________________________________________________<br>Matthew Stief<br>Human Development | Sex & Gender Lab | Cornell University<br>

<a href="http://www.human.cornell.edu/HD/sexgender" target="_blank">http://www.human.cornell.edu/HD/sexgender</a><br><br><br>Heterosexuality isn't normal, it's just common.<br>-Dorothy Parker<br>
</font><br>_______________________________________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>
For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu">eeglablist-request@sccn.ucsd.edu</a><br></blockquote></div><br><br clear="all"><div><br></div>
-- <br>Scott Makeig, Research Scientist and Director, Swartz Center for Computational Neuroscience, Institute for Neural Computation; Prof. of Neurosciences (Adj.), University of California San Diego, La Jolla CA 92093-0559, <a href="http://sccn.ucsd.edu/%7Escott" target="_blank">http://sccn.ucsd.edu/~scott</a><br>

</div>