Skip to content

Commit

Permalink
Update README using example data.
Browse files Browse the repository at this point in the history
  • Loading branch information
feilong committed Jan 6, 2023
1 parent 1829efa commit 3d3ef21
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2022, The brainplotlib developers
Copyright (c) 2022-2023, The brainplotlib developers

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![PyPI](https://img.shields.io/pypi/v/brainplotlib)](https://pypi.org/project/brainplotlib/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/brainplotlib)](https://pypistats.org/packages/brainplotlib)
[![Downloads](https://static.pepy.tech/badge/brainplotlib)](https://pepy.tech/project/brainplotlib)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/brainplotlib)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5979819.svg)](https://doi.org/10.5281/zenodo.5979819)

`brainplotlib` is a Python package that plots data on cortical surface.
It's designed to have minimal requirements --- only `NumPy` and `matplotlib`.

![brain image](https://github.com/feilong/brainplotlib/raw/main/images/random_data_with_colorbar.png)
![brain image](https://github.com/feilong/brainplotlib/raw/main/images/example_data_with_colorbar.png)

## Installation
The package can be installed with pip:
Expand All @@ -20,16 +20,14 @@ pip install brainplotlib

```Python
import numpy as np
from brainplotlib import brain_plot
from brainplotlib import brain_plot, example_data

## 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
# 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).
rng = np.random.default_rng(0)
v = rng.random((1175, ))

img, scale = brain_plot(v, vmax=1, vmin=0, cmap='viridis', return_scale=True)
img, scale = brain_plot(
example_data, vmax=10, vmin=-10, cmap='seismic', return_scale=True)
```

The rendered image is a NumPy array.
Expand All @@ -40,15 +38,15 @@ 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('random_data_with_colorbar.png', bbox_inches='tight')
plt.savefig('example_data_with_colorbar.png', bbox_inches='tight')
plt.show()
```

Alternatively, the high-resolution image can be saved directly using `OpenCV`.
```Python
import cv2
cv2.imwrite(
'random_data.png',
'example_data.png',
np.round(img[:, :, [2, 1, 0]] * 255).astype(np.uint8))
```

Expand Down
Binary file added images/example_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example_data_with_colorbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = brainplotlib
version = 0.5.0
version = 1.0.0
author = Ma Feilong
author_email = [email protected]
description = A lightweight package to plot brain surfaces with Python.
Expand Down

0 comments on commit 3d3ef21

Please sign in to comment.