code: def check_input_folder_and_return_caseIDs(
      input_folder, expected_num_modalities
  ):
      print(
          "This model expects {} input modalities for each image.".format(
              expected_num_modalities
          )
      )
      files = [
          file
          for file in os.listdir(input_folder)
          if os.path.isfile(os.path.join(input_folder, file))
          and file.endswith(".nii.gz")
      ]
      files.sort()
      maybe_case_ids = np.unique([i[:-12] for i in files])
  
      remaining = deepcopy(files)
      missing = []
      assert (
          len(files) > 0
      ), "input folder did not contain any images (expected to find .nii.gz file endings)"
  
      for c in maybe_case_ids:
          for n in range(expected_num_modalities):
              expected_output_file = c + "_%04.0d.nii.gz" % n
              if not os.path.isfile(
                  os.path.join(input_folder, expected_output_file)
              ):
                  missing.append(expected_output_file)
              else:
                  remaining.remove(expected_output_file)
      print(
          "Found {} unique case ids, here are some examples: ".format(
              len(maybe_case_ids)
          ),
          np.random.choice(
              maybe_case_ids, min(len(maybe_case_ids), 10)
          ),
      )
      print(
          "If they don't look right, make sure to double check your filenames. They must end with _0000.nii.gz etc"
      )
  
      if len(remaining) > 0:
          print(
              "found {} unexpected remaining files in the folder. Here are some examples:".format(
                  len(remaining)
              ),
              np.random.choice(remaining, min(len(remaining), 10)),
          )
      if len(missing) > 0:
          print("Some files are missing:")
          print(missing)
          raise RuntimeError("missing files in input_folder")
      return maybe_case_ids
  
file_path: PaddleSeg/contrib/MedicalSeg/nnunet/predict.py
imports: import argparse
  import os
  import sys
  import pickle
  import shutil
  import numpy
  from copy import deepcopy
  from medicalseg.models import NNUNet
  from nnunet.utils import predict_cases, MultiFoldsPredictor
label_desc: Use image node_id 2 for calling a global function with example usage: check_input_folder_and_return_caseIDs(input_folder, expected_num_modalities) and returns: maybe_case_ids