code: def test_init_2d_mo_bidimcsv(self):
      reader = get_2d_reader()
      sampler = ResizeSampler(
          reader=reader,
          window_sizes=MOD_2D_DATA,
          batch_size=1,
          shuffle=False,
          queue_length=50,
      )
      aggregator = WindowAsImageAggregator(
          image_reader=reader,
          output_path=os.path.join(
              "testing_data", "aggregated_identity"
          ),
      )
      more_batch = True
      out_shape = []
      with self.cached_session() as sess:
          sampler.set_num_threads(2)
          while more_batch:
              try:
                  out = sess.run(sampler.pop_batch_op())
                  out_shape = out["image"].shape[1:] + (1,)
              except tf.errors.OutOfRangeError:
                  break
              min_val = np.sum((np.asarray(out["image"]).flatten()))
              stats_val = [
                  np.min(out["image"]),
                  np.max(out["image"]),
                  np.sum(out["image"]),
              ]
              stats_val = np.expand_dims(stats_val, 0)
              stats_val = np.concatenate([stats_val, stats_val], axis=0)
              more_batch = aggregator.decode_batch(
                  {
                      "window_image": out["image"],
                      "csv_sum": min_val,
                      "csv_stats2d": stats_val,
                  },
                  out["image_location"],
              )
      output_filename = (
          "{}_window_image_niftynet_generated.nii.gz".format(
              sampler.reader.get_subject_id(0)
          )
      )
      sum_filename = os.path.join(
          "testing_data",
          "aggregated_identity",
          "{}_csv_sum_niftynet_generated.csv".format(
              sampler.reader.get_subject_id(0)
          ),
      )
      stats_filename = os.path.join(
          "testing_data",
          "aggregated_identity",
          "{}_csv_stats2d_niftynet_generated.csv".format(
              sampler.reader.get_subject_id(0)
          ),
      )
      output_file = os.path.join(
          "testing_data", "aggregated_identity", output_filename
      )
  
      out_shape = [out_shape[i] for i in NEW_ORDER_2D] + [
          1,
      ]
      self.assertAllClose(nib.load(output_file).shape, out_shape[:2])
      min_pd = pd.read_csv(sum_filename)
      self.assertAllClose(min_pd.shape, [1, 2])
      stats_pd = pd.read_csv(stats_filename)
      self.assertAllClose(stats_pd.shape, [1, 7])
      sampler.close_all()
  
imports: from __future__ import absolute_import, division, print_function
  import os
  import nibabel
  import tensorflow
  import pandas
  import numpy
  from niftynet.engine.sampler_resize_v2 import ResizeSampler
  from niftynet.engine.windows_aggregator_identity import WindowAsImageAggregator
  from niftynet.io.image_reader import ImageReader
  from niftynet.io.image_sets_partitioner import ImageSetsPartitioner
  from niftynet.layer.discrete_label_normalisation import DiscreteLabelNormalisationLayer
  from niftynet.layer.pad import PadLayer
  from niftynet.utilities.util_common import ParserNamespace
  from tests.niftynet_testcase import NiftyNetTestCase
label_desc: Use image node_id 9 for calling the IdentityAggregatorTest obj's underlying member method code with example usage: obj.test_init_2d_mo_bidimcsv() without return types