|
257 | 257 | # Plot the model performances |
258 | 258 | # --------------------------- |
259 | 259 | # |
260 | | -# To visualize the model performances, we can plot them on a flatten |
| 260 | +# To visualize the model performances, we can plot them on a flattened |
261 | 261 | # surface of the brain, using a mapper that is specific to the subject brain. |
262 | 262 | # (Check previous example to see how to use the mapper to Freesurfer average |
263 | 263 | # surface.) |
|
271 | 271 | ############################################################################### |
272 | 272 | # We can see that the "wordnet" features successfully predict a part of the |
273 | 273 | # brain activity, with :math:`R^2` scores as high as 0.4. Note that these |
274 | | -# scores are generalization scores, since they aere computed on a test set not |
| 274 | +# scores are generalization scores, since they are computed on a test set not |
275 | 275 | # seen during the mode fitting. Since we fitted a model independently on each |
276 | 276 | # voxel, we can show the generalization performances at the maximal resolution, |
277 | 277 | # the voxel. |
|
289 | 289 | # the solver over cross-validation. This plot is helpful to refine the alpha |
290 | 290 | # grid if the range is too small or too large. |
291 | 291 | # |
292 | | -# Note that some voxels are at the maximum regularization of the grid. These |
293 | | -# are voxels where the model has no predictive power, and where the optimal |
294 | | -# regularization is large to lead to a prediction equal to zero. |
295 | | -# We do not need to extend the alpha range for these voxels. |
| 292 | +# Note that some voxels might be at the maximum regularization value in the grid |
| 293 | +# search. These are voxels where the model has no predictive power, thus |
| 294 | +# the optimal regularization parameter is large to lead to a prediction equal |
| 295 | +# to zero. We do not need to extend the alpha range for these voxels. |
296 | 296 |
|
297 | 297 | from himalaya.viz import plot_alphas_diagnostic |
298 | 298 | best_alphas = backend.to_numpy(pipeline[-1].best_alphas_) |
|
304 | 304 | # ----------------------------------- |
305 | 305 | # |
306 | 306 | # To present an example of model comparison, we define here another model, |
307 | | -# without feature delays (i.e. no ``Delayer``). This model is unlikely to |
308 | | -# perform well, since fMRI responses are delayed in time with respect to |
309 | | -# the stimulus. |
| 307 | +# without feature delays (i.e. no ``Delayer``). Because the BOLD signal is |
| 308 | +# inherently slow due to the dynamics of neuro-vascular coupling, this model |
| 309 | +# is unlikely to perform well. |
310 | 310 |
|
311 | 311 | pipeline_nodelay = make_pipeline( |
312 | 312 | StandardScaler(with_mean=True, with_std=False), |
|
351 | 351 | # Visualize the HRF |
352 | 352 | # ----------------- |
353 | 353 | # |
354 | | -# We just saw that delays are necessary to model the BOLD response in such |
355 | | -# fMRI recordings. Here we show how to visualize the hemodynamic response |
356 | | -# function (HRF), as captured in the ridge regression weights. |
| 354 | +# We just saw that delays are necessary to model BOLD responses. |
| 355 | +# Here we show how the fitted ridge regression weights follow the hemodynamic response |
| 356 | +# function (HRF). |
357 | 357 | # |
358 | 358 | # Fitting a kernel ridge regression results in a set of coefficients called the |
359 | | -# "dual" coefficients :math:`w`. These coefficients are different from the |
| 359 | +# "dual" coefficients :math:`w`. These coefficients differ from the |
360 | 360 | # "primal" coefficients :math:`\beta` obtained with a ridge regression, |
361 | 361 | # but the primal coefficients can be computed from the dual coefficients |
362 | 362 | # using the training features :math:`X`: |
|
410 | 410 | # In this dataset, the brain responses are recorded every two seconds. |
411 | 411 | # |
412 | 412 | # We see that the hemodynamic response function (HRF) is captured in the model |
413 | | -# weights. In practice, we can limit the number of features by using only |
| 413 | +# weights. In this dataset, we can limit the number of features by using only |
414 | 414 | # the most informative delays, for example [1, 2, 3, 4]. |
415 | 415 |
|
416 | 416 | ############################################################################### |
|
0 commit comments