docstr: Create proprosessor for medical dataset.
  Folder structure:
      dataset_root
      ├── raw_dataset_dir
      │   ├── image_dir
      │   ├── labels_dir  
      │   ├── images_dir_test       
      ├── phase_dir
      │   ├── images
      │   ├── labels
      │   ├── train_list.txt
      │   └── val_list.txt
      ├── archive_1.zip
      ├── archive_2.zip
      └── ... archives ...
  Args:
      urls (dict): Urls to download dataset archive. Key will be used as archive name.
      valid_suffix(tuple):  Only files with the assigned suffix will be considered. The first is the suffix for image, and the other is for label.
      filter_key(tuple): Only files containing the filter_key the will be considered.
docstr_tok: ["Create","proprosessor","for","medical","dataset",".","Folder","structure",":","dataset_root","\u251c\u2500\u2500","raw_dataset_dir","\u2502","\u251c\u2500\u2500","image_dir","\u2502","\u251c\u2500\u2500","labels_dir","\u2502","\u251c\u2500\u2500","images_dir_test","\u251c\u2500\u2500","phase_dir","\u2502","\u251c\u2500\u2500","images","\u2502","\u251c\u2500\u2500","labels","\u2502","\u251c\u2500\u2500","train_list.txt","\u2502","\u2514\u2500\u2500","val_list.txt","\u251c\u2500\u2500","archive_1.zip","\u251c\u2500\u2500","archive_2.zip","\u2514\u2500\u2500","...","archives","...","Args",":","urls","(","dict",")",":","Urls","to","download","dataset","archive",".","Key","will","be","used","as","archive","name",".","valid_suffix","(","tuple",")",":","Only","files","with","the","assigned","suffix","will","be","considered",".","The","first","is","the","suffix","for","image",",","and","the","other","is","for","label",".","filter_key","(","tuple",")",":","Only","files","containing","the","filter_key","the","will","be","considered","."]
code: def __init__(
      self,
      dataset_root="data/TemDataSet",
      raw_dataset_dir="TemDataSet_seg_raw/",
      images_dir="train_imgs",
      labels_dir="train_labels",
      phase_dir="phase0",
      urls=None,
      valid_suffix=("nii.gz", "nii.gz"),
      filter_key=(None, None),
      uncompress_params={"format": "zip", "num_files": 1},
      images_dir_test="",
  ):
      """
      Create proprosessor for medical dataset.
      Folder structure:
          dataset_root
          ├── raw_dataset_dir
          │   ├── image_dir
          │   ├── labels_dir
          │   ├── images_dir_test
          ├── phase_dir
          │   ├── images
          │   ├── labels
          │   ├── train_list.txt
          │   └── val_list.txt
          ├── archive_1.zip
          ├── archive_2.zip
          └── ... archives ...
      Args:
          urls (dict): Urls to download dataset archive. Key will be used as archive name.
          valid_suffix(tuple):  Only files with the assigned suffix will be considered. The first is the suffix for image, and the other is for label.
          filter_key(tuple): Only files containing the filter_key the will be considered.
      """
      # combine all paths
      self.dataset_root = dataset_root
      self.phase_path = join_paths(self.dataset_root, phase_dir)
      self.raw_data_path = join_paths(
          self.dataset_root, raw_dataset_dir
      )
      self.dataset_json_path = join_paths(
          self.raw_data_path, "dataset.json"
      )  # save the dataset.json to raw path
      self.image_path = join_paths(self.phase_path, "images")
      self.label_path = join_paths(self.phase_path, "labels")
      os.makedirs(self.dataset_root, exist_ok=True)
      os.makedirs(self.phase_path, exist_ok=True)
      os.makedirs(self.image_path, exist_ok=True)
      os.makedirs(self.label_path, exist_ok=True)
      self.gpu_tag = "GPU" if global_var.get_value("USE_GPU") else "CPU"
      self.urls = urls
  
      if osp.exists(self.raw_data_path):
          print(
              f"raw_dataset_dir {self.raw_data_path} exists, skipping uncompress. To uncompress again, remove this directory"
          )
      else:
          self.uncompress_file(
              num_files=uncompress_params["num_files"],
              form=uncompress_params["format"],
          )
  
      self.image_files_test = None
      if (
          len(images_dir_test) != 0
      ):  # test image filter is the same as training image
          self.image_files_test = get_image_list(
              join_paths(self.raw_data_path, images_dir_test),
              valid_suffix[0],
              filter_key[0],
          )
          self.image_files_test.sort()
          self.image_path_test = join_paths(
              self.phase_path, "images_test"
          )
          os.makedirs(self.image_path_test, exist_ok=True)
  
      # Load the needed file with filter
      if isinstance(images_dir, tuple):
          self.image_files = []
          self.label_files = []
          for i in range(len(images_dir)):
              self.image_files += get_image_list(
                  join_paths(self.raw_data_path, images_dir[i]),
                  valid_suffix[0],
                  filter_key[0],
              )
              self.label_files += get_image_list(
                  join_paths(self.raw_data_path, labels_dir[i]),
                  valid_suffix[1],
                  filter_key[1],
              )
      else:
          self.image_files = get_image_list(
              join_paths(self.raw_data_path, images_dir),
              valid_suffix[0],
              filter_key[0],
          )
          self.label_files = get_image_list(
              join_paths(self.raw_data_path, labels_dir),
              valid_suffix[1],
              filter_key[1],
          )
  
      self.image_files.sort()
      self.label_files.sort()
  
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 1 to create a new Prep object  with example: obj = Prep(dataset_root, raw_dataset_dir, images_dir, labels_dir, phase_dir, urls, valid_suffix, filter_key, uncompress_params, images_dir_test)