code: def load_scans_BRATS15(pat_folder, with_seg=False):
      # Get path to nii files for a patient
      VSD_id = None
      nii_folders = [
          f_name
          for f_name in os.listdir(pat_folder)
          if f_name.startswith("VSD")
      ]
      nii_paths = []
      for nii_folder in nii_folders:
          nii_path = os.path.join(pat_folder, nii_folder)
          nii_fn = [
              f_n
              for f_n in os.listdir(nii_path)
              if f_n.endswith((".mha")) and f_n.startswith("VSD")
          ]
          assert len(nii_fn) == 1
          nii_path = os.path.join(nii_path, nii_fn[0])
          nii_paths.append(nii_path)
          # Get VSD id (compulsory for online evaluation)
          if "Flair" in nii_fn[0]:
              VSD_id = nii_fn[0].split(".")[-2]
              print("VSD ID: %s" % VSD_id)
      assert VSD_id is not None
      # Load data
      img_data = []
      for mod_n in mod_names15:
          file_n = [f_n for f_n in nii_paths if (mod_n + ".") in f_n][0]
          # mod_data = nibabel.load(os.path.join(pat_folder, file_n)).get_data()
          mod_data = sitk.ReadImage(
              os.path.join(pat_folder, file_n), sitk.sitkFloat32
          )
          mod_data = sitk.GetArrayFromImage(mod_data)
          img_data.append(mod_data)
      img_data = np.stack(img_data, axis=-1)
      if not with_seg:
          return img_data, None, VSD_id
      else:
          file_n_list = [f_n for f_n in nii_paths if ("OT.") in f_n]
          if len(file_n_list) != 0:
              file_n = file_n_list[0]
              # seg_data = nibabel.load(os.path.join(pat_folder, file_n)).get_data()
              seg_data = sitk.ReadImage(
                  os.path.join(pat_folder, file_n), sitk.sitkFloat32
              )
              seg_data = sitk.GetArrayFromImage(seg_data)
          else:
              seg_data = None
          return img_data, seg_data, VSD_id
  
file_path: NiftyNet/demos/BRATS17/rename_crop_BRATS.py
imports: import os
  import SimpleITK
  import nibabel
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: load_scans_BRATS15(pat_folder, with_seg) and returns: img_data,  None,  VSD_id, img_data,  seg_data,  VSD_id