Skip to content

Commit 70c06fe

Browse files
committed
MNT add jupyter notebooks generated from the tutorials
1 parent c78c8fe commit 70c06fe

15 files changed

Lines changed: 2210 additions & 2 deletions

doc/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ html-noplot:
2828
@echo
2929
@echo "Build finished (noplot). The HTML pages are in $(BUILDDIR)/html."
3030

31+
notebooks:
32+
rm -f ../tutorials/notebooks/*/*.ipynb
33+
python create_notebooks.py

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ sphinx_gallery
1313
```bash
1414
cd doc
1515
make html
16+
make notebooks
1617
firefox _build/html/index.html
1718
```

doc/create_notebooks.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
if __name__ == "__main__":
3+
import os
4+
import shutil
5+
6+
archive_name = "auto_examples/auto_examples_jupyter.zip"
7+
if not os.path.exists(archive_name):
8+
raise RuntimeError(
9+
f"{archive_name} does not exist, please run `make html` first.")
10+
11+
extract_dir = "../tutorials/notebooks/"
12+
shutil.unpack_archive(archive_name, extract_dir=extract_dir)
13+
print(f'Extracted {archive_name} to {extract_dir}')

tutorials/movies_3T/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This tutorial requires the following Python packages:
2727
- scipy
2828
- h5py
2929
- scikit-learn
30-
- voxelwise (this repository)
30+
- voxelwise_tutorials (this repository)
3131
- himalaya
3232
- pymoten (optional, for extracting motion energy)
3333
- cupy/pytorch (optional, to use GPU in himalaya)

tutorials/movies_4T/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This tutorial requires the following Python packages:
3030
- scipy
3131
- h5py
3232
- scikit-learn
33-
- voxelwise (this repository)
33+
- voxelwise_tutorials (this repository)
3434
- himalaya
3535
- pymoten (optional, for extracting motion energy)
3636
- cupy/pytorch (optional, to use GPU in himalaya)

tutorials/notebooks/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Jupyter notebooks
2+
3+
This directory contains a copy of each python script as a jupyter notebook.
4+
These notebooks are generated automatically by `sphinx-gallery`, and do not
5+
render any content. To see rendered versions of the tutorials, go to the
6+
[tutorials website](https://gallantlab.github.io/voxelwise_tutorials)
7+
8+
## Run the notebooks
9+
To run the notebooks yourself, you first need to download this repository and
10+
install the `voxelwise_tutorials` package:
11+
12+
```bash
13+
git clone https://github.com/gallantlab/voxelwise_tutorials.git
14+
cd voxelwise_tutorials
15+
pip install .
16+
```
17+
18+
You also need the following dependencies:
19+
20+
- numpy
21+
- scipy
22+
- h5py
23+
- scikit-learn
24+
- jupyter
25+
- matplotlib
26+
- himalaya
27+
- pycortex (optional, for using 3D brain viewers)
28+
- pymoten (optional, for extracting motion energy)
29+
- cupy/pytorch (optional, to use a GPU backend in himalaya)
30+
31+
For more info about how to run jupyter notebooks, see
32+
[the official documentation](https://jupyter-notebook.readthedocs.io/en/stable/).
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {
7+
"collapsed": false
8+
},
9+
"outputs": [],
10+
"source": [
11+
"%matplotlib inline"
12+
]
13+
},
14+
{
15+
"cell_type": "markdown",
16+
"metadata": {},
17+
"source": [
18+
"\n# Download the data set from CRCNS\n\n\nIn this script, we download the data set from CRCNS.\nA (free) account is required.\n\nCite this data set\n------------------\n\nThis tutorial is based on publicly available data\n`published on CRCNS <https://crcns.org/data-sets/vc/TBD>`_.\nIf you publish any work using this data set, please cite the original\npublication [1]_, and the data set [2]_.\n\n.. [1] Huth, A. G., Nishimoto, S., Vu, A. T., & Gallant, J. L. (2012). A\n continuous semantic space describes the representation of thousands of\n object and action categories across the human brain. Neuron, 76(6),\n 1210-1224.\n\n.. [2] Huth, A. G., Nishimoto, S., Vu, A. T., & Gallant, J. L. (2020):\n Gallant Lab Natural Movie 3T fMRI Data. CRCNS.org.\n http://dx.doi.org/10.6080/TBD\n"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {
25+
"collapsed": false
26+
},
27+
"outputs": [],
28+
"source": [
29+
""
30+
]
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"Download\n--------\n\n"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"metadata": {
43+
"collapsed": false
44+
},
45+
"outputs": [],
46+
"source": [
47+
"# path of the data directory\nimport os\nfrom voxelwise_tutorials.io import get_data_home\ndirectory = os.path.join(get_data_home(), \"vim-4\")\nprint(directory)"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": [
54+
"We will only use the first subject in this tutorial, but you can run the same\nanalysis on the four other subjects. Uncomment the lines in ``DATAFILES``` to\ndownload more subjects.\n\nWe also skip the stimuli files, since the dataset provides two preprocessed\nfeature spaces to perform voxelwise modeling without requiring the original\nstimuli.\n\n"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {
61+
"collapsed": false
62+
},
63+
"outputs": [],
64+
"source": [
65+
"import getpass\n\nfrom voxelwise_tutorials.io import download_crcns\n\nDATAFILES = [\n \"TBD/features/motion_energy.hdf\",\n \"TBD/features/wordnet.hdf\",\n \"TBD/mappers/S01_mappers.hdf\",\n # \"TBD/mappers/S02_mappers.hdf\",\n # \"TBD/mappers/S03_mappers.hdf\",\n # \"TBD/mappers/S04_mappers.hdf\",\n # \"TBD/mappers/S05_mappers.hdf\",\n \"TBD/responses/S01_responses.hdf\",\n # \"TBD/responses/S02_responses.hdf\",\n # \"TBD/responses/S03_responses.hdf\",\n # \"TBD/responses/S04_responses.hdf\",\n # \"TBD/responses/S05_responses.hdf\",\n # \"TBD/stimuli/test.hdf\",\n # \"TBD/stimuli/train_00.hdf\",\n # \"TBD/stimuli/train_01.hdf\",\n # \"TBD/stimuli/train_02.hdf\",\n # \"TBD/stimuli/train_03.hdf\",\n # \"TBD/stimuli/train_04.hdf\",\n # \"TBD/stimuli/train_05.hdf\",\n # \"TBD/stimuli/train_06.hdf\",\n # \"TBD/stimuli/train_07.hdf\",\n # \"TBD/stimuli/train_08.hdf\",\n # \"TBD/stimuli/train_09.hdf\",\n # \"TBD/stimuli/train_10.hdf\",\n # \"TBD/stimuli/train_11.hdf\",\n]"
66+
]
67+
},
68+
{
69+
"cell_type": "code",
70+
"execution_count": null,
71+
"metadata": {
72+
"collapsed": false
73+
},
74+
"outputs": [],
75+
"source": [
76+
"username = input(\"CRCNS username: \")\npassword = getpass.getpass(\"CRCNS password: \")\n\nfor datafile in DATAFILES:\n local_filename = download_crcns(datafile, username, password,\n destination=directory)"
77+
]
78+
}
79+
],
80+
"metadata": {
81+
"kernelspec": {
82+
"display_name": "Python 3",
83+
"language": "python",
84+
"name": "python3"
85+
},
86+
"language_info": {
87+
"codemirror_mode": {
88+
"name": "ipython",
89+
"version": 3
90+
},
91+
"file_extension": ".py",
92+
"mimetype": "text/x-python",
93+
"name": "python",
94+
"nbconvert_exporter": "python",
95+
"pygments_lexer": "ipython3",
96+
"version": "3.7.3"
97+
}
98+
},
99+
"nbformat": 4,
100+
"nbformat_minor": 0
101+
}

0 commit comments

Comments
 (0)