code: def check_image_is_3d(img):
      
  
      if len(img.shape) < 3:
          raise ValueError('Input volume must be atleast 3D!')
      elif len(img.shape) == 3:
          for dim_size in img.shape:
              if dim_size < 1:
                  raise ValueError('Atleast one slice must exist in each dimension')
      elif len(img.shape) == 4:
          if img.shape[3] != 1:
              raise ValueError('Input volume is 4D with more than one volume!')
          else:
              img = np.squeeze(img, axis=3)
      elif len(img.shape) > 4:
          raise ValueError('Invalid shape of image : {}'.format(img.shape))
  
      return img
docs: Ensures the image loaded is 3d and nothing else.