def load_save(self, mode='train'):
        """
        preprocess files, transfer to the correct type, and save it to the directory.
        """
        print(
            "Start convert {} images to numpy array using {}, please wait patiently"
            .format(mode, self.gpu_tag))

        tic = time.time()
        if mode == 'train':
            process_files = (self.train_image_files, self.train_label_files)
            target_files = (self.train_image_files_npy,
                            self.train_label_files_npy)
        else:
            process_files = (self.val_image_files, self.val_label_files)
            target_files = (self.val_image_files_npy, self.val_label_files_npy)
        process_tuple = ("images", "labels")

        save_tuple = (self.image_path, self.label_path)

        for i, files in enumerate(process_files):
            pre = self.preprocess[process_tuple[i]]
            savepath = save_tuple[i]

            for f in tqdm(
                    files,
                    total=len(files),
                    desc="preprocessing the {}".format(["images", "labels"][
                        i])):

                f_nps = Prep.load_medical_data(f)[0]
                # xyz to zxy
                f_nps = f_nps.transpose(2, 0, 1)
                if mode == 'train':
                    for volume_idx, f_np in enumerate(f_nps):
                        for op in pre:
                            f_np = op(f_np)
                        filename = osp.basename(f).split(".")[
                            0] + f"-{volume_idx:>04d}.npy"
                        f_np_name = join_paths(savepath, filename)
                        np.save(f_np_name, f_np)
                        target_files[i].append(filename)
                else:
                    for op in pre:
                        f_nps = op(f_nps)
                    filename = osp.basename(f).split(".")[0] + ".npy"
                    f_np_name = join_paths(savepath, filename)
                    np.save(f_np_name, f_nps)
                    target_files[i].append(filename)

        print("The preprocess time on {} is {}".format(self.gpu_tag,
                                                       time.time() - tic))

        preprocess files, transfer to the correct type, and save it to the directory.
        
contrib/MedicalSeg/tools/prepare_abdomen.py