code: def __getitem__(self, idx):
      if self.phase == "train":
          # read image and labels
          ith_info = self.img_list[idx].split(" ")
          img_name = os.path.join(self.root_dir, ith_info[0])
          label_name = os.path.join(self.root_dir, ith_info[1])
          assert os.path.isfile(img_name)
          assert os.path.isfile(label_name)
          img = nibabel.load(
              img_name
          )  # We have transposed the data from WHD format to DHW
          assert img is not None
          mask = nibabel.load(label_name)
          assert mask is not None
  
          # data processing
          img_array, mask_array = self.__training_data_process__(
              img, mask
          )
  
          # 2 tensor array
          img_array = self.__nii2tensorarray__(img_array)
          mask_array = self.__nii2tensorarray__(mask_array)
  
          assert (
              img_array.shape == mask_array.shape
          ), "img shape:{} is not equal to mask shape:{}".format(
              img_array.shape, mask_array.shape
          )
          return img_array, mask_array
  
      elif self.phase == "test":
          # read image
          ith_info = self.img_list[idx].split(" ")
          img_name = os.path.join(self.root_dir, ith_info[0])
          print(img_name)
          assert os.path.isfile(img_name)
          img = nibabel.load(img_name)
          assert img is not None
  
          # data processing
          img_array = self.__testing_data_process__(img)
  
          # 2 tensor array
          img_array = self.__nii2tensorarray__(img_array)
  
          return img_array
  
file_path: MedicalNet/datasets/brains18.py
imports: import math
  import os
  import random
  import numpy
  from torch.utils.data import Dataset
  import nibabel
  from scipy import ndimage
label_desc: Use image node_id 4 for calling the BrainS18Dataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: img_array,  mask_array, img_array