Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
adding pre-commit (#57)
Browse files Browse the repository at this point in the history
* define pre-commit
* apply to format
* CI check
  • Loading branch information
Borda authored Jun 1, 2021
1 parent 79a2cc2 commit 608ce30
Show file tree
Hide file tree
Showing 44 changed files with 158 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ comment:
layout: header, diff
require_changes: false
behavior: default # update if exists else create new
# branches: *
# branches: *
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Now, run all tests using::
Use ``--doctest-modules`` to run doctests.
For example, run all tests and all doctests using::
```
$ PYTHONPATH=. pytest --doctest-modules --with-xunit --with-coverage <package>
$ PYTHONPATH=. pytest --doctest-modules --with-xunit --with-coverage <package>
```
## Test coverage
Expand All @@ -104,4 +104,4 @@ detailing the test coverage::
## Bugs
Please `report bugs on GitHub <https://github.com/Borda/pyImRegBenchmark/issues>`_.
Please `report bugs on GitHub <https://github.com/Borda/pyImRegBenchmark/issues>`_.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ assignees: ''
### Description
<!-- Please provide a general introduction to the issue/proposal. -->

<!--
<!--
If reporting a bug, attach the entire traceback from Python.
If proposing an enhancement/new feature, provide links to related articles, reference examples, etc.
-->
Expand Down
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/Question.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ assignees: ''

## ❓ Questions and Help

### Before asking:
### Before asking:
<!--
1. search the issues.
2. search the docs.
1. search the issues.
2. search the docs.
-->

<!-- If you still can't find what you need: -->
Expand All @@ -21,7 +21,7 @@ assignees: ''

#### Code

<!-- Please paste a code snippet if your question requires it! -->
<!-- Please paste a code snippet if your question requires it! -->

#### What have you tried?

Expand Down
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Fixes # (issue).
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
- This change requires a documentation update

## PR review
Anyone in the community is free to review the PR once the tests have passed.
## PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

## Did you have fun?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ jobs:
rm ./data-images/*_/*/*_HE.csv
python birl/bm_template.py -n anhir -t ./data-images/pairs-imgs-lnds_histol.csv -d ./data-images -o ./results --preprocessing matching-rgb gray -cfg configs/sample_config.yaml
python bm_experiments/evaluate_experiment.py -d ./data-images -e ./results/BmTemplate_anhir --visual
shell: bash
shell: bash
19 changes: 19 additions & 0 deletions .github/workflows/code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ jobs:
- name: isort
run: isort --check-only .

pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2

- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}

- uses: pre-commit/[email protected]
# this action also provides an additional behaviour when used in private repositories
# when configured with a github token, the action will push back fixes to the pull request branch
# with:
# token: ${{ secrets.GITHUB_TOKEN }}

#typing-check-mypy:
# runs-on: ubuntu-20.04
# steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
file: bm_experiments/Dockerfile
push: ${{ github.ref == 'refs/heads/master' }}
tags: borda/birl:SOTA-py${{ matrix.python_version }}
timeout-minutes: 240
timeout-minutes: 240
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ coverage.xml
.hypothesis/

# Raw illustrations
figures/*.png
figures/*.png
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
default_language_version:
python: python3.8

ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
# submodules: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- id: pretty-format-json

#- repo: https://github.com/pre-commit/mirrors-autopep8
# rev: v1.5.7
# hooks:
# - id: autopep8
# name: fixing PEP8

- repo: https://github.com/PyCQA/isort
rev: 5.8.0
hooks:
- id: isort
name: imports
require_serial: false

- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.31.0
hooks:
- id: yapf
name: formatting
language: python
require_serial: false

- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
name: PEP8
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ recursive-include scripts *.r *.ijm *.bsh *.py
include *.txt

# Exclude build configs
exclude *.yml
exclude *.yml *.yaml

prune .git
prune .github
Expand Down
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[![Code Health](https://landscape.io/github/Borda/BIRL/master/landscape.svg?style=flat)](https://landscape.io/github/Borda/BIRL/master)
[![Run Status](https://api.shippable.com/projects/585bfa66e18a291000c15f24/badge?branch=master)](https://app.shippable.com/github/Borda/BIRL)
[![Coverage Badge](https://api.shippable.com/projects/585bfa66e18a291000c15f24/coverageBadge?branch=master)](https://app.shippable.com/github/Borda/BIRL)
[![Image.sc
[![Image.sc
forum](https://img.shields.io/badge/dynamic/json.svg?label=forum&url=https%3A%2F%2Fforum.image.sc%2Ftags%2Fanhir.json&query=%24.topic_list.tags.0.topic_count&colorB=brightgreen&suffix=%20topics&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAABPklEQVR42m3SyyqFURTA8Y2BER0TDyExZ+aSPIKUlPIITFzKeQWXwhBlQrmFgUzMMFLKZeguBu5y+//17dP3nc5vuPdee6299gohUYYaDGOyyACq4JmQVoFujOMR77hNfOAGM+hBOQqB9TjHD36xhAa04RCuuXeKOvwHVWIKL9jCK2bRiV284QgL8MwEjAneeo9VNOEaBhzALGtoRy02cIcWhE34jj5YxgW+E5Z4iTPkMYpPLCNY3hdOYEfNbKYdmNngZ1jyEzw7h7AIb3fRTQ95OAZ6yQpGYHMMtOTgouktYwxuXsHgWLLl+4x++Kx1FJrjLTagA77bTPvYgw1rRqY56e+w7GNYsqX6JfPwi7aR+Y5SA+BXtKIRfkfJAYgj14tpOF6+I46c4/cAM3UhM3JxyKsxiOIhH0IO6SH/A1Kb1WBeUjbkAAAAAElFTkSuQmCC)](https://forum.image.sc/tags/anhir)
-->

Expand All @@ -33,9 +33,9 @@ _This project/framework is the key component of **[Automatic Non-rigid Histologi
The project contains a set of sample images with related landmark annotations and experimental evaluation of state-of-the-art image registration methods.

The initial [dataset of stained histological tissues](http://cmp.felk.cvut.cz/~borovji3/?page=dataset) is composed by image pairs of related sections (mainly, consecutive cuts).
Each image in the pair is coloured with a different stain.
The registration of those images is a challenging task due to both artefacts and deformations acquired during sample preparation and appearance differences due to staining.
For evaluation, we have manually placed landmarks in each image pair. There are at least 40 uniformly spread over the tissue.
Each image in the pair is coloured with a different stain.
The registration of those images is a challenging task due to both artefacts and deformations acquired during sample preparation and appearance differences due to staining.
For evaluation, we have manually placed landmarks in each image pair. There are at least 40 uniformly spread over the tissue.
We do not put any landmarks in the background.
For more information about annotation creation and landmarks handling, we refer to the special repository - [Dataset: histology landmarks](http://borda.github.com/dataset-histology-landmarks).

Expand Down Expand Up @@ -91,20 +91,20 @@ python setup.py install
For installing some particular version/releases use following links
_https://github.com/Borda/BIRL/archive/v0.2.3.zip_
where the numbers match desired version
(see package [releases](https://github.com/Borda/BIRL/releases)).
(see package [releases](https://github.com/Borda/BIRL/releases)).

---

## Before benchmarks (pre-processing)
## Before benchmarks (pre-processing)

In the `data-images` folder we provide some sample images with landmarks for registration.
These sample registration pairs are saved in `data-images/pairs-imgs-lnds_mix.csv`.
In the `data-images` folder we provide some sample images with landmarks for registration.
These sample registration pairs are saved in `data-images/pairs-imgs-lnds_mix.csv`.
You can create your own costume cover table for a given dataset (folder with images and landmarks) by hand or use script `bm_dataset/create_registration_pairs.py` assuming the same folder structure `<dataset>/<image-set>/<scale>/<images-and-landmarks>` as for the [CIMA dataset](http://cmp.felk.cvut.cz/~borovji3/?page=dataset).

### Prepare synthetic data

There is a script to generate synthetic data.
Just set an initial image and their corresponding landmarks.
There is a script to generate synthetic data.
Just set an initial image and their corresponding landmarks.
The script will generate a set of geometrically deformed images mimicking different stains and compute the new related landmarks.

```bash
Expand All @@ -117,8 +117,8 @@ python bm_dataset/create_real_synth_dataset.py \

### Creating an image-pairs table

When the synthetic datasets have been created, the cover csv file which contains the registration pairs (Reference and Moving image (landmarks)) is generated.
Two modes are created: _"first2all"_ for registering the first image to all others and _"each2all"_ for registering each image to all other.
When the synthetic datasets have been created, the cover csv file which contains the registration pairs (Reference and Moving image (landmarks)) is generated.
Two modes are created: _"first2all"_ for registering the first image to all others and _"each2all"_ for registering each image to all other.
_(note A-B is the same as B-A)_

```bash
Expand All @@ -144,7 +144,7 @@ We introduce an option how to randomly take only a subset (use `nb_selected`) of
python bm_dataset/rescale_tissue_landmarks.py \
-a ./data-images -d ./output \
--nb_selected 0.5 --nb_total 200
```
```

Moreover we developed two additional script for converting large images, handling multiple tissue samples in single image and crop to wide background.
* `bm_dataset/convert_tiff2png.py` converts TIFF or SVS image to PNG in a particular level
Expand All @@ -161,7 +161,7 @@ Even though this framework is completely customizable we include several image r

### Install methods and run benchmarks

For each registration method, different experiments can be performed independently using different values of the parameters or image pairs sets.
For each registration method, different experiments can be performed independently using different values of the parameters or image pairs sets.

Sample execution of the "empty" benchmark template:
```bash
Expand Down Expand Up @@ -197,13 +197,13 @@ The general Image Registration benchmarks contain couple required and optional p
![preprocessing-hist-matching](assets/Rat-Kidney_histogram-matching.jpg)

Measure your computer performance using average execution time on several simple image registrations.
The registration consists of loading images, denoising, feature detection, transform estimation and image warping.
The registration consists of loading images, denoising, feature detection, transform estimation and image warping.
```bash
python bm_experiments/bm_comp_perform.py -o ./results
```
This script generate simple report exported in JSON file on given output path.

### Prepared experimental docker image
### Prepared experimental docker image

Used prepared docker image from [Docker Hub](https://hub.docker.com/r/borda/birl)

Expand Down Expand Up @@ -334,14 +334,14 @@ The new image registration methods should be added to `bm_experiments` folder.
### Re-evaluate experiment
In case you need to re-compute evaluation or add visualisation to existing experiment you can use the following script.
The script require complete experiment folder with standard `registration-results.scv` (similar to registration pairs extended by experiment results).
In case you need to re-compute evaluation or add visualisation to existing experiment you can use the following script.
The script require complete experiment folder with standard `registration-results.scv` (similar to registration pairs extended by experiment results).
```bash
python bm_experiments/evaluate_experiment.py \
-e ./results/BmUnwarpJ \
--visual
```
```
---
Expand All @@ -363,10 +363,10 @@ For complete references see [bibtex](docs/references.bib).
Create your own local environment, for more information see the [User Guide](https://pip.pypa.io/en/latest/user_guide.html), and install dependencies requirements.txt contains a list of packages and can be installed as
```bash
@duda:~$ cd BIRL
@duda:~$ cd BIRL
@duda:~/BIRL$ virtualenv env
@duda:~/BIRL$ source env/bin/activate
(env)@duda:~/BIRL$ pip install -r requirements.txt
@duda:~/BIRL$ source env/bin/activate
(env)@duda:~/BIRL$ pip install -r requirements.txt
(env)@duda:~/BIRL$ python ...
```
and in the end, terminating...
Expand All @@ -376,7 +376,7 @@ and in the end, terminating...
**Running docString tests** - documentation and samples of doc string on [pymotw](https://pymotw.com/2/doctest/) and [python/docs](https://docs.python.org/2/library/doctest.html)
**Listing dataset in command line**
**Listing dataset in command line**
```bash
find . | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/" >> dataset.txt
```
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
show_downloads: true
theme: jekyll-theme-cayman
theme: jekyll-theme-cayman
4 changes: 2 additions & 2 deletions bm_ANHIR/automatic-evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Run one of following sample registration experiments:
~/Medical-temp/experiments_anhir/BmUnwarpJ/*/*.png
```

Running the docker image with mapped folders
Running the docker image with mapped folders
```bash
mkdir submission output
```
Expand All @@ -61,7 +61,7 @@ docker run --rm -it \
```


### Export
### Export

Export the created image to be uploaded to the evaluation system.
```bash
Expand Down
2 changes: 1 addition & 1 deletion bm_ANHIR/emails/text_dataset.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Let us remind you that we will have a challenge workshop at the ISBI conference

Do not hesitate to ask if you have any questions or comments.
Good luck and we are looking forward to meeting you in Venice.
Jiri Borovec & Arrate Munoz-Barrutia & Jan Kybic & Ignacio Arganda
Jiri Borovec & Arrate Munoz-Barrutia & Jan Kybic & Ignacio Arganda
2 changes: 1 addition & 1 deletion bm_ANHIR/emails/text_invitation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ For more detail visit our webpage:
https://anhir.grand-challenge.org

Looking forward to your possible participation,
Jiri Borovec & Arrate Munoz-Barrutia & Jan Kybic & Ignacio Arganda
Jiri Borovec & Arrate Munoz-Barrutia & Jan Kybic & Ignacio Arganda
2 changes: 1 addition & 1 deletion bm_ANHIR/emails/text_pre-release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Do not hesitate to ask if you have any questions or comments.

Good luck!
We are looking forward to meeting you in Venice.
Jiri Borovec & Arrate Munoz-Barrutia & Jan Kybic & Ignacio Arganda-Carreras
Jiri Borovec & Arrate Munoz-Barrutia & Jan Kybic & Ignacio Arganda-Carreras
2 changes: 1 addition & 1 deletion bm_CIMA/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ Then you can parse just the new results with [evaluation script](../bm_ANHIR/eva
## References

For complete references see [bibtex](../docs/references.bib).
1. Borovec, J. (2019). **BIRL: Benchmark on Image Registration methods with Landmark validation**. arXiv preprint [arXiv:1912.13452.](https://arxiv.org/abs/1912.13452)
1. Borovec, J. (2019). **BIRL: Benchmark on Image Registration methods with Landmark validation**. arXiv preprint [arXiv:1912.13452.](https://arxiv.org/abs/1912.13452)
2 changes: 1 addition & 1 deletion bm_experiments/run-all-experiments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ do
$pproc \
--visual --unique --nb_workers $jobs

done
done
2 changes: 1 addition & 1 deletion configs/ANTs_SyN.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
--use-histogram-matching 1
--collapse-output-transforms 1
--float
--verbose
--verbose
2 changes: 1 addition & 1 deletion configs/ANTs_spline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
--use-histogram-matching 1
--collapse-output-transforms 1
--float
--verbose
--verbose
2 changes: 1 addition & 1 deletion configs/DROP.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ increg = 1
update = 0
sampling = 0
bins = 8
margin = 0
margin = 0
2 changes: 1 addition & 1 deletion configs/DROP2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
--nsim 1
--nlevels 16 16 16 8 8 8
--nlambda 0.5
--npin
--npin
Loading

0 comments on commit 608ce30

Please sign in to comment.