You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _sources/pages/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ Welcome to the tutorials on the Voxelwise Encoding Model framework from the
5
5
6
6
If you use these tutorials for your work, consider citing the corresponding paper:
7
7
8
-
> T. Dupré La Tour, M. Visconti di Oleggio Castello, and J. L. Gallant. The Voxelwise Encoding Model framework: a tutorial introduction to fitting encoding models to fMRI data. PsyArXiv, 2024. [doi:10.31234/osf.io/t975e.](https://doi.org/10.31234/osf.io/t975e)
8
+
> T. Dupré la Tour, M. Visconti di Oleggio Castello, and J. L. Gallant. The Voxelwise Encoding Model framework: a tutorial introduction to fitting encoding models to fMRI data. PsyArXiv, 2024. [doi:10.31234/osf.io/t975e.](https://doi.org/10.31234/osf.io/t975e)
9
9
10
10
You can find a copy of the paper [here](https://github.com/gallantlab/voxelwise_tutorials/blob/main/paper/voxelwise_tutorials_paper.pdf).
Copy file name to clipboardExpand all lines: notebooks/shortclips/03_compute_explainable_variance.html
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -437,8 +437,8 @@ <h1>Compute the explainable variance<a class="headerlink" href="#compute-the-exp
437
437
across repetitions. For each repeat, we define the residual timeseries between
438
438
brain response and average brain response as <spanclass="math notranslate nohighlight">\(r_i = y_i - \bar{y}\)</span>. The
439
439
explainable variance (EV) is estimated as</p>
440
-
<divclass="amsmath math notranslate nohighlight" id="equation-6b5c66f3-6a1c-4d78-b878-859915a0fd50">
441
-
<spanclass="eqno">(1)<aclass="headerlink" href="#equation-6b5c66f3-6a1c-4d78-b878-859915a0fd50" title="Permalink to this equation">#</a></span>\[\begin{align}\text{EV} = \frac{1}{N}\sum_{i=1}^N\text{Var}(y_i) - \frac{N}{N-1}\sum_{i=1}^N\text{Var}(r_i)\end{align}\]</div>
440
+
<divclass="amsmath math notranslate nohighlight" id="equation-8e371fe2-e3f6-4e66-94c0-74505eac3a2c">
441
+
<spanclass="eqno">(1)<aclass="headerlink" href="#equation-8e371fe2-e3f6-4e66-94c0-74505eac3a2c" title="Permalink to this equation">#</a></span>\[\begin{align}\text{EV} = \frac{1}{N}\sum_{i=1}^N\text{Var}(y_i) - \frac{N}{N-1}\sum_{i=1}^N\text{Var}(r_i)\end{align}\]</div>
442
442
<p>In the literature, the explainable variance is also known as the <em>signal
443
443
power</em>.</p>
444
444
<p>For more information, see <spanid="id1">Sahani and Linden [<aclass="reference internal" href="vem_tutorials_merged_for_colab_model_fitting.html#id158" title="M. Sahani and J. Linden. How linear are auditory cortical responses? Adv. Neural Inf. Process. Syst., 2002.">2002</a>]</span>, <spanid="id2">Hsu <em>et al.</em> [<aclass="reference internal" href="vem_tutorials_merged_for_colab_model_fitting.html#id159" title="A. Hsu, A. Borst, and F. E. Theunissen. Quantifying variability in neural responses and its application for the validation of model predictions. Network, 2004.">2004</a>]</span>, and <spanid="id3">Schoppe <em>et al.</em> [<aclass="reference internal" href="vem_tutorials_merged_for_colab_model_fitting.html#id160" title="O. Schoppe, N. S. Harper, B. Willmore, A. King, and J. Schnupp. Measuring the performance of neural models. Front. Comput. Neurosci., 2016.">2016</a>]</span>.</p>
variable <spanclass="math notranslate nohighlight">\(y \in \mathbb{R}^{n}\)</span> (the target). Specifically, linear
423
423
regression uses a vector of coefficient <spanclass="math notranslate nohighlight">\(w \in \mathbb{R}^{p}\)</span> to
424
424
predict the output</p>
425
-
<divclass="amsmath math notranslate nohighlight" id="equation-4d8e7a72-f95e-45b0-8300-c88feaa9beea">
426
-
<spanclass="eqno">(2)<aclass="headerlink" href="#equation-4d8e7a72-f95e-45b0-8300-c88feaa9beea" title="Permalink to this equation">#</a></span>\[\begin{align}\hat{y} = Xw\end{align}\]</div>
425
+
<divclass="amsmath math notranslate nohighlight" id="equation-44016c9a-386e-4c5d-b726-0c593bd1d3d6">
426
+
<spanclass="eqno">(2)<aclass="headerlink" href="#equation-44016c9a-386e-4c5d-b726-0c593bd1d3d6" title="Permalink to this equation">#</a></span>\[\begin{align}\hat{y} = Xw\end{align}\]</div>
427
427
<p>The model is considered accurate if the predictions <spanclass="math notranslate nohighlight">\(\hat{y}\)</span> are close
428
428
to the true output values <spanclass="math notranslate nohighlight">\(y\)</span>. Therefore, a good linear regression model
429
429
is given by the vector <spanclass="math notranslate nohighlight">\(w\)</span> that minimizes the sum of squared errors:</p>
430
-
<divclass="amsmath math notranslate nohighlight" id="equation-1a0b17c5-4527-49ed-82d6-6178a4173e16">
431
-
<spanclass="eqno">(3)<aclass="headerlink" href="#equation-1a0b17c5-4527-49ed-82d6-6178a4173e16" title="Permalink to this equation">#</a></span>\[\begin{align}w = \arg\min_w ||Xw - y||^2\end{align}\]</div>
430
+
<divclass="amsmath math notranslate nohighlight" id="equation-164582e6-d0f8-4ec6-a812-94b6f84c155f">
431
+
<spanclass="eqno">(3)<aclass="headerlink" href="#equation-164582e6-d0f8-4ec6-a812-94b6f84c155f" title="Permalink to this equation">#</a></span>\[\begin{align}w = \arg\min_w ||Xw - y||^2\end{align}\]</div>
432
432
<p>This is the simplest model for linear regression, and it is known as <em>ordinary
433
433
least squares</em> (OLS).</p>
434
434
<sectionid="ordinary-least-squares-ols">
@@ -480,8 +480,8 @@ <h2>Ordinary least squares (OLS)<a class="headerlink" href="#ordinary-least-squa
480
480
</div>
481
481
<p>The linear coefficient leading to the minimum squared loss can be found
482
482
analytically with the formula:</p>
483
-
<divclass="amsmath math notranslate nohighlight" id="equation-39886a10-bc4c-413a-96a6-a176b7120b6f">
484
-
<spanclass="eqno">(4)<aclass="headerlink" href="#equation-39886a10-bc4c-413a-96a6-a176b7120b6f" title="Permalink to this equation">#</a></span>\[\begin{align}w = (X^\top X)^{-1} X^\top y\end{align}\]</div>
483
+
<divclass="amsmath math notranslate nohighlight" id="equation-ec79a861-adc8-488d-b845-bd06194ee484">
484
+
<spanclass="eqno">(4)<aclass="headerlink" href="#equation-ec79a861-adc8-488d-b845-bd06194ee484" title="Permalink to this equation">#</a></span>\[\begin{align}w = (X^\top X)^{-1} X^\top y\end{align}\]</div>
485
485
<p>This is the OLS solution.</p>
486
486
<divclass="cell docutils container">
487
487
<divclass="cell_input docutils container">
@@ -621,8 +621,8 @@ <h2>Ridge regression<a class="headerlink" href="#ridge-regression" title="Link t
621
621
<p>To solve the instability and under-determinacy issues of OLS, OLS can be
622
622
extended to <em>ridge regression</em>. Ridge regression considers a different
623
623
optimization problem:</p>
624
-
<divclass="amsmath math notranslate nohighlight" id="equation-68b52747-55d0-4018-84bc-cf843e167110">
625
-
<spanclass="eqno">(5)<aclass="headerlink" href="#equation-68b52747-55d0-4018-84bc-cf843e167110" title="Permalink to this equation">#</a></span>\[\begin{align}w = \arg\min_w ||Xw - y||^2 + \alpha ||w||^2\end{align}\]</div>
624
+
<divclass="amsmath math notranslate nohighlight" id="equation-f6de4535-4112-4241-8db4-1486e978a489">
625
+
<spanclass="eqno">(5)<aclass="headerlink" href="#equation-f6de4535-4112-4241-8db4-1486e978a489" title="Permalink to this equation">#</a></span>\[\begin{align}w = \arg\min_w ||Xw - y||^2 + \alpha ||w||^2\end{align}\]</div>
626
626
<p>This optimization problem contains two terms: (i) a <em>data-fitting term</em>
627
627
<spanclass="math notranslate nohighlight">\(||Xw - y||^2\)</span>, which ensures the regression correctly fits the
628
628
training data; and (ii) a regularization term <spanclass="math notranslate nohighlight">\(\alpha||w||^2\)</span>, which
@@ -654,8 +654,8 @@ <h2>Ridge regression<a class="headerlink" href="#ridge-regression" title="Link t
654
654
<p>To understand why the regularization term makes the solution more robust to
655
655
noise, let’s consider the ridge solution. The ridge solution can be found
656
656
analytically with the formula:</p>
657
-
<divclass="amsmath math notranslate nohighlight" id="equation-1886f38e-bd35-4129-8cda-03e4abec2868">
658
-
<spanclass="eqno">(6)<aclass="headerlink" href="#equation-1886f38e-bd35-4129-8cda-03e4abec2868" title="Permalink to this equation">#</a></span>\[\begin{align}w = (X^\top X + \alpha I)^{-1} X^\top y\end{align}\]</div>
657
+
<divclass="amsmath math notranslate nohighlight" id="equation-ea124788-3420-4a26-b1fa-638985501426">
658
+
<spanclass="eqno">(6)<aclass="headerlink" href="#equation-ea124788-3420-4a26-b1fa-638985501426" title="Permalink to this equation">#</a></span>\[\begin{align}w = (X^\top X + \alpha I)^{-1} X^\top y\end{align}\]</div>
659
659
<p>where <codeclass="docutils literal notranslate"><spanclass="pre">I</span></code> is the identity matrix. In this formula, we can see that the
660
660
inverted matrix is now <spanclass="math notranslate nohighlight">\((X^\top X + \alpha I)\)</span>. Compared to OLS, the
661
661
additional term <spanclass="math notranslate nohighlight">\(\alpha I\)</span> adds a positive value <codeclass="docutils literal notranslate"><spanclass="pre">alpha</span></code> to all
Copy file name to clipboardExpand all lines: notebooks/shortclips/06_visualize_hemodynamic_response.html
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1660,8 +1660,8 @@ <h2>Visualize the HRF<a class="headerlink" href="#visualize-the-hrf" title="Link
1660
1660
coefficients <spanclass="math notranslate nohighlight">\(\beta\)</span> obtained with a ridge regression, but the primal
1661
1661
coefficients can be computed from the dual coefficients using the training
1662
1662
features <spanclass="math notranslate nohighlight">\(X\)</span>:</p>
1663
-
<divclass="amsmath math notranslate nohighlight" id="equation-a4fc0a20-0616-4955-85a5-056abdb2afbb">
1664
-
<spanclass="eqno">(7)<aclass="headerlink" href="#equation-a4fc0a20-0616-4955-85a5-056abdb2afbb" title="Permalink to this equation">#</a></span>\[\begin{align}\beta = X^\top w\end{align}\]</div>
1663
+
<divclass="amsmath math notranslate nohighlight" id="equation-647c6f7b-f485-4012-a2fa-40d3832f711b">
1664
+
<spanclass="eqno">(7)<aclass="headerlink" href="#equation-647c6f7b-f485-4012-a2fa-40d3832f711b" title="Permalink to this equation">#</a></span>\[\begin{align}\beta = X^\top w\end{align}\]</div>
1665
1665
<p>To better visualize the HRF, we will refit a model with more delays, but only
1666
1666
on a selection of voxels to speed up the computations.</p>
Copy file name to clipboardExpand all lines: notebooks/shortclips/08_fit_motion_energy_model.html
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1198,7 +1198,7 @@ <h2>Compare with the wordnet model<a class="headerlink" href="#compare-with-the-
1198
1198
could predict responses in face-responsive areas without encoding any
1199
1199
semantic information.</p>
1200
1200
<p>To better disentangle the two feature spaces, we developed a joint model
1201
-
called <codeclass="docutils literal notranslate"><spanclass="pre">banded</span><spanclass="pre">ridge</span><spanclass="pre">regression</span></code><spanid="id4">[<aclass="reference internal" href="../../pages/voxelwise_modeling.html#id25" title="T. Dupré La Tour, M. Eickenberg, A.O. Nunez-Elizalde, and J. L. Gallant. Feature-space selection with banded ridge regression. NeuroImage, 267:119728, 2022. doi:10.1016/j.neuroimage.2022.119728.">Dupré La Tour <em>et al.</em>, 2022</a>, <aclass="reference internal" href="../../pages/voxelwise_modeling.html#id22" title="A. O. Nunez-Elizalde, A. G. Huth, and J. L. Gallant. Voxelwise encoding models with non-spherical multivariate normal priors. Neuroimage, 197:482–492, 2019.">Nunez-Elizalde <em>et al.</em>, 2019</a>]</span>, which fits multiple feature spaces
1201
+
called <codeclass="docutils literal notranslate"><spanclass="pre">banded</span><spanclass="pre">ridge</span><spanclass="pre">regression</span></code><spanid="id4">[<aclass="reference internal" href="../../pages/voxelwise_modeling.html#id25" title="T. Dupré la Tour, M. Eickenberg, A.O. Nunez-Elizalde, and J. L. Gallant. Feature-space selection with banded ridge regression. NeuroImage, 267:119728, 2022. doi:10.1016/j.neuroimage.2022.119728.">Dupré la Tour <em>et al.</em>, 2022</a>, <aclass="reference internal" href="../../pages/voxelwise_modeling.html#id22" title="A. O. Nunez-Elizalde, A. G. Huth, and J. L. Gallant. Voxelwise encoding models with non-spherical multivariate normal priors. Neuroimage, 197:482–492, 2019.">Nunez-Elizalde <em>et al.</em>, 2019</a>]</span>, which fits multiple feature spaces
1202
1202
simultaneously with optimal regularization for each feature space. This model
1203
1203
is described in the next example.</p>
1204
1204
</section>
@@ -1207,8 +1207,8 @@ <h2>References<a class="headerlink" href="#references" title="Link to this headi
<p>T. Dupré La Tour, M. Eickenberg, A.O. Nunez-Elizalde, and J. L. Gallant. Feature-space selection with banded ridge regression. <em>NeuroImage</em>, 267:119728, 2022. <aclass="reference external" href="https://doi.org/10.1016/j.neuroimage.2022.119728">doi:10.1016/j.neuroimage.2022.119728</a>.</p>
<p>T. Dupré la Tour, M. Eickenberg, A.O. Nunez-Elizalde, and J. L. Gallant. Feature-space selection with banded ridge regression. <em>NeuroImage</em>, 267:119728, 2022. <aclass="reference external" href="https://doi.org/10.1016/j.neuroimage.2022.119728">doi:10.1016/j.neuroimage.2022.119728</a>.</p>
Copy file name to clipboardExpand all lines: notebooks/shortclips/09_fit_banded_ridge_model.html
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -422,7 +422,7 @@ <h1>Fit a voxelwise encoding model with both WordNet and motion-energy features<
422
422
with two different feature spaces: motion energy and wordnet categories.</p>
423
423
<p><em>Banded ridge regression:</em> Since the relative scaling of both feature spaces is
424
424
unknown, we use two regularization hyperparameters (one per feature space) in a
425
-
model called banded ridge regression <spanid="id1">[<aclass="reference internal" href="../../pages/voxelwise_modeling.html#id25" title="T. Dupré La Tour, M. Eickenberg, A.O. Nunez-Elizalde, and J. L. Gallant. Feature-space selection with banded ridge regression. NeuroImage, 267:119728, 2022. doi:10.1016/j.neuroimage.2022.119728.">Dupré La Tour <em>et al.</em>, 2022</a>, <aclass="reference internal" href="../../pages/voxelwise_modeling.html#id22" title="A. O. Nunez-Elizalde, A. G. Huth, and J. L. Gallant. Voxelwise encoding models with non-spherical multivariate normal priors. Neuroimage, 197:482–492, 2019.">Nunez-Elizalde <em>et al.</em>, 2019</a>]</span>.
425
+
model called banded ridge regression <spanid="id1">[<aclass="reference internal" href="../../pages/voxelwise_modeling.html#id25" title="T. Dupré la Tour, M. Eickenberg, A.O. Nunez-Elizalde, and J. L. Gallant. Feature-space selection with banded ridge regression. NeuroImage, 267:119728, 2022. doi:10.1016/j.neuroimage.2022.119728.">Dupré la Tour <em>et al.</em>, 2022</a>, <aclass="reference internal" href="../../pages/voxelwise_modeling.html#id22" title="A. O. Nunez-Elizalde, A. G. Huth, and J. L. Gallant. Voxelwise encoding models with non-spherical multivariate normal priors. Neuroimage, 197:482–492, 2019.">Nunez-Elizalde <em>et al.</em>, 2019</a>]</span>.
426
426
Just like with ridge regression, we optimize the hyperparameters over cross-validation.
427
427
An efficient implementation of this model is available in the
take the kernel weights and the ridge (dual) weights corresponding to each
2828
2828
feature space, and use them to compute the prediction from each feature space
2829
2829
separately.</p>
2830
-
<divclass="amsmath math notranslate nohighlight" id="equation-c515e9be-8919-4434-9ba6-8408cf6ab8bd">
2831
-
<spanclass="eqno">(8)<aclass="headerlink" href="#equation-c515e9be-8919-4434-9ba6-8408cf6ab8bd" title="Permalink to this equation">#</a></span>\[\begin{align}\hat{y} = \sum_i^m \hat{y}_i = \sum_i^m \gamma_i K_i \hat{w}\end{align}\]</div>
2830
+
<divclass="amsmath math notranslate nohighlight" id="equation-eab8ce78-6b79-4fd7-ad7d-866dfd1987d3">
2831
+
<spanclass="eqno">(8)<aclass="headerlink" href="#equation-eab8ce78-6b79-4fd7-ad7d-866dfd1987d3" title="Permalink to this equation">#</a></span>\[\begin{align}\hat{y} = \sum_i^m \hat{y}_i = \sum_i^m \gamma_i K_i \hat{w}\end{align}\]</div>
2832
2832
<p>Then, we use these split predictions to compute split <spanclass="math notranslate nohighlight">\(\tilde{R}^2_i\)</span>
2833
2833
scores. These scores are corrected so that their sum is equal to the
2834
2834
<spanclass="math notranslate nohighlight">\(R^2\)</span> score of the full prediction <spanclass="math notranslate nohighlight">\(\hat{y}\)</span>.</p>
motion-energy features predict brain activity in early visual cortex, while
2888
2888
wordnet features predict in semantic visual areas. For more discussions about
2889
2889
these results, we refer the reader to the publications describing the banded ridge
2890
-
regression approach <spanid="id2">[<aclass="reference internal" href="../../pages/voxelwise_modeling.html#id25" title="T. Dupré La Tour, M. Eickenberg, A.O. Nunez-Elizalde, and J. L. Gallant. Feature-space selection with banded ridge regression. NeuroImage, 267:119728, 2022. doi:10.1016/j.neuroimage.2022.119728.">Dupré La Tour <em>et al.</em>, 2022</a>, <aclass="reference internal" href="../../pages/voxelwise_modeling.html#id22" title="A. O. Nunez-Elizalde, A. G. Huth, and J. L. Gallant. Voxelwise encoding models with non-spherical multivariate normal priors. Neuroimage, 197:482–492, 2019.">Nunez-Elizalde <em>et al.</em>, 2019</a>]</span>.</p>
2890
+
regression approach <spanid="id2">[<aclass="reference internal" href="../../pages/voxelwise_modeling.html#id25" title="T. Dupré la Tour, M. Eickenberg, A.O. Nunez-Elizalde, and J. L. Gallant. Feature-space selection with banded ridge regression. NeuroImage, 267:119728, 2022. doi:10.1016/j.neuroimage.2022.119728.">Dupré la Tour <em>et al.</em>, 2022</a>, <aclass="reference internal" href="../../pages/voxelwise_modeling.html#id22" title="A. O. Nunez-Elizalde, A. G. Huth, and J. L. Gallant. Voxelwise encoding models with non-spherical multivariate normal priors. Neuroimage, 197:482–492, 2019.">Nunez-Elizalde <em>et al.</em>, 2019</a>]</span>.</p>
2891
2891
</section>
2892
2892
<sectionid="references">
2893
2893
<h2>References<aclass="headerlink" href="#references" title="Link to this heading">#</a></h2>
<p>T. Dupré La Tour, M. Eickenberg, A.O. Nunez-Elizalde, and J. L. Gallant. Feature-space selection with banded ridge regression. <em>NeuroImage</em>, 267:119728, 2022. <aclass="reference external" href="https://doi.org/10.1016/j.neuroimage.2022.119728">doi:10.1016/j.neuroimage.2022.119728</a>.</p>
2899
+
<p>T. Dupré la Tour, M. Eickenberg, A.O. Nunez-Elizalde, and J. L. Gallant. Feature-space selection with banded ridge regression. <em>NeuroImage</em>, 267:119728, 2022. <aclass="reference external" href="https://doi.org/10.1016/j.neuroimage.2022.119728">doi:10.1016/j.neuroimage.2022.119728</a>.</p>
0 commit comments