Skip to content

Commit 4ba0071

Browse files
committed
MNT rename tutorials and simplify merged tutorials for colab
1 parent 56c6141 commit 4ba0071

11 files changed

Lines changed: 244 additions & 211 deletions

tutorials/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,25 @@ NBDIR = notebooks/shortclips
2323
merge-notebooks:
2424
python merge_notebooks.py \
2525
$(NBDIR)/01_setup_colab.ipynb \
26+
$(NBDIR)/02_download_shortclips.ipynb \
2627
$(NBDIR)/03_compute_explainable_variance.ipynb \
2728
$(NBDIR)/04_understand_ridge_regression.ipynb \
2829
$(NBDIR)/05_fit_wordnet_model.ipynb \
2930
$(NBDIR)/06_visualize_hemodynamic_response.ipynb \
3031
$(NBDIR)/08_fit_motion_energy_model.ipynb \
3132
$(NBDIR)/09_fit_banded_ridge_model.ipynb \
32-
> $(NBDIR)/merged_for_colab.ipynb
33-
echo "Saved in $(NBDIR)/merged_for_colab.ipynb"
33+
> $(NBDIR)/vem_tutorials_merged_for_colab.ipynb
34+
echo "Saved in $(NBDIR)/vem_tutorials_merged_for_colab.ipynb"
3435

3536
python merge_notebooks.py \
3637
$(NBDIR)/01_setup_colab.ipynb \
38+
$(NBDIR)/02_download_shortclips.ipynb \
3739
$(NBDIR)/03_compute_explainable_variance.ipynb \
3840
$(NBDIR)/05_fit_wordnet_model.ipynb \
3941
$(NBDIR)/08_fit_motion_energy_model.ipynb \
4042
$(NBDIR)/09_fit_banded_ridge_model.ipynb \
41-
> $(NBDIR)/merged_for_colab_model_fitting.ipynb
42-
echo "Saved in $(NBDIR)/merged_for_colab_model_fitting.ipynb"
43+
> $(NBDIR)/vem_tutorials_merged_for_colab_model_fitting.ipynb
44+
echo "Saved in $(NBDIR)/vem_tutorials_merged_for_colab_model_fitting.ipynb"
4345

4446
build:
4547
jupyter book build --all $(SOURCEDIR)

tutorials/_config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ execute:
1313
exclude_patterns:
1414
- notebooks/shortclips/00_setup_colab.ipynb
1515
- notebooks/shortclips/07_extract_motion_energy.ipynb
16-
- notebooks/shortclips/merged_for_colab_model_fitting.ipynb
17-
- notebooks/shortclips/merged_for_colab.ipynb
16+
- notebooks/shortclips/vem_tutorials_merged_for_colab_model_fitting.ipynb
17+
- notebooks/shortclips/vem_tutorials_merged_for_colab.ipynb
1818
- notebooks/vim2/00_download_vim2.ipynb
1919
- notebooks/vim2/01_extract_motion_energy.ipynb
2020
- notebooks/vim2/02_plot_ridge_model.ipynb

tutorials/merge_notebooks.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
python merge_notebooks.py A.ipynb B.ipynb C.ipynb > merged.ipynb
66
"""
77
import io
8-
import sys
98
import os.path
9+
import sys
1010

1111
import nbformat
1212

@@ -19,13 +19,15 @@ def merge_notebooks(filenames):
1919
if merged is None:
2020
merged = nb
2121
# add a Markdown cell with the file name, then all cells
22-
merged.cells = [cell_with_title(title=os.path.basename(fname))
23-
] + nb.cells
22+
# merged.cells = [cell_with_title(title=os.path.basename(fname))
23+
# ] + nb.cells
24+
# Do not add the title cell, use the title in each notebook
25+
merged.cells = nb.cells
2426
else:
2527
# add a code cell resetting all variables
2628
merged.cells.append(cell_with_reset())
2729
# add a Markdown cell with the file name
28-
merged.cells.append(cell_with_title(title=os.path.basename(fname)))
30+
# merged.cells.append(cell_with_title(title=os.path.basename(fname)))
2931
# add all cells from current notebook
3032
merged.cells.extend(nb.cells)
3133

tutorials/notebooks/shortclips/01_setup_colab.ipynb

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@
3434
"cell_type": "markdown",
3535
"metadata": {},
3636
"source": [
37-
"## Install all required dependencies and download the data\n",
37+
"## Install all required dependencies\n",
3838
"\n",
39-
"Uncomment and run the following cell to download the required packages.\n",
40-
"\n"
39+
"Uncomment and run the following cell to download the required packages."
4140
]
4241
},
4342
{
@@ -99,42 +98,6 @@
9998
" \"on your machine.\")"
10099
]
101100
},
102-
{
103-
"cell_type": "markdown",
104-
"metadata": {},
105-
"source": [
106-
"Now run the following cell to download the data for the tutorials.\n",
107-
"\n"
108-
]
109-
},
110-
{
111-
"cell_type": "code",
112-
"execution_count": null,
113-
"metadata": {
114-
"collapsed": false
115-
},
116-
"outputs": [],
117-
"source": [
118-
"from voxelwise_tutorials.io import download_datalad\n",
119-
"\n",
120-
"DATAFILES = [\n",
121-
" \"features/motion_energy.hdf\",\n",
122-
" \"features/wordnet.hdf\",\n",
123-
" \"mappers/S01_mappers.hdf\",\n",
124-
" \"responses/S01_responses.hdf\",\n",
125-
"]\n",
126-
"\n",
127-
"source = \"https://gin.g-node.org/gallantlab/shortclips\"\n",
128-
"destination = \"/content/shortclips\"\n",
129-
"\n",
130-
"for datafile in DATAFILES:\n",
131-
" local_filename = download_datalad(\n",
132-
" datafile,\n",
133-
" destination=destination,\n",
134-
" source=source\n",
135-
" )"
136-
]
137-
},
138101
{
139102
"cell_type": "markdown",
140103
"metadata": {},

tutorials/notebooks/shortclips/04_understand_ridge_regression.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"\n",
8-
"# Understand ridge regression and cross-validation\n",
7+
"# Understand ridge regression and hyperparameter selection\n",
98
"\n",
109
"In future examples, we will model the fMRI responses using a regularized linear\n",
1110
"regression known as *ridge regression*. This example explains why we use ridge\n",
1211
"regression, and how to use cross-validation to select the appropriate\n",
13-
"regularization hyper-parameter.\n",
12+
"regularization hyperparameter.\n",
1413
"\n",
1514
"Linear regression is a method to model the relation between some input\n",
1615
"variables $X \\in \\mathbb{R}^{(n \\times p)}$ (the features) and an output\n",

tutorials/notebooks/shortclips/05_fit_wordnet_model.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"\n",
8-
"# Fit a ridge model with wordnet features\n",
7+
"# Fit a voxelwise encoding model with WordNet features\n",
98
"\n",
109
"In this example, we model the fMRI responses with semantic \"wordnet\" features,\n",
1110
"manually annotated on each frame of the movie stimulus. The model is a\n",

tutorials/notebooks/shortclips/08_fit_motion_energy_model.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"\n",
8-
"# Fit a ridge model with motion-energy features\n",
7+
"# Fit a voxelwise encoding model with motion-energy features\n",
98
"\n",
109
"In this example, we model the fMRI responses with motion-energy features\n",
1110
"extracted from the movie stimulus. The model is a regularized linear regression\n",

tutorials/notebooks/shortclips/09_fit_banded_ridge_model.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Fit a banded ridge model with both wordnet and motion-energy features\n",
7+
"# Fit a voxelwise encoding model with both WordNet and motion-energy features\n",
88
"\n",
99
"In this example, we model the fMRI responses with a *banded ridge regression* \n",
1010
"with two different feature spaces: motion energy and wordnet categories.\n",

0 commit comments

Comments
 (0)