niftynet.layer.layer_util module¶
-
niftynet.layer.layer_util.
check_spatial_dims
(input_tensor, criteria)¶ valid each of the spatial dims against criteria criteria can be a lambda function e.g. lambda x : x > 10 checks whether each dim is greater than 10
-
niftynet.layer.layer_util.
expand_spatial_params
(input_param, spatial_rank)¶ expand input parameter e.g., kernel_size=3 is converted to kernel_size=[3, 3, 3] for 3D images
-
niftynet.layer.layer_util.
infer_spatial_rank
(input_tensor)¶ e.g. given an input tensor [Batch, X, Y, Z, Feature] the spatial rank is 3
-
niftynet.layer.layer_util.
trivial_kernel
(kernel_shape)¶ This function generates a trivial kernel with all 0s except for the element in its spatial center e.g. trivial_kernel((3, 3, 1, 1,)) returns a kernel of [[[[0]], [[0]], [[0]]],
[[[0]], [[1]], [[0]]], [[[0]], [[0]], [[0]]]]kernel_shape[-1] and kernel_shape[-2] should be 1, so that it operates on the spatial dims only. However, there is no exact spatial centre if np.any((kernel_shape % 2) == 0). This is fine in many cases as np.sum(trivial_kernel(kernel_shape)) == 1