11This is a Python package that plots data on cortical surface.
22
3+ ![ brain image] ( https://github.com/feilong/brainplotlib/raw/main/images/random_data_with_colorbar.png )
4+
35## Installation
46The package can be installed with pip:
57``` bash
@@ -19,16 +21,18 @@ from brainplotlib import brain_plot
1921rng = np.random.default_rng(0 )
2022v = rng.random((1175 , ))
2123
22- img = brain_plot(v, vmax = 1 , vmin = 0 , cmap = ' viridis' )
24+ img, scale = brain_plot(v, vmax = 1 , vmin = 0 , cmap = ' viridis' , return_scale = True )
2325```
2426
2527The rendered image is a NumPy array.
2628It can be rendered using ` matplotlib ` :
2729``` Python
2830import matplotlib.pyplot as plt
29- fig = plt.figure(figsize = (img.shape[1 ] / 100 , img.shape[0 ] / 100 ), dpi = 100 )
31+ fig = plt.figure(figsize = (img.shape[1 ] / 200 , img.shape[0 ] / 200 ), dpi = 200 )
3032plt.imshow(img)
3133plt.axis(' off' )
34+ cbar = plt.colorbar(scale, shrink = 0.8 , aspect = 30 )
35+ plt.savefig(' random_data_with_colorbar.png' , bbox_inches = ' tight' )
3236plt.show()
3337```
3438
@@ -39,5 +43,3 @@ cv2.imwrite(
3943 ' random_data.png' ,
4044 np.round(img[:, :, [2 , 1 , 0 ]] * 255 ).astype(np.uint8))
4145```
42-
43- ![ brain image] ( https://github.com/feilong/brainplotlib/raw/main/images/random_data.png )
0 commit comments