This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dice_loss(pred, target): | |
"""This definition generalize to real valued pred and target vector. | |
This should be differentiable. | |
pred: tensor with first dimension as batch | |
target: tensor with first dimension as batch | |
""" | |
smooth = 1. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SimpleITK as sitk | |
import matplotlib.pyplot as plt | |
from neverfault.resample import resample_new | |
import numpy as np | |
def test(im): | |
""" Use Simple ITK to random deform (elastic deform) an 2D image. Can be easily | |
used for 3D. There are two ways of elastic deforming an image. One is to define | |
a sparse control points, and use B-Spline to interpolate the deformation field. | |
Another is to directly define the deformation field. For data augmentation purpose, |