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

Commit

Permalink
isort: define & apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Mar 31, 2021
1 parent 8b1e731 commit 80eea24
Show file tree
Hide file tree
Showing 29 changed files with 118 additions and 75 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ jobs:
- name: yapf
run: yapf --diff --parallel --recursive .

# imports-check-isort:
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@master
# - uses: actions/setup-python@v2
# with:
# python-version: 3.8
# - name: Install isort
# run: |
# pip install isort
# pip list
# - name: isort
# run: isort --check-only .
imports-check-isort:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install isort
run: |
pip install isort
pip list
- name: isort
run: isort --check-only .

#typing-check-mypy:
# runs-on: ubuntu-20.04
Expand Down
18 changes: 13 additions & 5 deletions birl/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,23 @@

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

#: In case provided dataset and complete (true) dataset differ
Expand Down
2 changes: 1 addition & 1 deletion birl/bm_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

# this is used while calling this file as a script
sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.experiments import create_basic_parser
from birl.benchmark import ImRegBenchmark
from birl.utilities.experiments import create_basic_parser


class BmTemplate(ImRegBenchmark):
Expand Down
4 changes: 2 additions & 2 deletions birl/utilities/data_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import warnings
from functools import wraps

import SimpleITK as sitk
import cv2 as cv
import nibabel
import numpy as np
import pandas as pd
import SimpleITK as sitk
import yaml
from PIL import Image
from skimage.color import rgb2gray, gray2rgb
from skimage.color import gray2rgb, rgb2gray

#: landmarks coordinates, loading from CSV file
LANDMARK_COORDS = ['X', 'Y']
Expand Down
16 changes: 8 additions & 8 deletions birl/utilities/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@

import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
from cv2 import (
IMWRITE_JPEG_QUALITY,
IMWRITE_PNG_COMPRESSION,
COLOR_RGBA2RGB,
COLOR_RGB2BGR,
INTER_LINEAR,
GaussianBlur,
COLOR_RGBA2RGB,
cvtColor,
GaussianBlur,
imwrite,
IMWRITE_JPEG_QUALITY,
IMWRITE_PNG_COMPRESSION,
INTER_LINEAR,
resize,
)
from matplotlib.path import Path
from scipy import spatial, optimize
from skimage.color import rgb2hsv, hsv2rgb, rgb2lab, lab2rgb, lch2lab, lab2lch, rgb2hed, hed2rgb, rgb2luv, luv2rgb
from PIL import Image
from scipy import optimize, spatial
from skimage.color import hed2rgb, hsv2rgb, lab2lch, lab2rgb, lch2lab, luv2rgb, rgb2hed, rgb2hsv, rgb2lab, rgb2luv
from skimage.exposure import rescale_intensity
from skimage.filters import threshold_otsu

Expand Down
3 changes: 2 additions & 1 deletion birl/utilities/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

import matplotlib.pylab as plt
import numpy as np
from matplotlib import colors as plt_colors
from matplotlib import ticker as plt_ticker
from PIL import ImageDraw
from matplotlib import colors as plt_colors, ticker as plt_ticker

from birl.utilities.data_io import convert_ndarray2image
from birl.utilities.dataset import scale_large_images_landmarks
Expand Down
4 changes: 2 additions & 2 deletions bm_ANHIR/evaluate_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
import pandas as pd

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.benchmark import _df_drop_unnamed, COL_PAIRED_LANDMARKS, filter_paired_landmarks, ImRegBenchmark
from birl.utilities.data_io import create_folder, load_landmarks, save_landmarks, update_path
from birl.utilities.dataset import parse_path_scale
from birl.utilities.experiments import iterate_mproc_map, parse_arg_params, FORMAT_DATE_TIME, nb_workers
from birl.benchmark import COL_PAIRED_LANDMARKS, ImRegBenchmark, filter_paired_landmarks, _df_drop_unnamed
from birl.utilities.experiments import FORMAT_DATE_TIME, iterate_mproc_map, nb_workers, parse_arg_params

NB_WORKERS = nb_workers(0.9)
NAME_CSV_RESULTS = 'registration-results.csv'
Expand Down
4 changes: 2 additions & 2 deletions bm_ANHIR/generate_regist_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import tqdm

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.data_io import image_sizes, update_path
from birl.utilities.dataset import IMAGE_EXTENSIONS, generate_pairing
from birl.benchmark import ImRegBenchmark
from birl.utilities.data_io import image_sizes, update_path
from birl.utilities.dataset import generate_pairing, IMAGE_EXTENSIONS

DATASET_IMAGES = '/datagrid/Medical/dataset_ANHIR/images_private'
DATASET_LANDMARKS = '/datagrid/Medical/dataset_ANHIR/landmarks_all'
Expand Down
2 changes: 1 addition & 1 deletion bm_dataset/convert_tiff2png.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
)

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.experiments import iterate_mproc_map, nb_workers
from birl.utilities.dataset import args_expand_parse_images
from birl.utilities.experiments import iterate_mproc_map, nb_workers

DEFAULT_LEVEL = 1
MAX_LOAD_IMAGE_SIZE = 16000
Expand Down
8 changes: 4 additions & 4 deletions bm_dataset/create_real_synth_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
print('No display found. Using non-interactive Agg backend')
matplotlib.use('Agg')

import tqdm
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import tqdm
from PIL import Image
from scipy import ndimage, stats, interpolate
import matplotlib.pyplot as plt
from scipy import interpolate, ndimage, stats

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.experiments import parse_arg_params, nb_workers
from birl.utilities.data_io import LANDMARK_COORDS
from birl.utilities.experiments import nb_workers, parse_arg_params

COLUMNS_COORD = LANDMARK_COORDS
NB_WORKERS = nb_workers(0.8)
Expand Down
8 changes: 6 additions & 2 deletions bm_dataset/crop_tissue_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.dataset import (
find_largest_object, project_object_edge, load_large_image, save_large_image, args_expand_parse_images
args_expand_parse_images,
find_largest_object,
load_large_image,
project_object_edge,
save_large_image,
)
from birl.utilities.experiments import iterate_mproc_map, try_decorator, nb_workers
from birl.utilities.experiments import iterate_mproc_map, nb_workers, try_decorator

NB_WORKERS = nb_workers(0.5)
SCALE_SIZE = 512
Expand Down
2 changes: 1 addition & 1 deletion bm_dataset/generate_regist_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import pandas as pd

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.benchmark import ImRegBenchmark
from birl.utilities.data_io import image_sizes
from birl.utilities.experiments import parse_arg_params
from birl.benchmark import ImRegBenchmark

# list of combination options
OPTIONS_COMBINE = ('first2all', 'each2all')
Expand Down
4 changes: 2 additions & 2 deletions bm_dataset/rescale_tissue_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import cv2 as cv

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.experiments import iterate_mproc_map, is_iterable, nb_workers
from birl.utilities.dataset import (load_large_image, save_large_image, parse_path_scale, args_expand_parse_images)
from birl.utilities.data_io import create_folder
from birl.utilities.dataset import args_expand_parse_images, load_large_image, parse_path_scale, save_large_image
from birl.utilities.experiments import is_iterable, iterate_mproc_map, nb_workers

NB_WORKERS = nb_workers(0.5)
DEFAULT_SCALES = (5, 10, 15, 20, 25, 50)
Expand Down
6 changes: 3 additions & 3 deletions bm_dataset/rescale_tissue_landmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
import pandas as pd

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.experiments import iterate_mproc_map, parse_arg_params, is_iterable
from birl.utilities.data_io import create_folder, load_landmarks_csv, save_landmarks_csv
from birl.utilities.dataset import (list_sub_folders, parse_path_scale, compute_bounding_polygon, inside_polygon)
from birl.utilities.dataset import compute_bounding_polygon, inside_polygon, list_sub_folders, parse_path_scale
from birl.utilities.experiments import is_iterable, iterate_mproc_map, parse_arg_params
from birl.utilities.registration import estimate_affine_transform, transform_points
from bm_dataset.rescale_tissue_images import NB_WORKERS, DEFAULT_SCALES, FOLDER_TEMPLATE
from bm_dataset.rescale_tissue_images import DEFAULT_SCALES, FOLDER_TEMPLATE, NB_WORKERS


def arg_parse_params():
Expand Down
6 changes: 5 additions & 1 deletion bm_dataset/split_images_two_tissues.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.dataset import (
find_split_objects, project_object_edge, load_large_image, save_large_image, args_expand_parse_images
args_expand_parse_images,
find_split_objects,
load_large_image,
project_object_edge,
save_large_image,
)
from birl.utilities.experiments import iterate_mproc_map, nb_workers

Expand Down
8 changes: 6 additions & 2 deletions bm_experiments/bm_ANTs.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@
import pandas as pd

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.benchmark import ImRegBenchmark
from birl.utilities.data_io import (
load_landmarks, save_landmarks, load_config_args, convert_image_to_nifti_gray, convert_image_from_nifti
convert_image_from_nifti,
convert_image_to_nifti_gray,
load_config_args,
load_landmarks,
save_landmarks,
)
from birl.utilities.experiments import exec_commands
from birl.benchmark import ImRegBenchmark
from bm_experiments import bm_comp_perform


Expand Down
10 changes: 7 additions & 3 deletions bm_experiments/bm_DROP.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@
import sys
import time

import SimpleITK as sitk
import numpy as np
import SimpleITK as sitk

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.benchmark import ImRegBenchmark
from birl.utilities.data_io import (
convert_image_to_mhd, convert_image_from_mhd, save_landmarks, load_landmarks, image_sizes
convert_image_from_mhd,
convert_image_to_mhd,
image_sizes,
load_landmarks,
save_landmarks,
)
from birl.benchmark import ImRegBenchmark
from bm_experiments import bm_comp_perform


Expand Down
4 changes: 2 additions & 2 deletions bm_experiments/bm_DROP2.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
import shutil
import sys

import SimpleITK as sitk
import numpy as np
import SimpleITK as sitk

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.data_io import save_landmarks, load_landmarks, load_config_args
from birl.utilities.data_io import load_config_args, load_landmarks, save_landmarks
from bm_experiments import bm_comp_perform
from bm_experiments.bm_DROP import BmDROP

Expand Down
4 changes: 2 additions & 2 deletions bm_experiments/bm_RVSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
import sys

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.data_io import load_landmarks, save_landmarks, load_config_yaml
from birl.utilities.experiments import exec_commands, dict_deep_update
from birl.benchmark import ImRegBenchmark
from birl.utilities.data_io import load_config_yaml, load_landmarks, save_landmarks
from birl.utilities.experiments import dict_deep_update, exec_commands
from bm_experiments import bm_comp_perform
from bm_experiments.bm_bUnwarpJ import BmUnwarpJ

Expand Down
4 changes: 2 additions & 2 deletions bm_experiments/bm_bUnwarpJ.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
import sys

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.data_io import update_path, load_landmarks, save_landmarks, load_config_yaml
from birl.utilities.experiments import exec_commands, dict_deep_update
from birl.benchmark import ImRegBenchmark
from birl.utilities.data_io import load_config_yaml, load_landmarks, save_landmarks, update_path
from birl.utilities.experiments import dict_deep_update, exec_commands
from bm_experiments import bm_comp_perform


Expand Down
9 changes: 5 additions & 4 deletions bm_experiments/bm_comp_perform.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@

matplotlib.use('Agg')
import numpy as np
from skimage import data, io, __version__ as skimage__version
from skimage.transform import resize, warp, AffineTransform
from skimage import __version__ as skimage__version
from skimage import data, io
from skimage.color import rgb2gray
from skimage.feature import match_descriptors, ORB
from skimage.measure import ransac
from skimage.util import random_noise
from skimage.restoration import denoise_bilateral, denoise_wavelet
from skimage.feature import ORB, match_descriptors
from skimage.transform import AffineTransform, resize, warp
from skimage.util import random_noise

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.experiments import computer_info
Expand Down
2 changes: 1 addition & 1 deletion bm_experiments/bm_elastix.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
import pandas as pd

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.benchmark import ImRegBenchmark
from birl.utilities.data_io import load_landmarks, save_landmarks, save_landmarks_pts
from birl.utilities.experiments import exec_commands
from birl.benchmark import ImRegBenchmark
from bm_experiments import bm_comp_perform


Expand Down
2 changes: 1 addition & 1 deletion bm_experiments/bm_rNiftyReg.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
import sys

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.data_io import load_landmarks, save_landmarks
from birl.benchmark import ImRegBenchmark
from birl.utilities.data_io import load_landmarks, save_landmarks
from bm_experiments import bm_comp_perform


Expand Down
4 changes: 2 additions & 2 deletions bm_experiments/evaluate_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import pandas as pd

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
from birl.utilities.experiments import iterate_mproc_map, parse_arg_params, nb_workers
from birl.benchmark import ImRegBenchmark, export_summary_results
from birl.benchmark import export_summary_results, ImRegBenchmark
from birl.utilities.experiments import iterate_mproc_map, nb_workers, parse_arg_params

#: default number of used threads
NB_WORKERS = nb_workers(0.75)
Expand Down
2 changes: 1 addition & 1 deletion scripts/Python/run_SimpleElastix.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import os
import sys

import SimpleITK as sitk
import numpy as np
import SimpleITK as sitk
from PIL import Image


Expand Down
Loading

0 comments on commit 80eea24

Please sign in to comment.