class_docstr: computing 1d convolution one each spatial dimension of the input
  using one-dimensional filter.
class_docstr_tok: ["computing","1d","convolution","one","each","spatial","dimension","of","the","input","using","one-dimensional","filter","."]
docstr: :param image: in shape `(batch, x[, y, z], feature_channels)`
  :return: spatially smoothed image
docstr_tok: [":","param","image",":","in","shape","`","(","batch",",","x","[",",","y",",","z","]",",","feature_channels",")","`",":","return",":","spatially","smoothed","image"]
code: def layer_op(self, image):
      """
  
      :param image: in shape `(batch, x[, y, z], feature_channels)`
      :return: spatially smoothed image
      """
      spatial_rank = infer_spatial_rank(image)
      _sigmas = expand_spatial_params(
          input_param=self.sigma,
          spatial_rank=spatial_rank,
          param_type=float,
      )
      _truncate = expand_spatial_params(
          input_param=self.truncate,
          spatial_rank=spatial_rank,
          param_type=float,
      )
      if not all(_sigmas):
          # return the original image if any sigma is zero
          return image
  
      def do_conv(input_tensor, dim):
          assert dim < spatial_rank
          if dim < 0:
              return input_tensor
  
          # squeeze the kernel to be along the 'dim'
          new_kernel_shape = [1] * (spatial_rank + 2)
          new_kernel_shape[dim] = -1
          kernel_tensor = self.kernel_func(
              sigma=_sigmas[dim], truncated=_truncate[dim]
          )
          kernel_tensor = tf.reshape(kernel_tensor, new_kernel_shape)
  
          # split channels and do smoothing respectively
          chn_wise_list = tf.unstack(
              do_conv(input_tensor, dim - 1), axis=-1
          )
          output_tensor = [
              tf.nn.convolution(
                  input=tf.expand_dims(chn, axis=-1),
                  filter=kernel_tensor,
                  padding="SAME",
                  strides=[1] * spatial_rank,
              )
              for chn in chn_wise_list
          ]
          return tf.concat(output_tensor, axis=-1)
  
      return do_conv(image, spatial_rank - 1)
  
file_path: NiftyNet/niftynet/layer/approximated_smoothing.py
imports: from __future__ import absolute_import, print_function, division
  import tensorflow
  from niftynet.layer.base_layer import Layer
  from niftynet.layer.layer_util import expand_spatial_params, infer_spatial_rank
  from niftynet.utilities.util_common import look_up_operations
label_desc: Use image node_id 2 for calling the SmoothingLayer obj's underlying member method code with example usage: obj.layer_op(image) and returns: do_conv, image, tf, input_tensor