Skip to content

Commit d40c47e

Browse files
committed
Add README.md.
1 parent a16d59a commit d40c47e

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
This simple package contains a `brain_plot` function that plots data on cortical surface.
2+
It assumes that:
3+
- The data is in fsaverage space with icoorder3 resolution (642 vertices per hemisphere).
4+
- The non-cortical vertices has been masked out (588 and 587 remaining vertices for the left and right hemisphere, respectively).
5+
6+
```Python
7+
import numpy as np
8+
from brainplotlib import brain_plot
9+
10+
# Generate some random data
11+
rng = np.random.default_rng(0)
12+
v = rng.random((1175, ))
13+
14+
img = brain_plot(v, vmax=1, vmin=0, cmap='viridis')
15+
```
16+
17+
The rendered image is a NumPy array.
18+
It can be rendered using `matplotlib`:
19+
```Python
20+
import matplotlib.pyplot as plt
21+
fig = plt.figure(figsize=(img.shape[1] / 100, img.shape[0] / 100), dpi=100)
22+
plt.imshow(img)
23+
plt.axis('off')
24+
plt.show()
25+
```
26+
27+
Alternatively, the high-resolution image can be saved directly using `cv2`.
28+
```Python
29+
import cv2
30+
cv2.imwrite(
31+
'random_data.png',
32+
np.round(img[:, :, [2, 1, 0]] * 255).astype(np.uint8))
33+
```
34+
35+
![brain image](https://github.com/feilong/brainplotlib/raw/main/images/random_data.png)

images/random_data.png

318 KB
Loading

0 commit comments

Comments
 (0)