Skip to content

Commit

Permalink
Merge branch 'main' into adapt-CI-mac
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrofelder authored Apr 29, 2024
2 parents 6818229 + d46749a commit 4822b34
Show file tree
Hide file tree
Showing 41 changed files with 1,285 additions and 1,538 deletions.
32 changes: 19 additions & 13 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@ name: tests

on:
push:
branches: [ main ]
branches:
- "main"
tags:
- '*'
- 'v*'
pull_request:
branches: [ '*' ]
workflow_dispatch:

jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: neuroinformatics-unit/actions/lint@v1
- 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:
Expand Down Expand Up @@ -42,10 +50,13 @@ jobs:
run: brew install hdf5
# Setup pyqt libraries
- uses: tlambert03/setup-qt-libs@v1
# Helps set up VTK with a headless display
- uses: pyvista/setup-headless-display-action@v2
# Run tests
- uses: neuroinformatics-unit/actions/test@v1
- uses: neuroinformatics-unit/actions/test@v2
with:
python-version: ${{ matrix.python-version }}
secret-codecov-token: ${{ secrets.CODECOV_TOKEN }}
use-xvfb: true

build_sdist_wheels:
Expand All @@ -54,19 +65,14 @@ jobs:
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- uses: neuroinformatics-unit/actions/build_sdist_wheels@v1
- 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/[email protected]
- uses: neuroinformatics-unit/actions/upload_pypi@v2
with:
user: __token__
password: ${{ secrets.TWINE_API_KEY }}
secret-pypi-key: ${{ secrets.TWINE_API_KEY }}
72 changes: 16 additions & 56 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
# Custom config files
*.conf.custom

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Cython
*.c
*.cpp

# C extensions
*.so

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

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -50,9 +42,8 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
*.cover
*,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
Expand All @@ -61,63 +52,32 @@ coverage.xml
# Django stuff:
*.log
local_settings.py
db.sqlite3

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

# Scrapy stuff:
.scrapy

# Sphinx documentation
doc/build/
docs/_build/

# pydocmd
_build/
mkdocs.yml
# MkDocs documentation
/site/

# PyBuilder
target/

# Jupyter Notebook
# Pycharm and VSCode
.idea/
venv/
.vscode/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# vscode
.vscode

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

.idea/
# OS
.DS_Store

*.~lock.*
*.zip
# written by setuptools_scm
**/_version.py
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
rev: v0.3.5
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.10.1
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
rev: v1.9.0
hooks:
- id: mypy
additional_dependencies:
Expand Down
60 changes: 60 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: brainglobe-segmentation
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Adam
family-names: Tyson
email: [email protected]
affiliation: 'Sainsbury Wellcome Centre, University College London'
- given-names: Horst
family-names: Obenhaus
- given-names: BrainGlobe
family-names: Developers
email: [email protected]
repository-code: 'https://github.com/brainglobe/brainglobe-segmentation'
url: 'https://brainglobe.info'
abstract: >-
Segmentation of anatomical structures in a common
coordinate space.
license: BSD-3-Clause
date-released: '2024-01-16'
year: 2024
preferred-citation:
type: article
authors:
- given-names: Adam
family-names: Tyson
affiliation: 'Sainsbury Wellcome Centre, University College London'
- given-names: Mateo
family-names: Velez-Fort
- given-names: Charly V.
family-names: Rousseau
- given-names: Lee
family-names: Cossell
- given-names: Chryssanthi
family-names: Tsitoura
- given-names: Stephen C.
family-names: Lenzi
- given-names: Horst A.
family-names: Obenhaus
- given-names: Federico
family-names: Claudi
- given-names: Tiago
family-names: Branco
- given-names: Troy W.
family-names: Margrie
doi: "10.1038/s41598-021-04676-9"
url: "https://doi.org/10.1038/s41598-021-04676-9"
journal: "Scientific Reports"
month: 1
year: 2022
title: "Accurate determination of marker location within whole-brain microscopy images"
issue: 1
volume: 12
citation-sentence: "This project makes use of the brainglobe-segmentation plugin for segmentation of objects and regions of the brain."
12 changes: 12 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
include CITATION.cff
include LICENSE
include README.md

exclude .pre-commit-config.yaml
exclude codecov.yml

include .napari/config.yml

graft brainglobe_segmentation

prune tests
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@
[![PyPI](https://img.shields.io/pypi/v/brainglobe-segmentation.svg)](https://pypi.org/project/brainglobe-segmentation)
[![Wheel](https://img.shields.io/pypi/wheel/brainglobe-segmentation.svg)](https://pypi.org/project/brainglobe-segmentation)
[![Development Status](https://img.shields.io/pypi/status/brainglobe-segmentation.svg)](https://github.com/brainglobe/brainglobe-segmentation)
[![Tests](https://img.shields.io/github/workflow/status/brainglobe/brainglobe-segmentation/tests)](
https://github.com/brainglobe/brainglobe-segmentation/actions)
[![codecov](https://codecov.io/gh/brainglobe/brainglobe-segmentation/branch/master/graph/badge.svg?token=WP9KTPZE5R)](https://codecov.io/gh/brainglobe/brainglobe-segmentation)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
[![Tests](https://img.shields.io/github/actions/workflow/status/brainglobe/brainglobe-segmentation/test_and_deploy.yml?branch=main)](https://github.com/brainglobe/brainglobe-segmentation/actions)
[![codecov](https://codecov.io/gh/brainglobe/brainglobe-segmentation/graph/badge.svg?token=WP9KTPZE5R)](https://codecov.io/gh/brainglobe/brainglobe-segmentation)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
[![Twitter](https://img.shields.io/twitter/follow/brain_globe?style=social)](https://twitter.com/brain_globe)

# brainglobe-segmentation

Segmentation of 1/2/3D brain structures in a common anatomical space

`brainglobe-segmentation` is a companion to [`brainreg`](https://github.com/brainglobe/brainreg) allowing manual segmentation of regions/objects within the brain (e.g. injection sites, probes etc.) allowing for automated analysis of brain region distribution, and visualisation (e.g. in [brainrender](https://github.com/brainglobe/brainrender)).
`brainglobe-segmentation` is the successor to [`brainreg-segment`](https://github.com/brainglobe/brainreg-segmentation).

`brainglobe-segmentation` and `brainreg` were developed by [Adam Tyson](https://github.com/adamltyson) and [Charly Rousseau](https://github.com/crousseau) in the [Margrie Lab](https://www.sainsburywellcome.org/web/groups/margrie-lab), based on [aMAP](https://doi.org/10.1038/ncomms11879) by [Christian Niedworok](https://github.com/cniedwor). The work was generously supported by the [Sainsbury Wellcome Centre](https://www.sainsburywellcome.org/web/).
Segmentation of anatomical structures in a common coordinate space

## Installation
**PyPI**
```
pip install brainglobe-segmentation
```

brainglobe-segmentation comes bundled with [`brainreg`](https://github.com/brainglobe/brainreg), so see the [brainreg installation instructions](https://brainglobe.info/documentation/brainreg/index.html).

brainglobe-segmentation can be installed on it's own (`pip install brainglobe-segmentation`), but you will need to register your data with brainreg first.
**conda**
```
conda install -c conda-forge brainglobe-segmentation
```

N.B. Your data will need to be registered to an anatomical atlas first.
## Usage

See [user guide](https://brainglobe.info/documentation/brainglobe-segmentation/index.html).
Expand All @@ -30,7 +31,7 @@ If you have any questions, head over to the [image.sc forum](https://forum.image

## Contributing

Contributions are very welcome. Please see the [developers guide](https://brainglobe.info/developers/index.html).
Contributions are very welcome. Please see the [developers guide](https://brainglobe.info/community/developers/index.html).

### Citing brainglobe-segmentation

Expand Down
18 changes: 2 additions & 16 deletions brainglobe_segmentation/atlas/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from bg_atlasapi.list_atlases import descriptors, utils


def lateralise_atlas_image(
masked_atlas_annotations,
hemispheres,
Expand All @@ -24,18 +21,6 @@ def lateralise_atlas_image(
return annotation_left, annotation_right


def get_available_atlases():
"""
Get the available brainglobe atlases
:return: Dict of available atlases (["name":version])
"""
available_atlases = utils.conf_from_url(
descriptors.remote_url_base.format("last_versions.conf")
)
available_atlases = dict(available_atlases["atlases"])
return available_atlases


def structure_from_viewer(coordinates, atlas_layer, atlas):
"""
Get brain region info from mouse position in napari viewer.
Expand All @@ -51,7 +36,8 @@ def structure_from_viewer(coordinates, atlas_layer, atlas):
Layer, which contains the annotation / region
information for every structure in the (registered)
atlas
atlas : Brainglobe atlas (bg_atlasapi.bg_atlas.BrainGlobeAtlas)
atlas : Brainglobe atlas
(brainglobe_atlasapi.bg_atlas.BrainGlobeAtlas)
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion brainglobe_segmentation/image/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def create_KDTree_from_image(image, value=0):
"""
Create a KDTree of points equalling a given value
Create a KDTree of points equaling a given value
:param image: Image to be converted to points
:param value: Value of image to be used
:return: scipy.spatial.cKDTree object
Expand Down
6 changes: 0 additions & 6 deletions brainglobe_segmentation/layout/gui_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,3 @@
IMAGE_FILE_EXT = ".tiff"
BOUNDARIES_STRING = "Boundaries"
HEMISPHERES_STRING = "Hemispheres"

# ORIENTATIONS = [
# "asl",
# "lsa",
# "sla",
# ] # When rolling through orientations of the brain, adhere to this order
Loading

0 comments on commit 4822b34

Please sign in to comment.