Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
script: pre-commit run --all-files
- name: "Sphinx Build"
script:
- cd docs
- make clean html
- cd docs
- make clean html
- stage: "Tests"
name: "Unit Tests"
script: pytest --cov-report= --cov=deepreg ./test/unit/
after_success: bash <(curl -s https://codecov.io/bash)
- name: "Command Tests: Unpaired Unlabeled"
script:
- deepreg_train -g "" --config_path deepreg/config/unpaired_labeled_ddf.yaml --log_dir test
- deepreg_train -g "" --config_path config/unpaired_labeled_ddf.yaml --log_dir test
- deepreg_predict -g "" --ckpt_path logs/test/save/weights-epoch2.ckpt --mode test
- deepreg_warp --image data/test/nifti/unit_test/moving_image.nii.gz --ddf data/test/nifti/unit_test/ddf.nii.gz --out logs/test_warp/out.nii.gz
- name: "Output Tests: Paired Unlabeled"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion deepreg/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import numpy as np
import tensorflow as tf

import deepreg.config.parser as config_parser
import deepreg.model.layer_util as layer_util
import deepreg.model.optimizer as opt
import deepreg.parser as config_parser
from deepreg.dataset.loader.util import normalize_array
from deepreg.model.network.build import build_model
from deepreg.util import (
Expand Down
2 changes: 1 addition & 1 deletion deepreg/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import tensorflow as tf

import deepreg.config.parser as config_parser
import deepreg.model.optimizer as opt
import deepreg.parser as config_parser
from deepreg.model.network.build import build_model
from deepreg.util import build_dataset, build_log_dir

Expand Down
5 changes: 0 additions & 5 deletions demos/classical_ct_headneck_affine/demo_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
learning_rate = 0.01
total_iter = int(1000)


## load image
if not os.path.exists(DATA_PATH):
raise ("Download the data using demo_data.py script")
Expand Down Expand Up @@ -89,12 +88,10 @@ def train_step(grid, weights, optimizer, mov, fix):
if (step % 50) == 0: # print info
tf.print("Step", step, image_loss_name, loss_opt)


## warp the moving image using the optimised affine transformation
grid_opt = layer_util.warp_grid(grid_ref, var_affine)
warped_moving_image = layer_util.resample(vol=moving_image, loc=grid_opt)


## warp the moving labels using the optimised affine transformation
warped_moving_labels = tf.stack(
[
Expand All @@ -104,7 +101,6 @@ def train_step(grid, weights, optimizer, mov, fix):
axis=4,
)


## save output to files
SAVE_PATH = "output_" + datetime.now().strftime("%Y%m%d-%H%M%S")
os.mkdir(SAVE_PATH)
Expand Down Expand Up @@ -137,5 +133,4 @@ def train_step(grid, weights, optimizer, mov, fix):
gray=True,
)


os.chdir(MAIN_PATH)
2 changes: 0 additions & 2 deletions demos/classical_mr_prostate_nonrigid/demo_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def train_step(warper, weights, optimizer, mov, fix):
loss_deform_opt,
)


# warp the moving image using the optimised ddf
warped_moving_image = warping(inputs=[var_ddf, moving_image])

Expand Down Expand Up @@ -127,5 +126,4 @@ def train_step(warper, weights, optimizer, mov, fix):
save_dir=SAVE_PATH, arr=arr, name=arr_name, gray=True, save_png=False
)


os.chdir(MAIN_PATH)
2 changes: 0 additions & 2 deletions demos/grouped_mask_prostate_longitudinal/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

print("\nMask data downloaded: %s." % os.path.abspath(DATA_PATH))


## now read the data and convert to train/val/test
ratio_val = 0.1
ratio_test = 0.2
Expand Down Expand Up @@ -98,7 +97,6 @@

print("Done. \n")


## now download the pre-trained model
MODEL_PATH = os.path.join(DATA_PATH, "pre-trained")
if os.path.exists(MODEL_PATH):
Expand Down
3 changes: 0 additions & 3 deletions demos/paired_ct_lung/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

print("The file ", fname, " has successfully been downloaded!")


data_folder_name = "data"

if os.path.exists(os.path.join(main_path, project_dir, data_folder_name)) is not True:
Expand Down Expand Up @@ -84,7 +83,6 @@ def moveFilesIntoCorrectPath(


if os.path.exists(path_to_images_and_labels):

moveFilesIntoCorrectPath(
images_fnames, path_to_images_and_labels, path_to_train, "images", "scans"
)
Expand Down Expand Up @@ -228,7 +226,6 @@ def moveTestCasesIntoCorrectPath(test_cases, path_to_train, path_to_test):
)
nib.save(img, os.path.join(data_dir, folder, subfolder, file))


######## DOWNLOAD MODEL CKPT FROM MODEL ZOO ########

url = "https://github.com/DeepRegNet/deepreg-model-zoo/raw/master/paired_ct_lung_demo_logs.zip"
Expand Down
1 change: 0 additions & 1 deletion demos/paired_ct_lung/demo_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
path_to_moving_image = os.path.join(path_to_test, "pair_0", "moving_image")
path_to_moving_label = os.path.join(path_to_test, "pair_0", "label_0", "moving_label")


# change inds_to_plot if different images need to be plotted instead

inds_to_plot = [144, 145, 184, 140, 150, 180]
Expand Down
2 changes: 0 additions & 2 deletions demos/paired_mrus_prostate/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

print("\nMR and ultrasound data downloaded: %s." % os.path.abspath(DATA_PATH))


## now split the data in to num_part partitions
num_part = 11

Expand Down Expand Up @@ -62,7 +61,6 @@

print("All data are partitioned into %d folders." % num_part)


## now download the pre-trained model
MODEL_PATH = os.path.join(DATA_PATH, "pre-trained")
if os.path.exists(MODEL_PATH):
Expand Down
1 change: 0 additions & 1 deletion demos/unpaired_ct_abdomen/demo_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
by following the instructions in readme.md"
)


"""
from deepreg.train import train

Expand Down
3 changes: 0 additions & 3 deletions demos/unpaired_ct_lung/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@

get_file(os.path.join(os.getcwd(), fname), url)


print("The file ", fname, " has successfully been downloaded!")


data_folder_name = "data"

if os.path.exists(os.path.join(main_path, project_dir, data_folder_name)) is not True:
Expand Down Expand Up @@ -88,7 +86,6 @@ def moveFilesIntoCorrectPath(


if os.path.exists(path_to_images_and_labels):

moveFilesIntoCorrectPath(
images_fnames, path_to_images_and_labels, path_to_train, "images", "scans"
)
Expand Down
1 change: 0 additions & 1 deletion demos/unpaired_ct_lung/demo_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
path_to_moving_image = os.path.join(path_to_test, pair_n, "moving_image")
path_to_moving_label = os.path.join(path_to_test, pair_n, "label_0", "moving_label")


# change inds_to_plot if different images need to be plotted instead

inds_to_plot = [20, 60, 100, 140, 160, 200]
Expand Down
1 change: 0 additions & 1 deletion demos/unpaired_mr_brain/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@

print("Files succesfully copied to " + path_to_train + " and " + path_to_test)


#################
# Preprocessing #
#################
Expand Down
1 change: 0 additions & 1 deletion demos/unpaired_mr_brain/demo_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

os.environ["CUDA_VISIBLE_DEVICES"] = "0"


gpu = "0"
gpu_allow_growth = False
ckpt_path = "" # To load pre-trained weights
Expand Down
1 change: 0 additions & 1 deletion demos/unpaired_us_prostate_cv/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
with zipfile.ZipFile(ZIP_PATH, "r") as zf:
zf.extractall()


if os.path.exists(DATA_PATH):
shutil.rmtree(DATA_PATH)
shutil.move(DATA_REPO, DATA_PATH)
Expand Down
Loading