Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardise package structure #22

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e098aad
Added default parameter sets to be used for transforms (from brainreg…
Oct 10, 2023
0adedfa
Basic magicgui that can import an atlas, translate the atlas/sample, …
Oct 10, 2023
8265262
Added a button to reset the image back to origin
Oct 10, 2023
8f37fad
Added the ability to rotate the image and reset back to original state
Oct 10, 2023
ab375f8
Added start alignment button
Oct 12, 2023
d0bf17c
Added start alignment button
Oct 12, 2023
ce73b7b
Merge remote-tracking branch 'origin/basic-functionality' into basic-…
Oct 12, 2023
d92810c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 12, 2023
ed93f0c
Transitioning basic function to qpty directly. Widget in registration…
Oct 13, 2023
65c04a6
Merge remote-tracking branch 'origin/basic-functionality' into basic-…
Oct 13, 2023
d53696f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 13, 2023
7297aec
Napari image layer is now rotated around the center not at origin
Oct 16, 2023
2125849
Tests for setup_parameter_object done
Oct 17, 2023
15a6e3e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 17, 2023
35d39f0
Wrote basic tests for registration_widget and register
IgorTatarnikov Oct 24, 2023
5ee9e99
Re-factored the core registration_widget.py to split off each individ…
IgorTatarnikov Oct 24, 2023
4a7de5f
Added a run settings widget to allow selection of transform types and…
IgorTatarnikov Oct 24, 2023
d141831
Added tabs on the left side of the main widget, parameter_list_view r…
IgorTatarnikov Oct 24, 2023
6fd7270
Can dynamically load default values from the 3 provided sources and l…
IgorTatarnikov Oct 24, 2023
e635d81
Param dictionaries are updated when fields are altered in the table t…
IgorTatarnikov Oct 25, 2023
d7e072f
Parameter table now expands when new entries are added
IgorTatarnikov Oct 25, 2023
b0dea23
Fixed merge conflicts with renaming main
IgorTatarnikov Nov 1, 2023
72259cb
Plugin runs successfully after renaming
IgorTatarnikov Nov 1, 2023
f015b7a
Param dictionaries passed to the backend directly
IgorTatarnikov Nov 2, 2023
44c0d02
First version of transform selection widget allowing arbitrary number…
IgorTatarnikov Nov 3, 2023
eb635e8
Each column now dynamically imports the correct default file based on…
IgorTatarnikov Nov 3, 2023
b668c7e
Parameters are now read as lists from files, arbitrary numbers of par…
IgorTatarnikov Nov 6, 2023
89065b2
Moving image adjusts immediately after values are entered, removed ad…
IgorTatarnikov Nov 7, 2023
cc1ec57
When reading parameter files anything after a '\' will now be discard…
IgorTatarnikov Nov 8, 2023
5e93b54
Updated tests for braingblobe_registration/register.py, added tests f…
IgorTatarnikov Nov 9, 2023
381e2b9
Added tests for brainglobe_registration/widgets/select_images_view.py
IgorTatarnikov Nov 9, 2023
fb0dc0e
Started tests for brainglobe_registration/widgets/parameter_list_view.py
IgorTatarnikov Nov 9, 2023
6945993
Finished tests for brainglobe/registration/widgets/parameter_list_vie…
IgorTatarnikov Nov 10, 2023
f9e1d90
Started tests for transform_select_view.py
IgorTatarnikov Nov 10, 2023
8b51abc
Updating README.md
IgorTatarnikov Nov 22, 2023
c3db983
Update README.md
IgorTatarnikov Nov 22, 2023
b6eadfc
Updated README.md
IgorTatarnikov Nov 23, 2023
63de272
Added tests, added dynamic fetching for sample selection
IgorTatarnikov Nov 23, 2023
1cef635
Update README.md
IgorTatarnikov Nov 23, 2023
beaa9ad
Refactored test_registration_widget.py to account for funcitons movin…
IgorTatarnikov Nov 24, 2023
b325d56
Fixed line lengths
IgorTatarnikov Nov 24, 2023
a19a95c
WIP transforming annotations after registration
IgorTatarnikov Nov 24, 2023
1e7de58
WIP transform annotations after registration
IgorTatarnikov Nov 24, 2023
b188101
Transformed annotation and boundaries images from atlas to sample space
IgorTatarnikov Nov 27, 2023
9614ce8
Registered boundaries are now added as an image layer, boundaries ove…
IgorTatarnikov Nov 28, 2023
f0640d3
Standardise package structure
IgorTatarnikov Nov 28, 2023
0fb4875
Changed test_and_deploy.yml to run on all push
IgorTatarnikov Nov 28, 2023
bdc52bc
Fixed file paths for test images
IgorTatarnikov Nov 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 63 additions & 61 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,90 +1,92 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: tests

on:
push:
branches:
- main
- npe2
- '*'
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
- '*'
pull_request:
branches:
- main
- npe2
workflow_dispatch:

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:
name: ${{ matrix.platform }} py${{ matrix.python-version }}
runs-on: ${{ matrix.platform }}
needs: [linting, manifest]
name: ${{ matrix.os }} py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10']
# 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:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

# these libraries enable testing on Qt on linux
- uses: tlambert03/setup-qt-libs@v1
- uses: pyvista/setup-headless-display-action@v2
with:
qt: true

# strategy borrowed from vispy for installing opengl libs on windows
- name: Install Windows OpenGL
if: runner.os == 'Windows'
run: |
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1
# cache atlases needed by the tests
- name: Cache Atlases
id: atlas-cache
uses: actions/cache@v3
with:
path: | # ensure we don't cache any interrupted atlas download and extraction!
~/.brainglobe/*
!~/.brainglobe/atlas.tar.gz
key: ${{ runner.os }}-cached-atlases
enableCrossOsArchive: false # ~ and $HOME evaluate to different places across OSs!

# note: if you need dependencies from conda, considering using
# setup-miniconda: https://github.com/conda-incubator/setup-miniconda
# and
# tox-conda: https://github.com/tox-dev/tox-conda
- name: Install dependencies
- if: ${{ steps.atlas-cache.outputs.cache-hit == 'true' }}
name: List files in brainglobe data folder # good to be able to sanity check that user data is as expected
run: |
python -m pip install --upgrade pip
python -m pip install setuptools tox tox-gh-actions
ls -af ~/.brainglobe/

# this runs the platform-specific tests declared in tox.ini
- name: Test with tox
uses: aganders3/headless-gui@v1
# Run tests
- uses: neuroinformatics-unit/actions/test@v2
with:
run: python -m tox
env:
PLATFORM: ${{ matrix.platform }}

- name: Coverage
uses: codecov/codecov-action@v3
python-version: ${{ matrix.python-version }}

deploy:
# this will run when you have tagged a commit, starting with "v*"
# and requires that you have put your twine API key in your
# github secrets (see readme for details)
build_sdist_wheels:
name: Build source distribution
needs: [test]
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools setuptools_scm wheel twine build
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
run: |
git tag
python -m build .
twine upload dist/*
- 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 }}
34 changes: 20 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Configuring https://pre-commit.ci/
ci:
autoupdate_schedule: monthly

exclude: 'conf.py'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-docstring-first
- id: check-executables-have-shebangs
Expand All @@ -16,17 +13,26 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.6
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.11.0
hooks:
- id: black
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.5.1
# hooks:
# - id: mypy
# additional_dependencies:
# - types-setuptools
# - types-requests
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.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]
- repo: https://github.com/tlambert03/napari-plugin-checks
rev: v0.3.0
hooks:
- id: napari-plugin-checks
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
include LICENSE
include README.md
include .napari-hub/DESCRIPTION.md
include .napari-hub/config.yml
include brainglobe_registration/napari.yaml
include brainglobe_registration/resources/brainglobe.png
exclude .pre-commit-config.yaml

recursive-include brainglobe_registration/parameters *.txt
recursive-include brainglobe_registration/resources *.tif
recursive-exclude imgs *.png
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
recursive-exclude docs *
recursive-exclude tests *
61 changes: 48 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,51 @@ Registration to a BrainGlobe atlas using Elastix

----------------------------------

This [napari] plugin was generated with [Cookiecutter] using [@napari]'s [cookiecutter-napari-plugin] template.

<!--
Don't miss the full getting started guide to set up your new package:
https://github.com/napari/cookiecutter-napari-plugin#getting-started

and review the napari docs for plugin developers:
https://napari.org/stable/plugins/index.html
-->

A [napari] plugin for registering images to a BrainGlobe atlas.

![brainglobe-registration](./imgs/brainglobe_registration_main.png)

## Usage

1. Open `napari`.
2. Install the plugin with `pip install git+https://github.com/brainglobe/brainglobe-registration.git`.
3. Open the widget by selecting `Plugins > BrainGlobe Registration` in the napari menu bar near the
top left of the window.
![brainglobe-registration-plugin](./imgs/brainglobe_registration_plugin_window.png)
The `BrainGlobe Registration` plugin will appear on the right hand side of the napari window.
4. Open the image you want to register in napari (a sample 2D image can be found by selecting `File > Open Sample > Sample Brain Slice`).
5. Select the atlas you want to register to from the dropdown menu.
![brainglobe-registration-atlas-selection](./imgs/brainglobe_registration_atlas_selection.png)
The atlas will appear in the napari viewer. Select the approximate `Z` slice of the atlas that you want to register to,
using the slider at the bottom of the napari viewer.
![brainglobe-registration-atlas-selection](./imgs/brainglobe_registration_atlas_selection_2.png)
6. Adjust the sample image to roughly match the atlas image.
You can do this by adjusting X and Y translation as well as rotating around the centre of the image.
You can overlay the two images by toggling `Grid` mode in the napari viewer (Ctrl+G).
You can then adjust the color map and opacity of the atlas image to make manual alignment easier.
![brainglobe-registration-overlay](./imgs/brainglobe_registration_overlay.png)
The sample image can be reset to its original position and orientation by clicking `Reset Image` in the `BrainGlobe Registration` plugin window.
7. Select the transformations you want to use from the dropdown menu. Set the transformation type to empty to remove a step.
Select from one of the three provided default parameter sets (elastix, ARA, or IBL). Customise the parameters further in the
`Parameters` tab.
8. Click `Run` to register the image. The registered image will appear in the napari viewer.
![brainglobe-registration-registered](./imgs/brainglobe_registration_registered.png)
![brainglobe-registration-registered](./imgs/brainglobe_registration_registered_stacked.png)
## Installation

You can install `brainglobe-registration` via [pip]:
We strongly recommend to use a virtual environment manager (like `conda` or `venv`). The installation instructions below
will not specify the Qt backend for napari, and you will therefore need to install that separately. Please see the
[`napari` installation instructions](https://napari.org/stable/tutorials/fundamentals/installation.html) for further advice on this.

pip install brainglobe-registration
[WIP] You can install `brainglobe-registration` via [pip]:

pip install brainglobe-registration


To install latest development version :

pip install git+https://github.com/brainglobe/brainglobe-registration.git


## Contributing

Contributions are very welcome. Tests can be run with [tox], please ensure
Expand All @@ -48,6 +70,19 @@ Distributed under the terms of the [BSD-3] license,

If you encounter any problems, please [file an issue] along with a detailed description.


## Acknowledgements

This [napari] plugin was generated with [Cookiecutter] using [@napari]'s [cookiecutter-napari-plugin] template.

<!--
Don't miss the full getting started guide to set up your new package:
https://github.com/napari/cookiecutter-napari-plugin#getting-started

and review the napari docs for plugin developers:
https://napari.org/stable/plugins/index.html
-->

[napari]: https://github.com/napari/napari
[Cookiecutter]: https://github.com/audreyr/cookiecutter
[@napari]: https://github.com/napari
Expand Down
Loading