niftynet.layer.layer_util module¶
-
check_spatial_dims
(input_tensor, criteria)[source]¶ 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
-
infer_spatial_rank
(input_tensor)[source]¶ e.g. given an input tensor [Batch, X, Y, Z, Feature] the spatial rank is 3
-
trivial_kernel
(kernel_shape)[source]¶ 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