code: def load_scans_BRATS17(pat_folder, with_seg=False):
      nii_fnames = [
          f_name
          for f_name in os.listdir(pat_folder)
          if f_name.endswith((".nii", ".nii.gz"))
      ]
      img_data = []
      for mod_n in mod_names17:
          file_n = [f_n for f_n in nii_fnames if (mod_n + ".") in f_n][
              0
          ]
          mod_data = nibabel.load(
              os.path.join(pat_folder, file_n)
          ).get_data()
          img_data.append(mod_data)
      img_data = np.stack(img_data, axis=-1)
      if not with_seg:
          return img_data, None
      else:
          file_n = [f_n for f_n in nii_fnames if ("seg.") in f_n][0]
          seg_data = nibabel.load(
              os.path.join(pat_folder, file_n)
          ).get_data()
          return img_data, seg_data
  
file_path: NiftyNet/demos/BRATS17/rename_crop_BRATS.py
imports: import os
  import SimpleITK
  import nibabel
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: load_scans_BRATS17(pat_folder, with_seg) and returns: img_data,  None, img_data,  seg_data