code: def verify_dataset_integrity(
      folder,
      data_json="dataset.json",
      train_images_dir="imagesTr",
      train_labels_dir="labelsTr",
      test_images_dir="imagesTs",
      default_num_threads=8,
  ):
      assert os.path.isfile(
          join_paths(folder, data_json)
      ), "There needs to be a {} file in folder {}, but not found.".format(
          data_json, folder
      )
      assert os.path.isdir(
          join_paths(folder, train_images_dir)
      ), "There needs to be a {} subfolder in folder {}, but not found.".format(
          train_images_dir, folder
      )
      assert os.path.isdir(
          join_paths(folder, train_labels_dir)
      ), "There needs to be a {} subfolder in folder {}, but not found.".format(
          train_labels_dir, folder
      )
  
      with open(join_paths(folder, data_json), "r") as f:
          dataset = json.load(f)
      training_cases = dataset["training"]
      num_modalities = len(dataset["modality"].keys())
      test_cases = dataset["test"]
      expected_train_identifiers = [
          i["image"].split("/")[-1].split(".")[0]
          for i in training_cases
      ]
      expected_test_identifiers = [
          i.split("/")[-1].split(".")[0] for i in test_cases
      ]
      expected_labels = list(int(i) for i in dataset["labels"].keys())
  
      # check training dataset orientation
      all_same, unique_orientations = verify_all_same_orientation(
          join_paths(folder, train_images_dir)
      )
      assert (
          all_same
      ), "Not all images in the dataset have the same axis ordering. Please correct that by reorienting the data."
  
      # check duplicate label
      assert len(expected_train_identifiers) == len(
          np.unique(expected_train_identifiers)
      ), "Found duplicate training labels in {}, please check your dataset.".format(
          data_json
      )
      verify_training_dataset(
          folder,
          num_modalities,
          expected_train_identifiers,
          expected_labels,
          train_images_dir=train_images_dir,
          train_labels_dir=train_labels_dir,
          default_num_threads=default_num_threads,
      )
  
      # check test set, but only if there actually is a test set
      if len(expected_test_identifiers) > 0:
          verify_test_dataset(
              folder,
              num_modalities,
              expected_test_identifiers,
              test_images_dir=test_images_dir,
          )
  
file_path: PaddleSeg/contrib/MedicalSeg/tools/preprocess_utils/integrity_checks.py
imports: import os
  import json
  import numpy
  import SimpleITK
  import nibabel
  from multiprocessing import Pool
  from .load_image import load_series
  from .path_utils import join_paths
label_desc: Use image node_id 7 for calling a global function with example usage: verify_dataset_integrity(folder, data_json, train_images_dir, train_labels_dir, test_images_dir, default_num_threads) without return types