Skip to content

Instantly share code, notes, and snippets.

2020-10-29 7:15:17.47: =============================== logger created =======================================
2020-10-29 7:15:17.47:
2020-10-29 7:15:17.47: ======================== Starting new session ============================
2020-10-29 7:15:17.47: Command line arguments given:
Namespace(device='cuda', model_cfg='./outputs/dm_e1/holdout_0/0/modelConfig.cfg', reset_trainer=False, saved_model=None, test_cfg=None, train_cfg='./outputs/dm_e1/holdout_0/0/trainConfig.cfg')
2020-10-29 7:15:18.08: Available devices to Tensorflow:
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
import os
import numpy as np
folds = [5,5]
exp_path = "./outputs/resunet_e1_new/"
avg_dice = []
for holdout in os.listdir(os.path.join(exp_path)):
for fold in os.listdir(os.path.join(exp_path,holdout)):
if not ".pkl" in fold:
for item in os.listdir(os.path.join(exp_path,holdout,fold)):
if "stdout" in item:
# Choose the segmentation model here
# options: unet, resunet, fcn
model:
{
architecture: resunet,
final_layer: softmax
}
# Set base filters: number of filters present in the initial module of the U-Net convolution; for IncU-Net, keep this divisible by 4
base_filters: 30
# Set the list of labels the model should train on and predict
import SimpleITK as sitk
# read image
inputImage = sitk.ReadImage('/path/to/input.nii.gz')
# get result in the form of a numpy array
npa_res = my_algorithm(sitk.GetArrayFromImage(inputImage)) # my_algorithm does something fancy
# Converting back to SimpleITK (assumes we didn't move the image in space as we copy the information from the original)
result_image = sitk.GetImageFromArray(npa_res)