Skip to content

Commit

Permalink
Merge with atlasgen (#199)
Browse files Browse the repository at this point in the history
* Initial commit

* Update README.md

* First commit

* gitignore

* Almost at complete atlas autogeneration

* Finalized script for automatic atlas generation

* Added template script for atlas generation

* Template description

* First working version of script for auto deployment

* Fixed metadata link

* Trying to fix windows permission error when deleting folders

* add 50um to allen mouse

* v1.2 for allen mouse

* blacked

* Update requirements

* vtkplotter -> vedo

* Format with black

* Update kim mouse atlas generation

* Improve downsampling

* revert roations

* add kim to main script

* rotate annotation volume for meshes

* add osten mouse atlas

* Added function for creating intermediate hierarchy structures masks

* Fix extract_largest_region and compare_mesh_volume

* reformat with black

* save additional metadata

* consistent syntax for empty dict

* Update docstring

* Add atlas packager metadata

* python 3.8 compatibility

* Add mouse spinal cord atlas

* add WHS SD Rat atlas

* add xmltodict to requirements.txt

* remove structures that are missing from annotation volume

* remove structures that are missing from annotation volume

* Fixed vedo Slicer import issue

* Update mesh_utils.py

* Create azba_zfish.py

* Standardise temporary output directory

* add [allenmouse] extra dependency (#17)

* Allow multiple downloads at once, updated citation

* Mesh cleaning improvements (#15)

* gitignore: added vscode

* gitignore: added vscode

* added rich fancy traceback for easier debugging

* replaced mesh cleaning with decimation

* pre-commit cleanup

* added TEST mode to atlas creation

* added smoothing options to all atlas gen scripts

* removed ratlas.py since outdated and theres a better atlas

* atlas gen update

* added smoothing and decimation to adult zebrafish atlas

Co-authored-by: Luigi Petrucco <[email protected]>

* Update azba_zfish.py

Changing the reference file to be af and the additional references to be topro

* some fixes for mpin atlas

* Fix tiny typo (#22)

* Update README.md

* Add lsfm atlas script (#18)

* Update lsfm mouse atlas script

* 2nd update LSFM mouse atlas script

Co-authored-by: Johanna <[email protected]>
Co-authored-by: Johanna Perens <[email protected]>

* Update requirements.txt

* Add ADMBA 3D developing mouse atlases (#25)

* Add ADMBA 3D developing mouse atlases

Extend the `mouse_e15_5` script by @pr4deepr to build all the atlases in the 3D reconstructed version of the Allen Developing Mouse Brain Atlas series. This build script is essentially the same except for the addition of a data class to configure the atlas parameters, which is implemented for each atlas.

* Fix atlas orientation to LSA

Change the input orientation to LSA to fit the NumPy convention used in BrainGlobe. Add docstrings describing the orientation and resolution assumptions in the configuration data class.

* Update package authors

* Add script for the Princeton mouse brain atlas. (#27)

* Added atlas generation script for the Princeton mouse brain atlas. Modified mesh_utils.py for fix.

* Modified atlas minor version, changed atlas orientation, and removed unnecessary html fetch of region hierarchy.

* Finalised atlas minor version.

Co-authored-by: Sam <[email protected]>

* KimLabDevCCFv001 (neuroinformatics team form) (#31)

* Create KimLabDevCCFv001.py

* Update KimLabDevCCFv001.py

* Update and rename KimLabDevCCFv001.py to KimLabDevCCF.py

* Update KimLabDevCCF.py

* first commit

* updated up to mesh creation, working through VTK type error

* kimlabdevccf working version 1 reference only

* rename atlasgen file

* start adding additional references

* add filenames for additional references

* fix unfinished handling of multi-templates

* update pre-commit black version to fix error with _unicode fun import from click

* tidy and install pre-commit

* fix change of plotter I erronoeusly made when using older python version

* testing kim atlsa with additional references

* Update requirements.txt

* add loguru requirement (at least windows 10)

* fix VTK type error

* remove path

* remove test code

* update to new download dir

* used to run atlas

* update atlas code for general use

* remove standard tempalte from additional references

* further clean up

* edit to run in single script

* fix False flag used to not run meshes

* get working on UNIX

* use PARALLEL and update atlas name

* update template key STP to stp

Co-authored-by: NovaFae <[email protected]>
Co-authored-by: Adam Tyson <[email protected]>

* Add testing config (#35)

* Add testing config

* Specify branchs for workflow trigger

* Bump pre-commit versions

* Fix cov flag

* Run black on code base

* Clean up requirements

* Move requirements to setup.py

* Fix setup.py black

* Replace brainglobe with NI actions (#37)

* Use pyproject.toml

* Update supported Python metadata

* Clean manifest check

* Remove cibuildwheel config

* Catch warnings during tests (#39)

* Add standard pre-commit config (#40)

* Add standard pre-commit config

* Add automated pre-commit fixes

* Ignore line too long

* Fix branches that CI is run on (#42)

* Update link (#48)

* [pre-commit.ci] pre-commit autoupdate (#49)

updates:
- [github.com/charliermarsh/ruff-pre-commit: v0.0.240 → v0.0.272](astral-sh/ruff-pre-commit@v0.0.240...v0.0.272)
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#50)

updates:
- [github.com/charliermarsh/ruff-pre-commit: v0.0.272 → v0.0.275](astral-sh/ruff-pre-commit@v0.0.272...v0.0.275)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#52)

updates:
- https:/charliermarsh/ruff-pre-commithttps:/astral-sh/ruff-pre-commit
- [github.com/astral-sh/ruff-pre-commit: v0.0.275 → v0.0.276](astral-sh/ruff-pre-commit@v0.0.275...v0.0.276)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#53)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.276 → v0.0.277](astral-sh/ruff-pre-commit@v0.0.276...v0.0.277)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#54)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.277 → v0.0.278](astral-sh/ruff-pre-commit@v0.0.277...v0.0.278)
- [github.com/psf/black: 23.3.0 → 23.7.0](psf/black@23.3.0...23.7.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#55)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.278 → v0.0.280](astral-sh/ruff-pre-commit@v0.0.278...v0.0.280)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#57)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.280 → v0.0.281](astral-sh/ruff-pre-commit@v0.0.280...v0.0.281)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#59)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.281 → v0.0.282](astral-sh/ruff-pre-commit@v0.0.281...v0.0.282)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Update to newer vedo API (#58)

* [pre-commit.ci] pre-commit autoupdate (#64)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.282 → v0.0.284](astral-sh/ruff-pre-commit@v0.0.282...v0.0.284)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* scale mesh points before mapping to new anatomical space (#62)

Co-authored-by: Will Graham <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#66)

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.284 → v0.0.285](astral-sh/ruff-pre-commit@v0.0.284...v0.0.285)

* update type assertion

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Adam Tyson <[email protected]>

* [pre-commit.ci] pre-commit autoupdate (#67)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.285 → v0.0.286](astral-sh/ruff-pre-commit@v0.0.285...v0.0.286)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Set pre-commit autoupdate frequency to monthly (#68)

* [pre-commit.ci] pre-commit autoupdate (#70)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.286 → v0.0.287](astral-sh/ruff-pre-commit@v0.0.286...v0.0.287)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#83)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.287 → v0.0.292](astral-sh/ruff-pre-commit@v0.0.287...v0.0.292)
- [github.com/psf/black: 23.7.0 → 23.9.1](psf/black@23.7.0...23.9.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#95)

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](pre-commit/pre-commit-hooks@v4.4.0...v4.5.0)
- [github.com/astral-sh/ruff-pre-commit: v0.0.292 → v0.1.4](astral-sh/ruff-pre-commit@v0.0.292...v0.1.4)
- [github.com/psf/black: 23.9.1 → 23.10.1](psf/black@23.9.1...23.10.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#107)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.4 → v0.1.6](astral-sh/ruff-pre-commit@v0.1.4...v0.1.6)
- [github.com/psf/black: 23.10.1 → 23.11.0](psf/black@23.10.1...23.11.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#109)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.6 → v0.1.9](astral-sh/ruff-pre-commit@v0.1.6...v0.1.9)
- [github.com/psf/black: 23.11.0 → 23.12.1](psf/black@23.11.0...23.12.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* draft validation functions (#90)

* draft validation functions

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* run on all atlases, don't crash on assertion error

* fixing atlas path

* Clearer output printing

* tidy up validation script, remove weird test_git

* add dev install, make test structure, initial tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add tests and return for _assert_close()

* add test for validate mesh matches annotation

* fix linting

* update version for actions

* drop py3.8 in tox, run pytest in tox

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix copy-paste error in pytest command

* drop py3.8 from gh action workflow file too

* Adding docstrings to validation script

* Making path tests stricter, breaking up long strings, adding diff_tolerance argument to _assert_close function

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* restructuring validate_mesh_matches_image_extents function, adding comments

* testing expected files and  meshes directory separately

* looping through validation functions and parameters to catch individual errors

* removing hard coded path, generalising to all atlases

* adding successful_validations list

* tidying up duplications

* fix recursive bug

* addressing Niko's final comments, cleaning code

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alessandro Felder <[email protected]>
Co-authored-by: alessandrofelder <[email protected]>

* Structure validation (#110)

* draft validation functions

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* run on all atlases, don't crash on assertion error

* fixing atlas path

* Clearer output printing

* tidy up validation script, remove weird test_git

* add dev install, make test structure, initial tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add tests and return for _assert_close()

* add test for validate mesh matches annotation

* fix linting

* update version for actions

* drop py3.8 in tox, run pytest in tox

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix copy-paste error in pytest command

* drop py3.8 from gh action workflow file too

* Adding docstrings to validation script

* wip: draft structure validation function

* Making path tests stricter, breaking up long strings, adding diff_tolerance argument to _assert_close function

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* restructuring validate_mesh_matches_image_extents function, adding comments

* testing expected files and  meshes directory separately

* looping through validation functions and parameters to catch individual errors

* removing hard coded path, generalising to all atlases

* adding successful_validations list

* tidying up duplications

* fix recursive bug

* checkout finished validate_atlases.py from validation branch

* adding validate_mesh_structure_pairs function

* Update bg_atlasgen/validate_atlases.py

Co-authored-by: Alessandro Felder <[email protected]>

* adding assertion to validate_mesh_structure_pairs function

* checking IDs via bg_atlasapi, checking if IDs have mesh files and accesible through the atlas

* Update bg_atlasgen/validate_atlases.py

Co-authored-by: Alessandro Felder <[email protected]>

* passing atlas_name to validate_mesh_structure_pairs function

* addressing Niko's final comments, cleaning code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alessandro Felder <[email protected]>
Co-authored-by: alessandrofelder <[email protected]>

* simplify validation function (#113)

* simplify validation function

- all validation functions just take an atlas object
- means we don't need a parameters list
- also simplify output list to be dicts of lists mapping the atlas name to values

- another advantage of this is that it simplifies mocking of atlas functions in the tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix bug found in code review

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#117)

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.9 → v0.2.0](astral-sh/ruff-pre-commit@v0.1.9...v0.2.0)
- [github.com/psf/black: 23.12.1 → 24.1.1](psf/black@23.12.1...24.1.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Add manifest to ci (#118)

* Add manifest to CI

* Standardise tox.ini into pyproject

* printing data frames with validation function information (#115)

* first test functions for validate_mesh_structure_pairs

* storing atlases and successful/failed validation functions in a data frame

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* restoring test_validation.py to the original merged version. Chages are implemented on another branch

* validate_atlases.py: going back to the version on main, appending only the name of the successful and failed functions (not the function object) to lists in validate_atlases function

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* populating dictionaries in for loop, writing JSON files

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* saving JSON files to ~/.brainglobe/atlases/validation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* printing where to find the result files

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update bg_atlasgen/validate_atlases.py

Co-authored-by: Alessandro Felder <[email protected]>

* Update bg_atlasgen/validate_atlases.py

removing unused variables

Co-authored-by: Alessandro Felder <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* saving only one JSON file with all the information

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* uncommenting test functions

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alessandro Felder <[email protected]>

* bg-atlasapi -> brainglobe-atlasapi

* bg_atlasapi -> brainglobe_atlasapi, package restructure

* Move tests for API into separate subfolder

* Revert "bg_atlasapi -> brainglobe_atlasapi, package restructure"

This reverts commit 120c3b2.

* bg_atlasapi -> brainglobe_atlasapi, package restructure

* Update manifest

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Pre-commit pass

* fixing small bug: validation_functions function argument as variable instead of all_validation_functions (#119)

* Bump NIU action versions

* Move conftest back to top-level directory

* Refactor atlasgen into a submodule

* pre-commit pass

* test functions for validate_mesh_structure_pairs (#114)

* first test functions for validate_mesh_structure_pairs

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* adding docstring

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* writing docstrings to explain the behaviour of the test functions

* validate_atlases.py: updated validate_mesh_structure_pairs function, test_validation.py: updated tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* spliting validate_mesh_structure_pairs function, checking mesh files and structures separately

* writing tests for catch_missing_mesh_files and catch_missing_structures validation functions

* creating an atlas with a missing structure to test catch_missing_structures function

* Update tests/test_unit/test_validation.py

Co-authored-by: Alessandro Felder <[email protected]>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alessandro Felder <[email protected]>

* Revert "Prepare for merge and rename (#198)"

This reverts commit 9d5317d.

* Update pyproject.toml

Co-authored-by: Alessandro Felder <[email protected]>

---------

Co-authored-by: Luigi Petrucco <[email protected]>
Co-authored-by: Adam Tyson <[email protected]>
Co-authored-by: Mathieu <[email protected]>
Co-authored-by: Adam Tyson <[email protected]>
Co-authored-by: Ben Kantor <[email protected]>
Co-authored-by: Kailyn Fields <[email protected]>
Co-authored-by: Federico Claudi <[email protected]>
Co-authored-by: Gubra-ApS <[email protected]>
Co-authored-by: Johanna <[email protected]>
Co-authored-by: Johanna Perens <[email protected]>
Co-authored-by: David Young <[email protected]>
Co-authored-by: Sam Clothier <[email protected]>
Co-authored-by: Sam <[email protected]>
Co-authored-by: Joe Ziminski <[email protected]>
Co-authored-by: NovaFae <[email protected]>
Co-authored-by: David Stansby <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alessandro Felder <[email protected]>
Co-authored-by: viktorpm <[email protected]>
Co-authored-by: alessandrofelder <[email protected]>
  • Loading branch information
21 people authored Feb 23, 2024
1 parent 9d5317d commit e34a84a
Show file tree
Hide file tree
Showing 57 changed files with 7,052 additions and 1,863 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: neuroinformatics-unit/actions/lint@v1
- uses: neuroinformatics-unit/actions/lint@v2

manifest:
runs-on: ubuntu-latest
Expand All @@ -36,22 +36,17 @@ jobs:
python-version: "3.9"

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

build_sdist_wheels:
name: Build source distribution and wheel
needs: [test]
if: (
github.event_name == 'push' && github.ref_type == 'tag'
) || (
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'Test packaging')
)
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
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
bg_atlasapi/bg_config.conf
brainglobe_atlasapi/bg_config.conf

workspace.py
.vscode/

# Byte-compiled / optimized / DLL files
__pycache__
*.__pycache__
__pycache__/
*.py[cod]
*$py.class
Expand Down Expand Up @@ -138,6 +140,5 @@ dmypy.json
.vs/
*.~lock.*


# macOS
*.DS_Store
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,3 @@ repos:
rev: 24.1.1
hooks:
- id: black
- repo: https:/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies:
- types-setuptools
- types-requests
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ authors:
affiliation: 'Sainsbury Wellcome Centre, University College London'
orcid: 'https://orcid.org/0000-0003-3225-1130'
email: [email protected]
repository-code: 'https:/brainglobe/bg-atlasapi'
repository-code: 'https:/brainglobe/brainglobe-atlasapi'
url: >-
https://brainglobe.info/documentation/bg-atlasapi/index.html
https://brainglobe.info/documentation/brainglobe-atlasapi/index.html
abstract: >-
A common interface for programmers to download and process
brain atlas data from multiple sources.
Expand Down
10 changes: 4 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
BSD 3-Clause License

Copyright (c) 2020, brainglobe
Copyright (c) 2020, BrainGlobe
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
- Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

Expand Down
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ include README.md
include requirements.txt

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

graft brainglobe_atlasapi *.py

prune tests
prune tutorials
126 changes: 82 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,61 @@
# This package has moved!
# brainglobe-atlasapi

This package has been renamed to `brainglobe-atlasapi`.
To continue receiving updates, please switch over to using [the new package](https:/brainglobe/brainglobe-atlasapi).

# BG-atlasAPI

[![Python Version](https://img.shields.io/pypi/pyversions/bg-atlasapi.svg)](https://pypi.org/project/bg-atlasapi)
[![PyPI](https://img.shields.io/pypi/v/bg-atlasapi.svg)](https://pypi.org/project/bg-atlasapi/)
[![Wheel](https://img.shields.io/pypi/wheel/bg-atlasapi.svg)](https://pypi.org/project/bg-atlasapi)
[![Python Version](https://img.shields.io/pypi/pyversions/brainglobe-atlasapi.svg)](https://pypi.org/project/brainglobe-atlasapi)
[![PyPI](https://img.shields.io/pypi/v/brainglobe-atlasapi.svg)](https://pypi.org/project/brainglobe-atlasapi/)
[![Wheel](https://img.shields.io/pypi/wheel/brainglobe-atlasapi.svg)](https://pypi.org/project/brainglobe-atlasapi)
[![Development Status](https://img.shields.io/pypi/status/brainatlas-api.svg)](https:/SainsburyWellcomeCentre/brainatlas-api)
[![Downloads](https://pepy.tech/badge/bg-atlasapi)](https://pepy.tech/project/bg-atlasapi)
[![Tests](https://img.shields.io/github/actions/workflow/status/brainglobe/bg-atlasapi/test_and_deploy.yml?branch=main)](
https:/brainglobe/bg-atlasapi/actions)
[![codecov](https://codecov.io/gh/brainglobe/bg-atlasapi/branch/master/graph/badge.svg?token=WTFPFW0TE4)](https://codecov.io/gh/brainglobe/bg-atlasapi)
[![Downloads](https://pepy.tech/badge/brainglobe-atlasapi)](https://pepy.tech/project/brainglobe-atlasapi)
[![Tests](https://img.shields.io/github/actions/workflow/status/brainglobe/brainglobe-atlasapi/test_and_deploy.yml?branch=main)](
https:/brainglobe/brainglobe-atlasapi/actions)
[![codecov](https://codecov.io/gh/brainglobe/brainglobe-atlasapi/branch/master/graph/badge.svg?token=WTFPFW0TE4)](https://codecov.io/gh/brainglobe/brainglobe-atlasapi)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https:/python/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https:/pre-commit/pre-commit)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.02668/status.svg)](https://doi.org/10.21105/joss.02668)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://docs.brainglobe.info/cellfinder/contributing)
[![Website](https://img.shields.io/website?up_message=online&url=https%3A%2F%2Fbrainglobe.info)](https://brainglobe.info/documentation/bg-atlasapi/index.html)
[![Website](https://img.shields.io/website?up_message=online&url=https%3A%2F%2Fbrainglobe.info)](https://brainglobe.info/documentation/brainglobe-atlasapi/index.html)
[![Twitter](https://img.shields.io/twitter/follow/brain_globe?style=social)](https://twitter.com/brain_globe)


The brainglobe atlas API (BG-AtlasAPI) provides a common interface for programmers to download and process brain atlas data from multiple sources.
The brainglobe atlas API (brainglobe-atlasapi) provides a common interface for programmers to download and process brain atlas data from multiple sources.

## Atlases available

A number of atlases are in development, but those available currently are:
* [Allen Mouse Brain Atlas](https://www.brain-map.org) at 10, 25, 50 and 100 micron resolutions
* [Allen Human Brain Atlas](https://www.brain-map.org) at 100 micron resolution
* [Max Planck Zebrafish Brain Atlas](http://fishatlas.neuro.mpg.de) at 1 micron resolution
* [Enhanced and Unified Mouse Brain Atlas](https://kimlab.io/brain-map/atlas/) at 10, 25, 50 and 100 micron resolutions
* [Smoothed version of the Kim et al. mouse reference atlas](https://doi.org/10.1016/j.celrep.2014.12.014) at 10, 25, 50 and 100 micron resolutions
* [Gubra's LSFM mouse brain atlas](https://doi.org/10.1007/s12021-020-09490-8) at 20 micron resolution
* [3D version of the Allen mouse spinal cord atlas](https://doi.org/10.1101/2021.05.06.443008) at 20 x 10 x 10 micron resolution
* [AZBA: A 3D Adult Zebrafish Brain Atlas](https://doi.org/10.1101/2021.05.04.442625) at 4 micron resolution
* [Waxholm Space atlas of the Sprague Dawley rat brain](https://doi.org/10.1016/j.neuroimage.2014.04.001) at 39 micron resolution
* [3D Edge-Aware Refined Atlases Derived from the Allen Developing Mouse Brain Atlases](https://doi.org/10.7554/eLife.61408) (E13, E15, E18, P4, P14, P28 & P56)
* [Princeton Mouse Brain Atlas](https://brainmaps.princeton.edu/2020/09/princeton-mouse-brain-atlas-links) at 20 micron resolution
* [Kim Lab Developmental CCF (P56)](https://data.mendeley.com/datasets/2svx788ddf/1) at 10 micron resolution with 8 reference images - STP, LSFM (iDISCO) and MRI (a0, adc, dwo, fa, MTR, T2)

- [Allen Mouse Brain Atlas](https://www.brain-map.org) at 10, 25, 50 and 100 micron resolutions
- [Allen Human Brain Atlas](https://www.brain-map.org) at 100 micron resolution
- [Max Planck Zebrafish Brain Atlas](http://fishatlas.neuro.mpg.de) at 1 micron resolution
- [Enhanced and Unified Mouse Brain Atlas](https://kimlab.io/brain-map/atlas/) at 10, 25, 50 and 100 micron resolutions
- [Smoothed version of the Kim et al. mouse reference atlas](https://doi.org/10.1016/j.celrep.2014.12.014) at 10, 25, 50 and 100 micron resolutions
- [Gubra's LSFM mouse brain atlas](https://doi.org/10.1007/s12021-020-09490-8) at 20 micron resolution
- [3D version of the Allen mouse spinal cord atlas](https://doi.org/10.1101/2021.05.06.443008) at 20 x 10 x 10 micron resolution
- [AZBA: A 3D Adult Zebrafish Brain Atlas](https://doi.org/10.1101/2021.05.04.442625) at 4 micron resolution
- [Waxholm Space atlas of the Sprague Dawley rat brain](https://doi.org/10.1016/j.neuroimage.2014.04.001) at 39 micron resolution
- [3D Edge-Aware Refined Atlases Derived from the Allen Developing Mouse Brain Atlases](https://doi.org/10.7554/eLife.61408) (E13, E15, E18, P4, P14, P28 & P56)
- [Princeton Mouse Brain Atlas](https://brainmaps.princeton.edu/2020/09/princeton-mouse-brain-atlas-links) at 20 micron resolution
- [Kim Lab Developmental CCF (P56)](https://data.mendeley.com/datasets/2svx788ddf/1) at 10 micron resolution with 8 reference images - STP, LSFM (iDISCO) and MRI (a0, adc, dwo, fa, MTR, T2)

## Installation
BG-AtlasAPI works with Python >3.6, and can be installed from PyPI with:

brainglobe-atlasapi works with Python >3.6, and can be installed from PyPI with:

```bash
pip install bg-atlasapi
pip install brainglobe-atlasapi
```

## Usage
Full information can be found in the [documentation](https://brainglobe.info/documentation/bg-atlasapi/index.html)

Full information can be found in the [documentation](https://brainglobe.info/documentation/brainglobe-atlasapi/index.html)

### Python API
**List of atlases**

To see a list of atlases use `bg_atlasapi.show_atlases`
#### List of atlases

To see a list of atlases use `brainglobe_atlasapi.show_atlases`

```python
from bg_atlasapi import show_atlases
from brainglobe_atlasapi import show_atlases
show_atlases()
# Brainglobe Atlases
# ╭──────────────────────────────────┬────────────┬───────────────┬──────────────╮
Expand All @@ -71,19 +72,19 @@ show_atlases()
# ╰──────────────────────────────────┴────────────┴───────────────┴──────────────╯
```

**Using the atlases**
#### Using the atlases

All the features of each atlas can be accessed via the `BrainGlobeAtlas` class.


e.g. for the 25um Allen Mouse Brain Atlas:

```python
from bg_atlasapi.bg_atlas import BrainGlobeAtlas
from brainglobe_atlasapi.bg_atlas import BrainGlobeAtlas
atlas = BrainGlobeAtlas("allen_mouse_25um")
```

The various files associated with the atlas can then be accessed as attributes of the class:

```python
# reference image
reference_image = atlas.reference
Expand All @@ -101,9 +102,10 @@ print(hemispheres_image.shape)
# (528, 320, 456)
```

**Brain regions**
#### Brain regions

There are multiple ways to work with individual brain regions. To see a dataframe of each brain region, with it's unique ID, acronym and full name, use `atlas.lookup_df`:

```python
atlas.lookup_df.head(8)
# acronym id name
Expand All @@ -118,6 +120,7 @@ atlas.lookup_df.head(8)
```

Each brain region can also be access by the acronym, e.g. for primary visual cortex (VISp):

```python
from pprint import pprint
VISp = atlas.structures["VISp"]
Expand All @@ -131,20 +134,55 @@ pprint(VISp)
# 'structure_id_path': [997, 8, 567, 688, 695, 315, 669, 385]}
```

### Note on coordinates in `bg-atlasapi`
Working with both image coordinates and cartesian coordinates in the same space can be confusing! In `bg-atlasapi`, the origin is always assumed to be in the upper left corner of the image (sectioning along the first dimension), the "ij" convention. This means that when plotting meshes and points using cartesian systems, you might encounter confusing behaviors coming from the fact that in cartesian plots one axis is inverted with respect to ij coordinates (vertical axis increases going up, image row indexes increase going down). To make things as consistent as possible, in `bg-atlasapi` the 0 of the meshes coordinates is assumed to coincide with the 0 index of the images stack, and meshes coordinates increase following the direction stack indexes increase.
To deal with transformations between your data space and `bg-atlasapi`, you might find the [brainglobe-space](https:/brainglobe/brainglobe-space) package helpful.
### Note on coordinates in `brainglobe-atlasapi`

Working with both image coordinates and cartesian coordinates in the same space can be confusing!
In `brainglobe-atlasapi`, the origin is always assumed to be in the upper left corner of the image (sectioning along the first dimension), the "ij" convention.
This means that when plotting meshes and points using cartesian systems, you might encounter confusing behaviors coming from the fact that in cartesian plots one axis is inverted with respect to ij coordinates (vertical axis increases going up, image row indexes increase going down).
To make things as consistent as possible, in `brainglobe-atlasapi` the 0 of the meshes coordinates is assumed to coincide with the 0 index of the images stack, and meshes coordinates increase following the direction stack indexes increase.
To deal with transformations between your data space and `brainglobe-atlasapi`, you might find the [brainglobe-space](https:/brainglobe/brainglobe-space) package helpful.

## Contributing to brainglobe-atlasapi

# Contributing to bg-atlasapi
**Contributors to bg-atlaspi are absolutely encouraged**, whether you want to fix bugs, add/request new features or simply ask questions.

If you would like to contribute to `bg-atlasapi` (or any of the downstream tools like [brainrender](https:/brainglobe/brainrender) etc.) please get in touch by opening a new issue or pull request on [GitHub](https:/brainglobe/bg-atlasapi). Please also see the [developers guide](https://brainglobe.info/developers/index.html).
If you would like to contribute to `brainglobe-atlasapi` (or any of the downstream tools like [brainrender](https:/brainglobe/brainrender) etc.) please get in touch by opening a new issue or pull request on [GitHub](https:/brainglobe/brainglobe-atlasapi).
Please also see the [developers guide](https://brainglobe.info/developers/index.html).

Someone might have already asked a question you might have, so if you're not sure where to start, check out the [issues](https:/brainglobe/bg-atlasapi/issues) (and the issues of the other repositories).
Someone might have already asked a question you might have, so if you're not sure where to start, check out the [issues](https:/brainglobe/brainglobe-atlasapi/issues) (and the issues of the other repositories).

## Citation

If you find the BrainGlobe Atlas API useful, please cite the paper in your work:

>Claudi, F., Petrucco, L., Tyson, A. L., Branco, T., Margrie, T. W. and Portugues, R. (2020). BrainGlobe Atlas API: a common interface for neuroanatomical atlases. Journal of Open Source Software, 5(54), 2668, https://doi.org/10.21105/joss.02668
**Don't forget to cite the developers of the atlas that you used!**

---

# Atlas Generation and Adding a New Atlas

For full instructions to add a new BrainGlobe atlas, please see [here](https://brainglobe.info/documentation/brainglobe_atlasapi/adding-a-new-atlas.html).

The `brainglobe_atlasapi.atlas_generation` submodule contains code for the generation of cleaned-up data, for the main `brainglobe_atlasapi` module.
This code was previously the `bg-atlasgen` module.

## To contribute

1. Fork this repo
2. Clone your repo
3. Run `git clone https:/brainglobe/brainglobe-atlasapi`
4. Install an editable version of the package; by running `pip install -e .` within the cloned directory
5. Create a script to package your atlas, and place into `brainglobe_atlasapi/atlas_generation/atlas_scripts`. Please see other scripts for examples.

Your script should contain everything required to run.
The raw data should be hosted on a publicly accessible repository so that anyone can run the script to recreate the atlas.

If you need to add any dependencies, please add them as an extra in the `pyproject.toml` file, e.g.:

```python
[project.optional-dependencies]
allenmouse = ["allensdk"]
newatlas = ["dependency_1", "dependency_2"]
```
22 changes: 0 additions & 22 deletions bg_atlasapi/__init__.py

This file was deleted.

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

try:
__version__ = metadata("brainglobe-atlasapi")["Version"]
__author__ = metadata("brainglobe-atlasapi")["Author"]
del metadata
except PackageNotFoundError:
# package is not installed
pass


from brainglobe_atlasapi.bg_atlas import BrainGlobeAtlas
from brainglobe_atlasapi.list_atlases import show_atlases
5 changes: 5 additions & 0 deletions brainglobe_atlasapi/atlas_generation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__version__ = "1" # will set major version of all atlases

from rich.traceback import install

install()
Empty file.
Loading

0 comments on commit e34a84a

Please sign in to comment.