code: def __check_label_image(label_image):
      
      encountered_indices = scipy.unique(label_image)
      expected_indices = scipy.arange(1, label_image.max() + 1)
      if not encountered_indices.size == expected_indices.size or \
         not (encountered_indices == expected_indices).all():
          raise AttributeError('The supplied label image does either not contain any regions or they are not labeled consecutively starting from 1.')
docs: Check the label image for consistent labelling starting from 1.