class_docstr: This class keeps record of the currently cached image,
  initialised as all zeros, and the values are replaced
  by image window data decoded from batch.
class_docstr_tok: ["This","class","keeps","record","of","the","currently","cached","image",",","initialised","as","all","zeros",",","and","the","values","are","replaced","by","image","window","data","decoded","from","batch","."]
docstr: Function used to save multiple outputs listed in the window
  dictionary. For the fields that have the keyword 'window' in the
  dictionary key, it will be saved as image. The rest will be saved as
  csv. CSV files will contain at saving a first line of 0 (to be
  changed into the header by the user), the first column being the
  index of the window, followed by the list of output and the location
  array for each considered window
  
  :param window: dictionary of output
  :param location: location of the input
  :return:
docstr_tok: ["Function","used","to","save","multiple","outputs","listed","in","the","window","dictionary",".","For","the","fields","that","have","the","keyword","'window","'","in","the","dictionary","key",",","it","will","be","saved","as","image",".","The","rest","will","be","saved","as","csv",".","CSV","files","will","contain","at","saving","a","first","line","of","0","(","to","be","changed","into","the","header","by","the","user",")",",","the","first","column","being","the","index","of","the","window",",","followed","by","the","list","of","output","and","the","location","array","for","each","considered","window",":","param","window",":","dictionary","of","output",":","param","location",":","location","of","the","input",":","return",":"]
code: def decode_batch(self, window, location):
      """
      Function used to save multiple outputs listed in the window
      dictionary. For the fields that have the keyword 'window' in the
      dictionary key, it will be saved as image. The rest will be saved as
      csv. CSV files will contain at saving a first line of 0 (to be
      changed into the header by the user), the first column being the
      index of the window, followed by the list of output and the location
      array for each considered window
  
      :param window: dictionary of output
      :param location: location of the input
      :return:
      """
      n_samples = location.shape[0]
      location_cropped = {}
      for key in window:
          if (
              "window" in key
          ):  # all outputs to be created as images should
              # contained the keyword "window"
              window[key], location_cropped[key] = self.crop_batch(
                  window[key], location, self.window_border
              )
  
      for batch_id in range(n_samples):
          image_id = location[batch_id, 0]
          if image_id != self.image_id:
              # image name changed:
              # save current result and create an empty result file
              self._save_current_image()
              self._save_current_csv()
              if self._is_stopping_signal(location[batch_id]):
                  return False
  
              self.image_out, self.csv_out = {}, {}
              for key in window:
                  if "window" in key:
                      # to be saved as image
                      self.image_out[
                          key
                      ] = self._initialise_empty_image(
                          image_id=image_id,
                          n_channels=window[key].shape[-1],
                          dtype=window[key].dtype,
                      )
                  else:
                      # to be saved as csv file
                      n_elements = np.int64(
                          np.asarray(window[key]).size / n_samples
                      )
                      table_header = (
                          [
                              "{}_{}".format(key, idx)
                              for idx in range(n_elements)
                          ]
                          if n_elements > 1
                          else ["{}".format(key)]
                      )
                      table_header += [
                          "coord_{}".format(idx)
                          for idx in range(location.shape[-1])
                      ]
                      self.csv_out[key] = self._initialise_empty_csv(
                          key_names=table_header
                      )
  
          for key in window:
              if "window" in key:
                  (
                      x_start,
                      y_start,
                      z_start,
                      x_end,
                      y_end,
                      z_end,
                  ) = location_cropped[key][batch_id, 1:]
                  self.image_out[key][
                      x_start:x_end, y_start:y_end, z_start:z_end, ...
                  ] = window[key][batch_id, ...]
              else:
                  window[key] = np.asarray(window[key]).reshape(
                      [n_samples, -1]
                  )
                  window_save = window[key][batch_id : batch_id + 1, :]
                  window_loc = location[batch_id : batch_id + 1, :]
                  csv_row = np.concatenate([window_save, window_loc], 1)
                  csv_row = csv_row.ravel()
                  key_names = self.csv_out[key].columns
                  self.csv_out[key] = self.csv_out[key].append(
                      OrderedDict(zip(key_names, csv_row)),
                      ignore_index=True,
                  )
      return True
  
file_path: NiftyNet/niftynet/engine/windows_aggregator_grid.py
imports: from __future__ import absolute_import, division, print_function
  import os
  from collections import OrderedDict
  import numpy
  import pandas
  import niftynet.io.misc_io
  from niftynet.engine.windows_aggregator_base import ImageWindowsAggregator
  from niftynet.layer.discrete_label_normalisation import DiscreteLabelNormalisationLayer
  from niftynet.layer.pad import PadLayer
label_desc: Use image node_id 2 for calling the GridSamplesAggregator obj's underlying member method code with example usage: obj.decode_batch(window, location) and returns: True, False