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
-
expand_spatial_params
(input_param, spatial_rank, param_type=<type 'int'>)[source]¶ Expand input parameter e.g.,
kernel_size=3
is converted tokernel_size=[3, 3, 3]
for 3D images (whenspatial_rank == 3
).
-
check_divisible_channels
(input_tensor, n_channel_splits)[source]¶ Check if the number of channels (last dim) of the input tensor is divisible by
n_channel_splits
. If True, returnsn_input_channels / n_channel_splits
, raises AssertionError otherwiseParameters: - input_tensor –
- n_channel_splits –
Returns: n_input_channels / n_channel_splits