class_docstr: Image windows are retrieved and analysed by the
  tensorflow graph, this windows aggregator receives
  output window data in numpy array. To access image-level
  information the reader is needed.
class_docstr_tok: ["Image","windows","are","retrieved","and","analysed","by","the","tensorflow","graph",",","this","windows","aggregator","receives","output","window","data","in","numpy","array",".","To","access","image-level","information","the","reader","is","needed","."]
docstr: This utility function removes two borders along each
  spatial dim of the output image window data,
  adjusts window spatial coordinates accordingly.
  
  :param window:
  :param location:
  :param border:
  :return:
docstr_tok: ["This","utility","function","removes","two","borders","along","each","spatial","dim","of","the","output","image","window","data",",","adjusts","window","spatial","coordinates","accordingly",".",":","param","window",":",":","param","location",":",":","param","border",":",":","return",":"]
code: def crop_batch(window, location, border=None):
      """
      This utility function removes two borders along each
      spatial dim of the output image window data,
      adjusts window spatial coordinates accordingly.
  
      :param window:
      :param location:
      :param border:
      :return:
      """
      if not border:
          return window, location
      assert isinstance(
          border, (list, tuple)
      ), "border should be a list or tuple"
      while len(border) < N_SPATIAL:
          border = tuple(border) + (border[-1],)
      border = border[:N_SPATIAL]
  
      location = location.astype(np.int)
      window_shape = window.shape
      spatial_shape = window_shape[1:-1]
      n_spatial = len(spatial_shape)
      for idx in range(n_spatial):
          location[:, idx + 1] = location[:, idx + 1] + border[idx]
          location[:, idx + 4] = location[:, idx + 4] - border[idx]
      if np.any(location < 0):
          return window, location
  
      cropped_shape = np.max(
          location[:, 4:7] - location[:, 1:4], axis=0
      )
      left = np.floor(
          (spatial_shape - cropped_shape[:n_spatial]) / 2.0
      ).astype(np.int)
      if np.any(left < 0):
          tf.logging.fatal(
              "network output window can be "
              "cropped by specifying the border parameter in config file, "
              "but here the output window content size %s is smaller "
              "than the window coordinate size: %s -- "
              "computed by input window size minus border size (%s)"
              "not supported by this aggregator. Please try larger border.)",
              spatial_shape,
              cropped_shape,
              border,
          )
          raise ValueError
      if n_spatial == 1:
          window = window[
              :,
              left[0] : (left[0] + cropped_shape[0]),
              np.newaxis,
              np.newaxis,
              ...,
          ]
      elif n_spatial == 2:
          window = window[
              :,
              left[0] : (left[0] + cropped_shape[0]),
              left[1] : (left[1] + cropped_shape[1]),
              np.newaxis,
              ...,
          ]
      elif n_spatial == 3:
          window = window[
              :,
              left[0] : (left[0] + cropped_shape[0]),
              left[1] : (left[1] + cropped_shape[1]),
              left[2] : (left[2] + cropped_shape[2]),
              ...,
          ]
      else:
          tf.logging.fatal(
              "unknown output format: shape %s" " spatial dims are: %s",
              window_shape,
              spatial_shape,
          )
          raise NotImplementedError
      return window, location
  
file_path: NiftyNet/niftynet/engine/windows_aggregator_base.py
imports: from __future__ import absolute_import, print_function, division
  import os
  import numpy
  import tensorflow
  from niftynet.engine.image_window import N_SPATIAL
label_desc: Use image node_id 7 for calling the ImageWindowsAggregator obj's underlying member method code with example usage: obj.crop_batch(window, location, border) and returns: window,  location, window,  location, window,  location