Skip to content

Commit 1829efa

Browse files
committed
Upgrade to latest jupyter-book (0.13.1) and add example data.
1 parent 387bb75 commit 1829efa

5 files changed

Lines changed: 84 additions & 67 deletions

File tree

docs/_config.yml

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -34,78 +34,86 @@ html:
3434
parse:
3535
myst_substitutions:
3636
gallery: |
37-
````{panels}
38-
:column: col-4 m-0
39-
:body: p-0
40-
41-
```{link-button} /examples/save_image
42-
:text: Save the high-res image
43-
:type: ref
44-
:classes: stretched-link btn-block m-0 p-0
45-
```
37+
`````{grid}
38+
39+
````{grid-item-card}
40+
:columns: 4
41+
:class-header: bg-light text-center
42+
:class-body: text-center m-0 p-0
43+
:link-type: doc
44+
:link: /examples/save_image
45+
Save the high-res image
4646
^^^
4747
```{glue:figure} save_image
4848
```
49+
````
4950
50-
---
51-
52-
```{link-button} /examples/plot_colorbar
53-
:text: Plot a colorbar
54-
:type: ref
55-
:classes: stretched-link btn-block m-0 p-0
56-
```
51+
````{grid-item-card}
52+
:columns: 4
53+
:class-header: bg-light text-center
54+
:class-body: text-center m-0 p-0
55+
:link-type: doc
56+
:link: /examples/plot_colorbar
57+
Plot a colorbar
5758
^^^
5859
```{glue:figure} with_colorbar
5960
```
61+
````
6062
61-
---
62-
63-
```{link-button} /examples/different_cmaps
64-
:text: Different colormaps
65-
:type: ref
66-
:classes: stretched-link btn-block m-0 p-0
67-
```
63+
````{grid-item-card}
64+
:columns: 4
65+
:class-header: bg-light text-center
66+
:class-body: text-center m-0 p-0
67+
:link-type: doc
68+
:link: /examples/different_cmaps
69+
Different colormaps
6870
^^^
6971
```{glue:figure} different_cmaps
7072
```
71-
7273
````
73-
````{panels}
74-
:column: col-4 m-0
75-
:body: p-0
76-
77-
```{link-button} /examples/different_resolutions
78-
:text: Different data resolutions
79-
:type: ref
80-
:classes: stretched-link btn-block m-0 p-0
81-
```
74+
75+
`````
76+
77+
`````{grid}
78+
79+
````{grid-item-card}
80+
:columns: 4
81+
:class-header: bg-light text-center
82+
:class-body: text-center m-0 p-0
83+
:link-type: doc
84+
:link: /examples/different_resolutions
85+
Different data resolutions
8286
^^^
8387
```{glue:figure} different_resolutions
8488
```
89+
````
8590
86-
---
87-
88-
```{link-button} /examples/cortical_masks
89-
:text: Handling cortical masks
90-
:type: ref
91-
:classes: stretched-link btn-block m-0 p-0
92-
```
91+
````{grid-item-card}
92+
:columns: 4
93+
:class-header: bg-light text-center
94+
:class-body: text-center m-0 p-0
95+
:link-type: doc
96+
:link: /examples/cortical_masks
97+
Handle cortical masks
9398
^^^
9499
```{glue:figure} cortical_masks
95100
```
101+
````
96102
97-
---
98-
99-
```{link-button} /examples/different_surfaces
100-
:text: Alternative surface types
101-
:type: ref
102-
:classes: stretched-link btn-block m-0 p-0
103-
```
103+
````{grid-item-card}
104+
:columns: 4
105+
:class-header: bg-light text-center
106+
:class-body: text-center m-0 p-0
107+
:link-type: doc
108+
:link: /examples/different_surfaces
109+
Alternative surface types
104110
^^^
105111
```{glue:figure} different_surfaces
106112
```
107-
108113
````
114+
115+
`````
116+
109117
gallery_link : |
110118
---
111119
[**<< Go back to the gallery of examples**](/examples/index)

docs/examples/cortical_masks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ kernelspec:
1313
name: python3
1414
---
1515

16-
# Handling cortical masks
16+
# Handle cortical masks
1717

1818
Not every vertex on surface belongs to the cerebral cortex.
1919
There are approximately 8.5% of vertices around the medial wall that are non-cortical.

docs/examples/plot_colorbar.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,27 @@ This example shows how to plot a colorbar besides the brain.
2020
```{glue:} with_colorbar
2121
```
2222

23+
```{margin} Example data
24+
The example data is a NumPy array combining masked data of both hemispheres, based on a face-selectivity map from [Jiahui et al. (2020)](https://doi.org/10.1016/j.neuroimage.2019.116458) [Figure 5](https://www.sciencedirect.com/science/article/pii/S1053811919310493#fig5).
25+
```
2326
```{code-cell}python
2427
import numpy as np
25-
from brainplotlib import brain_plot
28+
from brainplotlib import brain_plot, example_data
2629
import matplotlib.pyplot as plt
2730
28-
rng = np.random.default_rng(0)
29-
v = rng.random((1175, ))
31+
print(example_data.shape, example_data.dtype)
3032
```
3133
```{margin} Get color scale information
3234
The `return_scale` parameter allows returning the color scale information along with the image itself, which can then be used by `plt.colorbar`.
3335
```
3436
```{code-cell}python
35-
img, scale = brain_plot(v, vmax=1, vmin=0, cmap='viridis', return_scale=True)
37+
img, scale = brain_plot(
38+
example_data, vmax=10, vmin=-10, cmap='seismic', return_scale=True)
3639
```
3740
```{code-cell}python
3841
:tags: ["remove-output"]
39-
fig = plt.figure(figsize=(img.shape[1] / 300, img.shape[0] / 300), dpi=300)
42+
fig = plt.figure(
43+
figsize=(img.shape[1] / 300, img.shape[0] / 300), dpi=300)
4044
plt.imshow(img)
4145
plt.axis('off')
4246
cbar = plt.colorbar(scale, shrink=0.8, aspect=30)

docs/examples/save_image.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,20 @@ cv2.imwrite(
7474
np.round(img[:, :, reorder] * 255).astype(np.uint8))
7575
```
7676

77-
````{tabbed} Using matplotlib
77+
`````{tab-set}
78+
````{tab-item} Using matplotlib
7879
```python
7980
import matplotlib.pyplot as plt
80-
fig = plt.figure(figsize=(img.shape[1] / 200, img.shape[0] / 200), dpi=200)
81+
fig = plt.figure(
82+
figsize=(img.shape[1] / 200, img.shape[0] / 200), dpi=200)
8183
ax = fig.add_axes([0, 0, 1, 1])
8284
ax.imshow(img)
8385
ax.axis('off')
8486
plt.savefig('save_image_matplotlib.png')
8587
plt.close()
8688
```
8789
````
88-
````{tabbed} Using Pillow
90+
````{tab-item} Using Pillow
8991
```python
9092
from PIL import Image
9193
im = Image.fromarray(
@@ -96,7 +98,7 @@ im.save('save_image_pillow.png')
9698
The code block above requires that the [Pillow package](https://pillow.readthedocs.io/en/stable/index.html) has been installed.
9799
```
98100
````
99-
````{tabbed} Using OpenCV
101+
````{tab-item} Using OpenCV
100102
```python
101103
import cv2
102104
## The default channel order of OpenCV is BGR rather than RGB.
@@ -109,25 +111,28 @@ cv2.imwrite(
109111
The code block above requires that [OpenCV](https://opencv.org/) and its Python bindings to be installed.
110112
```
111113
````
114+
`````
112115

113116
## Comparison of saved images
114-
````{panels}
115-
:column: col-4
116-
117+
````{grid}
118+
```{grid-item-card}
119+
:class-header: bg-light text-center
117120
Using matplotlib
118121
^^^
119122
![](save_image_matplotlib.png)
120-
---
121-
123+
```
124+
```{grid-item-card}
125+
:class-header: bg-light text-center
122126
Using Pillow
123127
^^^
124128
![](save_image_pillow.png)
125-
---
126-
129+
```
130+
```{grid-item-card}
131+
:class-header: bg-light text-center
127132
Using OpenCV
128133
^^^
129134
![](save_image_opencv.png)
130-
135+
```
131136
````
132137

133138
{{ gallery_link }}

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ It only depends on [`NumPy`](https://numpy.org/) and [`matplotlib`](https://matp
99

1010
`brainplotlib` can be easily installed with pip
1111
```bash
12-
pip install brainplotlib
12+
python -m pip install brainplotlib
1313
```
1414

1515

0 commit comments

Comments
 (0)