Helper Module for Deep Learning.
Common functions to transform image. Code: https://github.com/fepegar/torchio
-
pynet.augmentation.spatial.affine(arr, rotation=10, translation=10, zoom=0.2, order=3, dist='uniform', seed=None)[source]¶ Random affine transformation.
The affine translation & rotation parameters are drawn from a lognormal distribution - small movements are assumed to occur more often and large movements less frequently - or from a uniform distribution.
- Parameters
arr: array
the input data.
rotation: float or 2-uplet, default 10
the rotation in degrees of the simulated movements. Larger values generate more distorted images.
translation: float or 2-uplet, default 10
the translation in voxel of the simulated movements. Larger values generate more distorted images.
zoom: float, default 0.2
the zooming magnitude. Larger values generate more distorted images.
order: int, default 3
the order of the spline interpolation in the range [0, 5].
dist: str, default ‘uniform’
the sampling distribution: ‘uniform’ or ‘lognormal’.
seed: int, default None
seed to control random number generator.
- Returns
transformed: array
the transformed input data.
-
pynet.augmentation.spatial.deformation(arr, max_displacement=4, alpha=3, order=3, seed=None)[source]¶ Apply dense random elastic deformation.
Reference: Khanal B, Ayache N, Pennec X., Simulating Longitudinal Brain MRIs with Known Volume Changes and Realistic Variations in Image Intensity, Front Neurosci, 2017.
- Parameters
arr: array
the input data.
max_displacement: float, default 4
the maximum displacement in voxel along each dimension. Larger values generate more distorted images.
alpha: float, default 3
the power of the power-law momentum distribution. Larger values genrate smoother fields.
order: int, default 3
the order of the spline interpolation in the range [0, 5].
seed: int, default None
seed to control random number generator.
- Returns
transformed: array
the transformed input data.
-
pynet.augmentation.spatial.flip(arr, axis=None, seed=None)[source]¶ Apply a random mirror flip.
- Parameters
arr: array
the input data.
axis: int, default None
apply flip on the specified axis. If not specified, randomize the flip axis.
seed: int, default None
seed to control random number generator.
- Returns
transformed: array
the transformed input data.
-
pynet.augmentation.spatial.random_generator(interval, size, dist='uniform', seed=None)[source]¶ Random varaible generator.
- Parameters
interval: 2-uplet
the possible values of the generated random variable.
size: uplet
the number of random variables to be drawn from the sampling distribution.
dist: str, default ‘uniform’
the sampling distribution: ‘uniform’ or ‘lognormal’.
seed: int, default None
seed to control random number generator.
- Returns
random_variables: array
the generated random variable.
Follow us
Inspired by AZMIND template.