|
237 | 237 | "outputs": [], |
238 | 238 | "source": [ |
239 | 239 | "from voxelwise_tutorials.io import get_data_home\n", |
| 240 | + "\n", |
240 | 241 | "directory = get_data_home(dataset=\"shortclips\")\n", |
241 | 242 | "print(directory)" |
242 | 243 | ] |
|
291 | 292 | "outputs": [], |
292 | 293 | "source": [ |
293 | 294 | "import os\n", |
| 295 | + "\n", |
294 | 296 | "file_name = os.path.join(directory, 'responses', f'{subject}_responses.hdf')\n", |
295 | 297 | "Y_test = load_hdf5_array(file_name, key=\"Y_test\")\n", |
296 | 298 | "print(\"(n_repeats, n_samples_test, n_voxels) =\", Y_test.shape)" |
|
313 | 315 | "outputs": [], |
314 | 316 | "source": [ |
315 | 317 | "from voxelwise_tutorials.utils import explainable_variance\n", |
| 318 | + "\n", |
316 | 319 | "ev = explainable_variance(Y_test)\n", |
317 | 320 | "print(\"(n_voxels,) =\", ev.shape)" |
318 | 321 | ] |
|
534 | 537 | "outputs": [], |
535 | 538 | "source": [ |
536 | 539 | "from voxelwise_tutorials.io import load_hdf5_sparse_array\n", |
| 540 | + "\n", |
537 | 541 | "voxel_to_fsaverage = load_hdf5_sparse_array(mapper_file,\n", |
538 | 542 | " key='voxel_to_fsaverage')\n", |
539 | 543 | "ev_projected = voxel_to_fsaverage @ ev\n", |
|
2402 | 2406 | "outputs": [], |
2403 | 2407 | "source": [ |
2404 | 2408 | "from voxelwise_tutorials.io import get_data_home\n", |
| 2409 | + "\n", |
2405 | 2410 | "directory = get_data_home(dataset=\"shortclips\")\n", |
2406 | 2411 | "print(directory)" |
2407 | 2412 | ] |
|
2588 | 2593 | "from voxelwise_tutorials.delayer import Delayer\n", |
2589 | 2594 | "from himalaya.kernel_ridge import KernelRidgeCV\n", |
2590 | 2595 | "from himalaya.backend import set_backend\n", |
| 2596 | + "\n", |
2591 | 2597 | "backend = set_backend(\"torch_cuda\", on_error=\"warn\")\n", |
2592 | 2598 | "\n", |
2593 | 2599 | "X_train = X_train.astype(\"float32\")\n", |
|
2614 | 2620 | "outputs": [], |
2615 | 2621 | "source": [ |
2616 | 2622 | "from sklearn import set_config\n", |
| 2623 | + "\n", |
2617 | 2624 | "set_config(display='diagram') # requires scikit-learn 0.23\n", |
2618 | 2625 | "pipeline" |
2619 | 2626 | ] |
|
2710 | 2717 | "outputs": [], |
2711 | 2718 | "source": [ |
2712 | 2719 | "import matplotlib.pyplot as plt\n", |
2713 | | - "fig, axs = plt.subplots(6, 1, figsize=(8, 6.5), constrained_layout=True, \n", |
2714 | | - " sharex=True)\n", |
2715 | | - "times = np.arange(n_trs)*TR\n", |
| 2720 | + "\n", |
| 2721 | + "fig, axs = plt.subplots(6, 1, figsize=(8, 6.5), constrained_layout=True,\n", |
| 2722 | + " sharex=True)\n", |
| 2723 | + "times = np.arange(n_trs) * TR\n", |
2716 | 2724 | "\n", |
2717 | 2725 | "axs[0].plot(times, y, color=\"r\")\n", |
2718 | 2726 | "axs[0].set_title(\"BOLD response\")\n", |
2719 | 2727 | "for i, (ax, xx) in enumerate(zip(axs.flat[1:], x_delayed.T)):\n", |
2720 | | - " ax.plot(times, xx, color='k')\n", |
2721 | | - " ax.set_title(\"$x(t - {0:.0f})$ (feature delayed by {1} sample{2})\".format(\n", |
2722 | | - " i*TR, i, \"\" if i == 1 else \"s\"))\n", |
| 2728 | + " ax.plot(times, xx, color='k')\n", |
| 2729 | + " ax.set_title(\"$x(t - {0:.0f})$ (feature delayed by {1} sample{2})\".format(\n", |
| 2730 | + " i * TR, i, \"\" if i == 1 else \"s\"))\n", |
2723 | 2731 | "for ax in axs.flat:\n", |
2724 | | - " ax.axvline(40, color='gray')\n", |
2725 | | - " ax.set_yticks([])\n", |
| 2732 | + " ax.axvline(40, color='gray')\n", |
| 2733 | + " ax.set_yticks([])\n", |
2726 | 2734 | "_ = axs[-1].set_xlabel(\"Time [s]\")\n", |
2727 | 2735 | "plt.show()" |
2728 | 2736 | ] |
|
4240 | 4248 | "name": "python", |
4241 | 4249 | "nbconvert_exporter": "python", |
4242 | 4250 | "pygments_lexer": "ipython3", |
4243 | | - "version": "3.7.12" |
| 4251 | + "version": "3.9.0" |
4244 | 4252 | }, |
4245 | 4253 | "name": "_merged" |
4246 | 4254 | }, |
|
0 commit comments