|
57 | 57 | print("(n_voxels,) =", ev.shape) |
58 | 58 |
|
59 | 59 | ############################################################################### |
60 | | -# We can plot the distribution of explainable variance over voxels. |
| 60 | +# To better understand the explainable variance, we can plot the time-courses |
| 61 | +# of a voxel with large explainable variance... |
61 | 62 |
|
62 | 63 | import matplotlib.pyplot as plt |
63 | 64 |
|
| 65 | +voxel_1 = np.argmax(ev) |
| 66 | +plt.figure(figsize=(10, 4)) |
| 67 | +plt.plot(Y_test[:, :, voxel_1].T, color='C0', alpha=0.5) |
| 68 | +plt.plot(Y_test[:, :, voxel_1].mean(0), color='C1', label='average') |
| 69 | +plt.xlabel("Time points") |
| 70 | +plt.title("Voxel with large explainable variance (%.2f)" % ev[voxel_1]) |
| 71 | +plt.legend() |
| 72 | +plt.show() |
| 73 | + |
| 74 | +############################################################################### |
| 75 | +# ... and of a voxel with low explainable variance. |
| 76 | +voxel_2 = np.argmin(ev) |
| 77 | +plt.figure(figsize=(10, 4)) |
| 78 | +plt.plot(Y_test[:, :, voxel_2].T, color='C0', alpha=0.5) |
| 79 | +plt.plot(Y_test[:, :, voxel_2].mean(0), color='C1', label='average') |
| 80 | +plt.xlabel("Time points") |
| 81 | +plt.title("Voxel with low explainable variance (%.2f)" % ev[voxel_2]) |
| 82 | +plt.legend() |
| 83 | +plt.show() |
| 84 | + |
| 85 | +############################################################################### |
| 86 | +# We can also plot the distribution of explainable variance over voxels. |
| 87 | + |
64 | 88 | plt.hist(ev, bins=np.linspace(0, 1, 100), log=True, histtype='step') |
65 | 89 | plt.xlabel("Explainable variance") |
66 | 90 | plt.ylabel("Number of voxels") |
|
133 | 157 |
|
134 | 158 | import cortex |
135 | 159 |
|
136 | | -surface = "fsaverage_pycortex" # ("fsaverage" outside the Gallant lab) |
| 160 | +surface = "fsaverage" |
137 | 161 |
|
138 | 162 | if not hasattr(cortex.db, surface): |
139 | 163 | cortex.utils.download_subject(subject_id=surface) |
|
0 commit comments