docstr: Split filenames and write the image names and label names on train.txt, val.txt or test.txt.
  Set the valset to 20% of images if all files need to be used in training.
  
  Args:
  txt(string): the path to the txt file, for example: "data/train.txt"
  image_files(list|tuple): the list of image names.
  label_files(list|tuple): the list of label names, order is corresponding with the image_files.
  split(float|int): Percentage of the dataset used in training
docstr_tok: ["Split","filenames","and","write","the","image","names","and","label","names","on","train.txt",",","val.txt","or","test.txt",".","Set","the","valset","to","20","%","of","images","if","all","files","need","to","be","used","in","training",".","Args",":","txt","(","string",")",":","the","path","to","the","txt","file",",","for","example",":","``","data\/train.txt","''","image_files","(","list|tuple",")",":","the","list","of","image","names",".","label_files","(","list|tuple",")",":","the","list","of","label","names",",","order","is","corresponding","with","the","image_files",".","split","(","float|int",")",":","Percentage","of","the","dataset","used","in","training"]
code: def split_files_txt(
      self, txt, image_files, label_files=None, split=None
  ):
      """
      Split filenames and write the image names and label names on train.txt, val.txt or test.txt.
      Set the valset to 20% of images if all files need to be used in training.
  
      Args:
      txt(string): the path to the txt file, for example: "data/train.txt"
      image_files(list|tuple): the list of image names.
      label_files(list|tuple): the list of label names, order is corresponding with the image_files.
      split(float|int): Percentage of the dataset used in training
  
      """
      if split is None:
          if label_files is None:  # testset don't have
              split = len(image_files)
          else:
              split = int(0.8 * len(image_files))
      elif split <= 1:
          split = int(split * len(image_files))
      elif split > 1:
          raise RuntimeError(
              "Only have {} images but required {} images in trainset"
          )
  
      if "train" in txt:
          image_names = image_files[:split]
          label_names = label_files[:split]
      elif "val" in txt:
          # set the valset to 20% of images if all files need to be used in training
          if split == len(image_files):
              valsplit = int(0.8 * len(image_files))
              image_names = image_files[valsplit:]
              label_names = label_files[valsplit:]
          else:
              image_names = image_files[split:]
              label_names = label_files[split:]
      elif "test" in txt:
          self.write_txt(txt, image_files[:split])
  
          return
      else:
          raise NotImplementedError(
              "The txt split except for train.txt, val.txt and test.txt is not implemented yet."
          )
  
      self.write_txt(txt, image_names, label_names)
  
imports: import os
  import os.path
  import sys
  import time
  import glob
  import numpy
  import nibabel
  import SimpleITK
  from tqdm import tqdm
  import json
  from medicalseg.utils import get_image_list
  from tools.preprocess_utils import uncompressor, global_var, add_qform_sform, join_paths
label_desc: Use image node_id 9 for calling the Prep obj's underlying member method code with example usage: obj.split_files_txt(txt, image_files, label_files, split) without return types