11[ ![ PyPI] ( https://img.shields.io/pypi/v/brainplotlib )] ( https://pypi.org/project/brainplotlib/ )
2- [ ![ PyPI - Downloads] ( https://img.shields.io/pypi/dm/ brainplotlib )] ( https://pypistats.org/packages /brainplotlib )
2+ [ ![ Downloads] ( https://static.pepy.tech/badge/ brainplotlib )] ( https://pepy.tech/project /brainplotlib )
33![ PyPI - Python Version] ( https://img.shields.io/pypi/pyversions/brainplotlib )
44[ ![ DOI] ( https://zenodo.org/badge/DOI/10.5281/zenodo.5979819.svg )] ( https://doi.org/10.5281/zenodo.5979819 )
55
66` brainplotlib ` is a Python package that plots data on cortical surface.
77It's designed to have minimal requirements --- only ` NumPy ` and ` matplotlib ` .
88
9- ![ brain image] ( https://github.com/feilong/brainplotlib/raw/main/images/random_data_with_colorbar .png )
9+ ![ brain image] ( https://github.com/feilong/brainplotlib/raw/main/images/example_data_with_colorbar .png )
1010
1111## Installation
1212The package can be installed with pip:
@@ -20,16 +20,14 @@ pip install brainplotlib
2020
2121``` Python
2222import numpy as np
23- from brainplotlib import brain_plot
23+ from brainplotlib import brain_plot, example_data
2424
25- # # Generate some random data
26- # In this case it's icoorder3 resolution (642 vertices per hemisphere), and
27- # the non-cortical vertices have been masked out (588 and 587 remaining
25+ # The example_data is icoorder5 resolution (10242 vertices per hemisphere),
26+ # and the non-cortical vertices have been masked out (9372 and 9370 remaining
2827# vertices for the left and right hemisphere, respectively).
29- rng = np.random.default_rng(0 )
30- v = rng.random((1175 , ))
3128
32- img, scale = brain_plot(v, vmax = 1 , vmin = 0 , cmap = ' viridis' , return_scale = True )
29+ img, scale = brain_plot(
30+ example_data, vmax = 10 , vmin = - 10 , cmap = ' seismic' , return_scale = True )
3331```
3432
3533The rendered image is a NumPy array.
@@ -40,15 +38,15 @@ fig = plt.figure(figsize=(img.shape[1] / 200, img.shape[0] / 200), dpi=200)
4038plt.imshow(img)
4139plt.axis(' off' )
4240cbar = plt.colorbar(scale, shrink = 0.8 , aspect = 30 )
43- plt.savefig(' random_data_with_colorbar .png' , bbox_inches = ' tight' )
41+ plt.savefig(' example_data_with_colorbar .png' , bbox_inches = ' tight' )
4442plt.show()
4543```
4644
4745Alternatively, the high-resolution image can be saved directly using ` OpenCV ` .
4846``` Python
4947import cv2
5048cv2.imwrite(
51- ' random_data .png' ,
49+ ' example_data .png' ,
5250 np.round(img[:, :, [2 , 1 , 0 ]] * 255 ).astype(np.uint8))
5351```
5452
0 commit comments