code: def test_filling(self):
      reader = get_nonnormalising_label_reader()
      test_constant = 0.5731
      postfix = "_niftynet_out_background"
      test_border = (10, 7, 8)
      data_param = MOD_LABEL_DATA
      sampler = GridSampler(
          reader=reader,
          window_sizes=data_param,
          batch_size=10,
          spatial_window_size=None,
          window_border=test_border,
          queue_length=50,
      )
      aggregator = GridSamplesAggregator(
          image_reader=reader,
          name="label",
          output_path=os.path.join("testing_data", "aggregated"),
          window_border=test_border,
          interp_order=0,
          postfix=postfix,
          fill_constant=test_constant,
      )
      more_batch = True
      with self.cached_session() as sess:
          sampler.set_num_threads(2)
          while more_batch:
              out = sess.run(sampler.pop_batch_op())
              more_batch = aggregator.decode_batch(
                  {"window_label": out["label"]}, out["label_location"]
              )
      output_filename = "window_label_{}_{}.nii.gz".format(
          sampler.reader.get_subject_id(0), postfix
      )
      output_file = os.path.join(
          "testing_data", "aggregated", output_filename
      )
      output_data = nib.load(output_file).get_data()
      output_shape = output_data.shape
      for i in range(3):
  
          def _test_background(idcs):
              extract = output_data[idcs]
              self.assertTrue(
                  (extract == test_constant).sum() == extract.size
              )
  
          extract_idcs = [slice(None)] * 3
  
          extract_idcs[i] = slice(0, test_border[i])
          _test_background(tuple(extract_idcs))
  
          extract_idcs[i] = slice(
              output_shape[i] - test_border[i], output_shape[i]
          )
          _test_background(tuple(extract_idcs))
  
imports: from __future__ import absolute_import, division, print_function
  import os
  import nibabel
  import tensorflow
  import numpy
  import pandas
  from niftynet.engine.sampler_grid_v2 import GridSampler
  from niftynet.engine.windows_aggregator_grid import GridSamplesAggregator
  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 12 for calling the GridSamplesAggregatorTest obj's underlying member method code with example usage: obj.test_filling() without return types