code: def test_images2d(self):
      reader = ImageReader(["image"])
  
      # COLOR IMAGES
      reader.initialise(
          IMAGE_2D_DATA, IMAGE_2D_TASK_COLOR, image2d_data_list
      )
  
      idx, data, interp_order = reader()
      image = data["image"]
      # Check index
      self.assertGreaterEqual(idx, 0)
      self.assertLess(idx, 10)
      # Check data type
      self.assertGreaterEqual(image.min(), 0)
      self.assertLessEqual(image.max(), 255)
      self.assertEqual(image.dtype, np.float32)
      # Check shape
      self.assertEqual(image.ndim, 5)
      self.assertAllEqual(image.shape, (100, 100, 1, 1, 3))
      self.assertEqual(interp_order["image"], (1,))
  
      # GRAY IMAGES
      reader.initialise(
          IMAGE_2D_DATA, IMAGE_2D_TASK_GRAY, image2d_data_list
      )
  
      idx, data, interp_order = reader()
      image = data["image"]
  
      # Check index
      self.assertGreaterEqual(idx, 0)
      self.assertLess(idx, 10)
      # Check data type
      self.assertGreaterEqual(image.min(), 0)
      self.assertLessEqual(image.max(), 255)
      self.assertEqual(image.dtype, np.float32)
      # Check shape
      self.assertEqual(image.ndim, 5)
      self.assertAllEqual(image.shape, (100, 100, 1, 1, 1))
      self.assertEqual(interp_order["image"], (1,))
  
      gray_idx, gray_data, gray_order = reader(idx=5)
  
      # SEGMENTATION MASKS
      reader.initialise(
          IMAGE_2D_DATA, IMAGE_2D_TASK_MASK, image2d_data_list
      )
  
      idx, data, interp_order = reader()
      image = data["image"]
  
      # Check index
      self.assertGreaterEqual(idx, 0)
      self.assertLess(idx, 10)
      # Check data type
      self.assertGreaterEqual(image.min(), 0)
      self.assertLessEqual(image.max(), 255)
      self.assertEqual(image.dtype, np.float32)
      self.assertEqual(np.unique(image).size, 2)
      # Check shape
      self.assertEqual(image.ndim, 5)
      self.assertAllEqual(image.shape, (100, 100, 1, 1, 1))
      self.assertEqual(interp_order["image"], (0,))
  
      # Compare segmentation masks to thresholding original image
      mask_idx, mask_data, mask_order = reader(idx=5)
  
      gray_data = gray_data["image"]
      mask_data = mask_data["image"]
  
      self.assertEqual(gray_idx, mask_idx)
      self.assertEqual(gray_order["image"], (1,))
      self.assertEqual(mask_order["image"], (0,))
      self.assertAllEqual((gray_data > SEG_THRESHOLD) * 255, mask_data)
  
imports: from __future__ import absolute_import, print_function
  import os
  import numpy
  import tensorflow
  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.reader_modular_test import generate_2d_images, SEG_THRESHOLD
  from tests.niftynet_testcase import NiftyNetTestCase
label_desc: Use image node_id 9 for calling the ImageReaderTest obj's underlying member method code with example usage: obj.test_images2d() without return types