Entry Point¶
Train¶
Module to train a network using init files and a CLI
-
deepreg.train.
build_callbacks
(log_dir: str, histogram_freq: int, save_period: int) → list¶ Function to prepare callbacks for training.
- Parameters
log_dir – directory of logs
histogram_freq – save the histogram every X epochs
save_period – save the checkpoint every X epochs
- Returns
a list of callbacks
-
deepreg.train.
build_config
(config_path: (<class 'str'>, <class 'list'>), log_root: str, log_dir: str, ckpt_path: str) → [<class ‘dict’>, <class ‘str’>]¶ Function to initialise log directories, assert that checkpointed model is the right type and to parse the configuration for training
- Parameters
config_path – list of str, path to config file
log_root – str, root of logs
log_dir – str, path to where training logs to be stored.
ckpt_path – str, path where model is stored.
- Returns
config: a dictionary saving configuration
log_dir: the path of directory to save logs
-
deepreg.train.
main
(args=None)¶ Entry point for train script
-
deepreg.train.
train
(gpu: str, config_path: (<class 'str'>, <class 'list'>), gpu_allow_growth: bool, ckpt_path: str, log_dir: str, log_root: str = 'logs')¶ Function to train a model
- Parameters
gpu – str, which local gpu to use to train
config_path – str, path to configuration set up
gpu_allow_growth – bool, whether or not to allocate whole GPU memory to training
ckpt_path – str, where to store training checkpoints
log_root – str, root of logs
log_dir – str, where to store logs in training
Predict¶
Module to perform predictions on data using command line interface
-
deepreg.predict.
build_config
(config_path: (<class 'str'>, <class 'list'>), log_root: str, log_dir: str, ckpt_path: str) → [<class ‘dict’>, <class ‘str’>]¶ Function to create new directory to log directory to store results.
- Parameters
config_path – string or list of strings, path of configuration files
log_root – str, root of logs
log_dir – string, path to store logs.
ckpt_path – str, path where model is stored.
- Returns
config, configuration dictionary
log_dir, path of the directory for saving outputs
-
deepreg.predict.
build_pair_output_path
(indices: list, save_dir: str) -> (<class 'str'>, <class 'str'>)¶ Create directory for saving the paired data
- Parameters
indices – indices of the pair, the last one is for label
save_dir – directory of output
- Returns
save_dir, str, directory for saving the moving/fixed image
label_dir, str, directory for saving the rest outputs
-
deepreg.predict.
main
(args=None)¶ Function to run in command line with argparse to predict results on data for a given model
-
deepreg.predict.
predict
(gpu: str, gpu_allow_growth: bool, ckpt_path: str, mode: str, batch_size: int, log_dir: str, sample_label: str, config_path: (<class 'str'>, <class 'list'>), save_nifti: bool = True, save_png: bool = True, log_root: str = 'logs')¶ Function to predict some metrics from the saved model and logging results.
- Parameters
gpu – str, which env gpu to use.
gpu_allow_growth – bool, whether to allow gpu growth or not
ckpt_path – str, where model is stored, should be like log_folder/save/xxx.ckpt
mode – train / valid / test, to define which split of dataset to be evaluated
batch_size – int, batch size to perform predictions in
log_dir – str, path to store logs
sample_label – sample/all, not used
save_nifti – if true, outputs will be saved in nifti format
save_png – if true, outputs will be saved in png format
config_path – to overwrite the default config
-
deepreg.predict.
predict_on_dataset
(dataset: tensorflow.data.Dataset, fixed_grid_ref: tensorflow.Tensor, model: tensorflow.keras.Model, model_method: str, save_dir: str, save_nifti: bool, save_png: bool)¶ Function to predict results from a dataset from some model
- Parameters
dataset – where data is stored
fixed_grid_ref – shape=(1, f_dim1, f_dim2, f_dim3, 3)
model – model to be used for prediction
model_method – str, ddf / dvf / affine / conditional
save_dir – str, path to store dir
save_nifti – if true, outputs will be saved in nifti format
save_png – if true, outputs will be saved in png format
Warp¶
Module to warp a image with given ddf. A CLI tool is provided.
-
deepreg.warp.
main
(args=None)¶ Entry point for warp script
-
deepreg.warp.
warp
(image_path: str, ddf_path: str, out_path: str)¶ - Parameters
image_path – file path of the image file
ddf_path – file path of the ddf file
out_path – file path of the output