brainplotlib is a Python package that plots data on cortical surface.
It's designed to have minimal requirements --- only NumPy and matplotlib.
Installation
The package can be installed with pip:
pip install brainplotlib
Example usage
See the examples gallery for all code examples with detailed explanations.
import numpy as np
from brainplotlib import brain_plot, example_data
# The example_data is icoorder5 resolution (10242 vertices per hemisphere),
# and the non-cortical vertices have been masked out (9372 and 9370 remaining
# vertices for the left and right hemisphere, respectively).
img, scale = brain_plot(
example_data, vmax=10, vmin=-10, cmap='seismic', return_scale=True)
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] / 200, img.shape[0] / 200), dpi=200)
plt.imshow(img)
plt.axis('off')
cbar = plt.colorbar(scale, shrink=0.8, aspect=30)
plt.savefig('example_data_with_colorbar.png', bbox_inches='tight')
plt.show()
Alternatively, the high-resolution image can be saved directly using OpenCV.
import cv2
cv2.imwrite(
'example_data.png',
np.round(img[:, :, [2, 1, 0]] * 255).astype(np.uint8))
Citation
If you use this software in your publications, please cite it
@software{brainplotlib,
author = {Ma Feilong and Guo Jiahui and M. Ida Gobbini and James V. Haxby},
title = {brainplotlib: plotting brain data on cortical surface},
month = feb,
year = 2022,
publisher = {Zenodo},
doi = {10.5281/zenodo.5979819},
url = {https://doi.org/10.5281/zenodo.5979819}
}
Metadata
Release files for brainplotlib 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| brainplotlib-1.0.0.tar.gz | 8.3 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| brainplotlib-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.7 MB
Release files / brainplotlib-1.0.0.tar.gz
| Download URL | brainplotlib-1.0.0.tar.gz |
|---|---|
| Size | 8.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8da932d5289541fa7ee4e686d98339b6a68a88a85421b65d5c98c7134722b88b
|
|
BLAKE2b-256 checksum How to use checksums |
ab137b51a7ae9c122c4d970dedfdd3efed87241434fd89855999c4358ad7fed6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.9.2
|
Release files / brainplotlib-1.0.0-py3-none-any.whl
| Download URL | brainplotlib-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e70a80799b87e057f5184a54f40323cc6827ecdc0ee0e137ee60ee95a8a30317
|
|
BLAKE2b-256 checksum How to use checksums |
29315268f5132eaeb9a02e0d120dddfeeab3498249c21bc6217c14f3542c41d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.9.2
|