A lightweight package to plot brain surfaces with Python.
Project description
This simple package contains a brain_plot
function that plots data on cortical surface.
It assumes that:
- The data is in fsaverage space with icoorder3 resolution (642 vertices per hemisphere).
- The non-cortical vertices has been masked out (588 and 587 remaining vertices for the left and right hemisphere, respectively).
import numpy as np
from brainplotlib import brain_plot
# Generate some random data
rng = np.random.default_rng(0)
v = rng.random((1175, ))
img = brain_plot(v, vmax=1, vmin=0, cmap='viridis')
The rendered image is a NumPy array.
It can be rendered using matplotlib
:
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(img.shape[1] / 100, img.shape[0] / 100), dpi=100)
plt.imshow(img)
plt.axis('off')
plt.show()
Alternatively, the high-resolution image can be saved directly using cv2
.
import cv2
cv2.imwrite(
'random_data.png',
np.round(img[:, :, [2, 1, 0]] * 255).astype(np.uint8))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
brainplotlib-0.1.1.tar.gz
(115.2 kB
view hashes)
Built Distribution
brainplotlib-0.1.1-py3-none-any.whl
(120.4 kB
view hashes)
Close
Hashes for brainplotlib-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40e165722fd845517acdcdae518d1d2b3eceae0f487595117c2556750b23ff8a |
|
MD5 | c6ad3dde4c122d1e179b02eaf39fb158 |
|
BLAKE2b-256 | 6885c7b6271cbb188f2b215660d8f417ce88d87b1896acd40f9f42205dd0d17a |