A lightweight package to plot brain surfaces with Python.
Project description
This is a Python package that plots data on cortical surface.
Installation
The package can be installed with pip:
pip install brainplotlib
Example usage
import numpy as np
from brainplotlib import brain_plot
## Generate some random data
# In this case it's icoorder3 resolution (642 vertices per hemisphere), and
# the non-cortical vertices have been masked out (588 and 587 remaining
# vertices for the left and right hemisphere, respectively).
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.2.0.tar.gz
(3.5 MB
view hashes)
Built Distribution
Close
Hashes for brainplotlib-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bffc15c979eac9d081bb5c51f24bcb85c73cc066ec9853983ba5eef812443e85 |
|
MD5 | 0d31187b3e68e5c26bfcf0e540a85890 |
|
BLAKE2b-256 | 70c51d3e1e7c02ff8278a5fd4f8f5cd338a31ff70c2fab2703e3e55cacbf0073 |