<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 29. Aug 2017, at 02:42, Roberto Petrosino &lt;<a href="mailto:roberto.petrosino@uconn.edu" class="">roberto.petrosino@uconn.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Jona,<div class=""><br class=""></div><div class="">many thanks for your reply.&nbsp;</div><div class=""><br class=""></div><div class="">So,&nbsp;<font face="Menlo" class="">linear_regression_raw</font>&nbsp;will take predictors from the&nbsp;<font face="Menlo" class="">covariates</font>&nbsp;argument, which will have to refer to an array having the same length as the event file - am I correct? What is the reasoning behind having two regression functions (one for continuous and one for non-continuous data)?&nbsp;</div><div class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div>(The suggestion is to use pandas data frames for linear_regression_raw)</div><div>They work completely differently. One fits independent models at each time point, the other fits one model for the whole data set.</div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">I was looking at the script&nbsp;<a href="http://martinos.org/mne/dev/auto_examples/stats/plot_sensor_regression.html#sphx-glr-auto-examples-stats-plot-sensor-regression-py" class="">here</a>, and I was a bit unclear about some lines of code -&nbsp;I just started migrating from eeglab, so I apologize if I sound completely ignorant about everything here.</div><div class=""><br class=""></div><div class=""><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; padding: 10px; margin-top: 0px; margin-bottom: 10.5px; line-height: 1.42857143; word-break: break-all; word-wrap: break-word; color: rgb(123, 138, 139); border: 1px solid rgb(204, 204, 204); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(242, 249, 255) !important;"><span class="n" style="box-sizing: border-box;">names</span> <span class="o" style="box-sizing: border-box; color: rgb(102, 102, 102);">=</span> <span class="p" style="box-sizing: border-box;">[</span><span class="s1" style="box-sizing: border-box; color: rgb(64, 112, 160);">'intercept'</span><span class="p" style="box-sizing: border-box;">,</span> <span class="s1" style="box-sizing: border-box; color: rgb(64, 112, 160);">'trial-count'</span><span class="p" style="box-sizing: border-box;">]</span>

<span class="n" style="box-sizing: border-box;">intercept</span> <span class="o" style="box-sizing: border-box; color: rgb(102, 102, 102);">=</span> <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.ones.html#numpy.ones" title="View documentation for numpy.ones" class="" style="box-sizing: border-box; color: rgb(41, 122, 204); text-decoration: none;"><span class="n" style="box-sizing: border-box;">np</span><span class="o" style="box-sizing: border-box; color: rgb(102, 102, 102);">.</span><span class="n" style="box-sizing: border-box;">ones</span></a><span class="p" style="box-sizing: border-box;">((</span><span class="nb" style="box-sizing: border-box; color: rgb(0, 112, 32);">len</span><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">epochs</span><span class="p" style="box-sizing: border-box;">),),</span> <span class="n" style="box-sizing: border-box;">dtype</span><span class="o" style="box-sizing: border-box; color: rgb(102, 102, 102);">=</span><span class="n" style="box-sizing: border-box;">np</span><span class="o" style="box-sizing: border-box; color: rgb(102, 102, 102);">.</span><span class="n" style="box-sizing: border-box;">float</span><span class="p" style="box-sizing: border-box;">)</span>
<span class="n" style="box-sizing: border-box;">design_matrix</span> <span class="o" style="box-sizing: border-box; color: rgb(102, 102, 102);">=</span> <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.column_stack.html#numpy.column_stack" title="View documentation for numpy.column_stack" class="" style="box-sizing: border-box; color: rgb(41, 122, 204); text-decoration: none;"><span class="n" style="box-sizing: border-box;">np</span><span class="o" style="box-sizing: border-box; color: rgb(102, 102, 102);">.</span><span class="n" style="box-sizing: border-box;">column_stack</span></a><span class="p" style="box-sizing: border-box;">([</span><span class="n" style="box-sizing: border-box;">intercept</span><span class="p" style="box-sizing: border-box;">,</span>  <span class="c1" style="box-sizing: border-box; color: rgb(64, 128, 144); font-style: italic;"># intercept</span>
                                 <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html#numpy.linspace" title="View documentation for numpy.linspace" class="" style="box-sizing: border-box; color: rgb(41, 122, 204); text-decoration: none;"><span class="n" style="box-sizing: border-box;">np</span><span class="o" style="box-sizing: border-box; color: rgb(102, 102, 102);">.</span><span class="n" style="box-sizing: border-box;">linspace</span></a><span class="p" style="box-sizing: border-box;">(</span><span class="mi" style="box-sizing: border-box; color: rgb(32, 128, 80);">0</span><span class="p" style="box-sizing: border-box;">,</span> <span class="mi" style="box-sizing: border-box; color: rgb(32, 128, 80);">1</span><span class="p" style="box-sizing: border-box;">,</span> <span class="nb" style="box-sizing: border-box; color: rgb(0, 112, 32);">len</span><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">intercept</span><span class="p" style="box-sizing: border-box;">))])</span>
</pre></div><div class="">So, if I’m understanding correctly, here the code is defining one of the two predictors for the next regression analysis. `intercept` is an array as long as the variable `epochs`, and filled with ones. Such an array is “glued” with another array of the same length, filled with evenly spaced numbers between 0 and 0. Everything is then put in the linear regression model:</div></div></blockquote><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><br class=""></div><div class=""><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; padding: 10px; margin-top: 0px; margin-bottom: 10.5px; line-height: 1.42857143; word-break: break-all; word-wrap: break-word; color: rgb(123, 138, 139); border: 1px solid rgb(204, 204, 204); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(242, 249, 255) !important;"><span class="c1" style="box-sizing: border-box; color: rgb(64, 128, 144); font-style: italic;"># also accepts source estimates</span>
<span class="n" style="box-sizing: border-box;">lm</span> <span class="o" style="box-sizing: border-box; color: rgb(102, 102, 102);">=</span> <a href="http://martinos.org/mne/dev/generated/mne.stats.linear_regression.html#mne.stats.linear_regression" title="View documentation for mne.stats.regression.linear_regression" class="" style="box-sizing: border-box; color: rgb(41, 122, 204); text-decoration: none;">linear_regression</a><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">epochs</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">design_matrix</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">names</span><span class="p" style="box-sizing: border-box;">)</span></pre><div class=""><br class=""></div></div><div class="">My question is - what is `trial_count` in the first place? It is defined as follows:</div><div class=""><br class=""></div><div class=""><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; padding: 10px; margin-top: 0px; margin-bottom: 10.5px; line-height: 1.42857143; word-break: break-all; word-wrap: break-word; color: rgb(123, 138, 139); border: 1px solid rgb(204, 204, 204); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(242, 249, 255) !important;"><span class="n" style="box-sizing: border-box;">trial_count</span> <span class="o" style="box-sizing: border-box; color: rgb(102, 102, 102);">=</span> <span class="n" style="box-sizing: border-box;">lm</span><span class="p" style="box-sizing: border-box;">[</span><span class="s1" style="box-sizing: border-box; color: rgb(64, 112, 160);">'trial-count'</span><span class="p" style="box-sizing: border-box;">]</span></pre><div class="">but I don’t seem to understand what that really is. Basically what I was trying to do is plotting rERP waveforms with the epoched regression function, similarly to what is showed for the non-epoched regression function&nbsp;<a href="http://martinos.org/mne/dev/auto_examples/stats/plot_linear_regression_raw.html#sphx-glr-auto-examples-stats-plot-linear-regression-raw-py" class="">here</a>.</div></div><div class=""><br class=""></div></div></blockquote><div><br class=""></div><div>trial_count is the 2nd column of the design matrix. It’s, as you said, evenly spaced numbers from 0 to 1, so it’s 0 for the first and 1 for the last epoch. It gets its name from the “names” list (defined further up) fed as the 3rd argument to linear_regression.</div><div>So it’s just a regressor for how late you are in the experiment.</div></div><div><br class=""></div><div><br class=""></div></body></html>