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

Commit

Permalink
imports & docs
Browse files Browse the repository at this point in the history
* absolute imports
* update docstring
* drop enlighten
* update manifest
* fixing CI: xos
  • Loading branch information
Borda committed Jan 11, 2020
1 parent ec43742 commit 99b324f
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 68 deletions.
55 changes: 34 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,66 @@ env:
global:
- DISPLAY=""

language: python

matrix:
include:
- os: osx
osx_image: xcode9.4
language: generic
env: TOXENV=py36
addons:
homebrew:
# update: true
packages: python3.6
before_install:
# - brew update && brew install git-lfs
- pip3 install virtualenv
- virtualenv -p python3 ~/venv
- source ~/venv/bin/activate
#before_script:
# - git lfs install
# - git lfs pull
- os: linux
language: python
python: 2.7
dist: xenial # Ubuntu 16.04
env: TOXENV=py27
- os: linux
language: python
python: 3.5
dist: xenial # Ubuntu 16.04
env: TOXENV=py35
- os: linux
language: python
python: 3.6
dist: bionic # Ubuntu 18.04
env: TOXENV=py36
- os: linux
language: python
python: 3.7
dist: bionic # Ubuntu 18.04
env: TOXENV=py37
- os: osx
osx_image: xcode10.3
language: generic
env: TOXENV=py37
addons:
homebrew:
# update: true
packages: openslide
before_install:
# - brew update && brew install git-lfs
- pip3 install virtualenv
- virtualenv -p python3 ~/venv
- source ~/venv/bin/activate
#before_install:
# # - brew update && brew install git-lfs
# - "pyenv install 3.6.8"
# - "pyenv global 3.6.8"
#before_script:
# - git lfs install
# - git lfs pull
# https://blog.travis-ci.com/2019-08-07-extensive-python-testing-on-travis-ci
# https://docs.travis-ci.com/user/languages/python/
- os: windows # Windows 10.0.17134 N/A Build 17134
language: shell # 'language: python' is an error on Travis CI Windows
before_install:
- choco install python --version 3.7.0
- python -m pip install --upgrade pip
env: PATH=/c/Python37:/c/Python37/Scripts:%OPENCV_DIR%/bin:$PATH
# https://towardsdatascience.com/extensive-python-testing-on-travis-ci-4c24db9bf961
allow_failures:
- os: osx
- os: windows

# See http://docs.travis-ci.com/user/caching/#pip-cache
cache: pip

before_install:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew install openslide ;
else
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then
sudo apt-get install openslide-tools ;
fi

Expand Down
8 changes: 3 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ recursive-include bm_dataset *.py
recursive-include bm_experiments *.py
recursive-exclude bm_experiments *.sh

# exclude challenge scripts
recursive-exclude bm_ANHIR *
exclude bm_ANHIR

# exclude tests from package
recursive-exclude tests *
exclude tests
Expand Down Expand Up @@ -53,4 +49,6 @@ prune .git
prune .github
prune notebook*
prune temp*
prune test*
prune test*
prune bm_ANHIR
prune bm_CIMA
13 changes: 6 additions & 7 deletions birl/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
Copyright (C) 2016-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand All @@ -28,17 +27,17 @@

# this is used while calling this file as a script
sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from .utilities.data_io import (
from birl.utilities.data_io import (
update_path, create_folder, image_sizes, load_landmarks, load_image, save_image)
from .utilities.dataset import image_histogram_matching, common_landmarks
from .utilities.evaluate import (
from birl.utilities.dataset import image_histogram_matching, common_landmarks
from birl.utilities.evaluate import (
compute_target_regist_error_statistic, compute_affine_transf_diff, compute_tre_robustness)
from .utilities.experiments import (
from birl.utilities.experiments import (
nb_workers, exec_commands, string_dict, iterate_mproc_map, create_basic_parser,
parse_arg_params, Experiment)
from .utilities.drawing import (
from birl.utilities.drawing import (
export_figure, draw_image_points, draw_images_warped_landmarks, overlap_two_images)
from .utilities.registration import estimate_affine_transform
from birl.utilities.registration import estimate_affine_transform

#: In case provided dataset and complete (true) dataset differ
COL_PAIRED_LANDMARKS = 'Ration matched landmarks'
Expand Down
1 change: 0 additions & 1 deletion birl/bm_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down
8 changes: 4 additions & 4 deletions birl/utilities/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def project_object_edge(img, dimension):
def load_large_image(img_path):
""" loading very large images
Note, for the loading we have to use matplotlib while ImageMagic nor other
.. note:: For the loading we have to use matplotlib while ImageMagic nor other
lib (opencv, skimage, Pillow) is able to load larger images then 64k or 32k.
:param str img_path: path to the image
Expand All @@ -189,7 +189,7 @@ def load_large_image(img_path):
def save_large_image(img_path, img):
""" saving large images more then 50k x 50k
Note, for the saving we have to use openCV while other
.. note:: For the saving we have to use openCV while other
lib (matplotlib, Pillow, ITK) is not able to save larger images then 32k.
:param str img_path: path to the new image
Expand Down Expand Up @@ -330,7 +330,7 @@ def norm_angle(angle, deg=True):
def is_point_inside_perpendicular(point_begin, point_end, point_test):
""" If point is left from line and perpendicularly in between line segment
Note that negative response does not mean that that the point is on tight side
.. note:: negative response does not mean that that the point is on tight side
:param list(float) point_begin: starting line point
:param list(float) point_end: ending line point
Expand Down Expand Up @@ -361,7 +361,7 @@ def is_point_inside_perpendicular(point_begin, point_end, point_test):
def is_point_in_quadrant_left(point_begin, point_end, point_test):
""" If point is left quadrant from line end point
Note that negative response does not mean that that the point is on tight side
.. note:: negative response does not mean that that the point is on tight side
:param list(float) point_begin: starting line point
:param list(float) point_end: ending line point
Expand Down
7 changes: 3 additions & 4 deletions birl/utilities/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
# from __future__ import absolute_import

import os
import logging
Expand All @@ -14,9 +13,9 @@
from PIL import ImageDraw
from matplotlib import colors as plt_colors, ticker as plt_ticker

from .data_io import convert_ndarray2image
from .dataset import scale_large_images_landmarks
from .evaluate import compute_matrix_user_ranking
from birl.utilities.data_io import convert_ndarray2image
from birl.utilities.dataset import scale_large_images_landmarks
from birl.utilities.evaluate import compute_matrix_user_ranking

#: default figure size for visualisations
MAX_FIGURE_SIZE = 18 # inches
Expand Down
3 changes: 1 addition & 2 deletions birl/utilities/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Copyright (C) 2016-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

from itertools import chain
from collections import Counter
Expand All @@ -12,7 +11,7 @@
import pandas as pd
from scipy.spatial import distance

from .registration import estimate_affine_transform, get_affine_components, norm_angle
from birl.utilities.registration import estimate_affine_transform, get_affine_components, norm_angle


def compute_tre(points_1, points_2):
Expand Down
12 changes: 5 additions & 7 deletions birl/utilities/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Copyright (C) 2016-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand All @@ -19,12 +18,12 @@
import multiprocessing as mproc
from functools import wraps

import enlighten
import tqdm
import numpy as np
from pathos.multiprocessing import ProcessPool

from .data_io import create_folder, save_config_yaml, update_path
from .dataset import CONVERT_RGB
from birl.utilities.data_io import create_folder, save_config_yaml, update_path
from birl.utilities.dataset import CONVERT_RGB

#: number of available CPUs on this computer
CPU_COUNT = int(mproc.cpu_count())
Expand Down Expand Up @@ -544,9 +543,8 @@ def iterate_mproc_map(wrap_func, iterate_vals, nb_workers=CPU_COUNT, desc=''):
nb_workers = CPU_COUNT if nb_workers < 0 else nb_workers

if desc is not None:
pbar = enlighten.Counter(total=len(iterate_vals),
desc=str('%r @%i-threads' % (desc, nb_workers)),
stream=sys.stderr)
pbar = tqdm.tqdm(total=len(iterate_vals),
desc=str('%r @%i-threads' % (desc, nb_workers)))
else:
pbar = None

Expand Down
2 changes: 1 addition & 1 deletion bm_ANHIR/copy_sub-scales.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Copy files as all sub-scales
Note that all paths are hard-coded to be used in CMP grid
.. note:: all paths are hard-coded to be used in CMP grid
"""

Expand Down
2 changes: 1 addition & 1 deletion bm_dataset/crop_tissue_images.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Crop images around major object with set padding
Note, that using these scripts for 1+GB images take several tens of GB RAM
.. note:: Using these scripts for 1+GB images take several tens of GB RAM
Sample usage::
Expand Down
2 changes: 1 addition & 1 deletion bm_dataset/rescale_tissue_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
With given path pattern to images crete particular scales within the same set
Note, that using these scripts for 1+GB images take several tens of GB RAM
.. note:: Using these scripts for 1+GB images take several tens of GB RAM
Sample usage::
Expand Down
2 changes: 1 addition & 1 deletion bm_dataset/split_images_two_tissues.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Splitting image containing two samples
Note, that using these scripts for 1+GB images take several tens of GB RAM
.. note:: Using these scripts for 1+GB images take several tens of GB RAM
Sample usage::
Expand Down
1 change: 0 additions & 1 deletion bm_experiments/bm_ANTs.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down
1 change: 0 additions & 1 deletion bm_experiments/bm_ANTsPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down
1 change: 0 additions & 1 deletion bm_experiments/bm_DROP.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down
1 change: 0 additions & 1 deletion bm_experiments/bm_DROP2.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down
1 change: 0 additions & 1 deletion bm_experiments/bm_RVSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down
1 change: 0 additions & 1 deletion bm_experiments/bm_bUnwarpJ.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down
1 change: 0 additions & 1 deletion bm_experiments/bm_elastix.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down
1 change: 0 additions & 1 deletion bm_experiments/bm_rNiftyReg.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ matplotlib>=2.0.2,<3.0.0 # new version does not support py2
tqdm>=4.7.4,<=4.30 # higher fails ascii for py2
pyyaml
scikit-image
opencv-python
opencv-python-headless
openslide-python
nibabel
SimpleITK
mock
psutil
pathos
enlighten>=1.3.3 # fix for Windows
pathos
1 change: 0 additions & 1 deletion tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down
1 change: 0 additions & 1 deletion tests/test_data-utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Copyright (C) 2017-2019 Jiri Borovec <[email protected]>
"""
from __future__ import absolute_import

import os
import sys
Expand Down

0 comments on commit 99b324f

Please sign in to comment.