<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="">Hi Jona,<div class=""><br class=""></div><div class="">that makes sense. I have another couple of questions, if you don’t mind me asking. :)</div><div class=""><br class=""></div><div class="">1) I tried to use&nbsp;<span style="font-family: Menlo;" class="">linear_regression_raw </span>on my data, but I got the weird result attached. It looked like my data needed to be baseline-corrected (which isn’t apparently applied within the actual function), but I wouldn't know how to do it. Is it the <font face="Menlo" class="">apply_baseline&nbsp;</font>method that I should use for that purpose?</div><div class=""><br class=""></div><div class="">2) A way around the problem in 1) would be to use&nbsp;<span style="font-family: Menlo;" class="">linear_regression&nbsp;</span>on already epoched and baseline-corrected data as shown&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="" style="font-family: LucidaGrande;">here</a>. Is there a plotting results other than the topomaps exemplified there?</div><div class=""><br class=""></div><div class="">3) I don’t seem to understand what some of the arguments of&nbsp;<span style="font-family: Menlo;" class="">linear_regression_raw&nbsp;</span>really say. In particular, which argument takes the predictors to run the regression against - <font face="Menlo" class="">covariates </font>or <font face="Menlo" class="">solver</font>? What does each of them actually do?</div><div class=""><br class=""></div><div class="">Many thanks for all the help, and apologies for the amount of questions!</div><div class=""><br class=""></div><div class="">-Roberto</div><div class=""><br class=""></div><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">----------<br class="">Roberto Petrosino<br class="">Ph.D. Student in Linguistics</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">CT Institute for&nbsp;the Brain&nbsp;and Cognitive Sciences<br class="">University of Connecticut<br class=""><br class=""></div></div></div></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Aug 30, 2017, at 4:40 AM, Jona Sassenhagen &lt;<a href="mailto:jona.sassenhagen@gmail.com" class="">jona.sassenhagen@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">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 style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">(The suggestion is to use pandas data frames for linear_regression_raw)</div><div style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">They work completely differently. One fits independent models at each time point, the other fits one model for the whole data set.</div><div style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><br class="" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><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="" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><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 style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">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 style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">So it’s just a regressor for how late you are in the experiment.</div></div></blockquote></div><br class=""></body></html>