Skip to content

Commit

Permalink
Merge pull request #21 from brainglobe/update
Browse files Browse the repository at this point in the history
Bring package up to date
  • Loading branch information
alessandrofelder authored Dec 13, 2023
2 parents 36d42f0 + 214a6a7 commit c1ee9bc
Show file tree
Hide file tree
Showing 26 changed files with 506 additions and 294 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: tests

on:
push:
branches:
- '*'
tags:
- '*'
pull_request:

jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: neuroinformatics-unit/actions/lint@v2

manifest:
name: Check Manifest
runs-on: ubuntu-latest
steps:
- uses: neuroinformatics-unit/actions/check_manifest@v2

test:
needs: [linting, manifest]
name: ${{ matrix.os }} py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Run all supported Python versions on linux
python-version: ["3.9", "3.10", "3.11"]
os: [ubuntu-latest]
# Include one windows and macos run
include:
- os: macos-latest
python-version: "3.10"
- os: windows-latest
python-version: "3.10"

steps:
# Run tests
- uses: neuroinformatics-unit/actions/test@v2
with:
python-version: ${{ matrix.python-version }}

build_sdist_wheels:
name: Build source distribution
needs: [test]
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- uses: neuroinformatics-unit/actions/build_sdist_wheels@v2


upload_all:
name: Publish build distributions
needs: [build_sdist_wheels]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.TWINE_API_KEY }}
97 changes: 17 additions & 80 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
.chache
workspace.py
*.mp4
.vscode
.vscode/*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand All @@ -14,6 +8,7 @@ __pycache__/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -25,12 +20,9 @@ lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -45,17 +37,13 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
*,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
Expand All @@ -64,83 +52,32 @@ cover/
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
# Flask instance folder
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# MkDocs documentation
/site/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
# Pycharm and VSCode
.idea/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site
.vscode/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
# IPython Notebook
.ipynb_checkpoints

# pytype static type analyzer
.pytype/
# pyenv
.python-version

# Cython debug symbols
cython_debug/
# OS
.DS_Store

.idea/*
# written by setuptools_scm
**/_version.py
54 changes: 38 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@


# Configuring https://pre-commit.ci/
ci:
autoupdate_schedule: monthly

repos:
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
pass_filenames: true
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
pass_filenames: true
# this seems to need to be here in addition to setup.cfg
exclude: __init__.py, workspace.py
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.0
hooks:
- id: mypy
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-toml
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=lf]
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.272
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy
additional_dependencies:
- types-setuptools
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
- id: check-manifest
args: [--no-build-isolation]
additional_dependencies: [setuptools-scm]
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include LICENSE
include README.md
exclude .pre-commit-config.yaml

recursive-exclude * __pycache__
recursive-exclude * *.py[co]
recursive-exclude docs *
recursive-exclude tests *
recursive-exclude examples *
recursive-exclude images *
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BG Heatmaps
Rendering heatmaps with brainrender.
Rendering anatomical heatmaps with brainrender and matplotlib.



Expand All @@ -20,7 +20,7 @@ Rendering heatmaps with brainrender.
The starting point for a heatmap visualization is a `dict` assigning scalar values to a set of brain regions (identified by their acronym).
For example:

```python
```python
regions = dict( # scalar values for each region
TH=1,
RSP=0.2,
Expand Down Expand Up @@ -63,7 +63,7 @@ planner = bgh.plan(
8000,
5000,
5000,
),
),
orientation="frontal", # orientation, or 'sagittal', or 'horizontal' or a tuple (x,y,z)
thickness=2000, # thickness of the slices used for rendering (in microns)
)
Expand Down Expand Up @@ -109,7 +109,7 @@ bgh.heatmap(
8000,
5000,
5000,
),
),
orientation="horizontal", # 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
title="horizontal view",
vmin=-5,
Expand All @@ -136,14 +136,14 @@ coordinates = bgh.get_plane_coordinates(
8000,
5000,
5000,
),
),
orientation="frontal", # 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
)
```

## Using `bgheatmap` with other atlases.

`bgheatmap` uses `brainrender` which, in turn, uses brainglobe's `Atlas API` under the hood. That means that all of `bgheatmap`'s functionality is compatible with any of the atlases supported by the atlas API.
`bgheatmap` uses `brainrender` which, in turn, uses brainglobe's `Atlas API` under the hood. That means that all of `bgheatmap`'s functionality is compatible with any of the atlases supported by the atlas API.
`bgh.heatmap`, `bgh.planner` and `bgh.get_plane_coordinates` all accept a `atlas_name` argument, pass the name of the atlas name you'd like to use!
For more information see the API's [https://docs.brainglobe.info/bg-atlasapi/introduction](documentation).

Expand Down
3 changes: 0 additions & 3 deletions bgheatmaps/__init__.py

This file was deleted.

11 changes: 11 additions & 0 deletions brainglobe_heatmap/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("brainglobe-heatmap")
except PackageNotFoundError:
# package is not installed
pass

from brainglobe_heatmap.heatmaps import heatmap
from brainglobe_heatmap.planner import plan
from brainglobe_heatmap.slicer import get_structures_slice_coords
Loading

0 comments on commit c1ee9bc

Please sign in to comment.