def run_preprocessing(self, num_threads):
     if os.path.isdir(join(self.preprocessed_output_folder, "gt_segmentations")):
         shutil.rmtree(join(self.preprocessed_output_folder, "gt_segmentations"))
     shutil.copytree(join(self.folder_with_cropped_data, "gt_segmentations"), join(self.preprocessed_output_folder,
                                                                                   "gt_segmentations"))
     normalization_schemes = self.plans['normalization_schemes']
     use_nonzero_mask_for_normalization = self.plans['use_mask_for_norm']
     intensityproperties = self.plans['dataset_properties']['intensityproperties']
     preprocessor = PreprocessorFor2D(normalization_schemes, use_nonzero_mask_for_normalization, self.transpose_forward,
                                        intensityproperties)
     target_spacings = [i["current_spacing"] for i in self.plans_per_stage.values()]
     preprocessor.run(target_spacings, self.folder_with_cropped_data, self.preprocessed_output_folder,
                      self.plans['data_identifier'], num_threads)
Esempio n. 2
0
    def preprocess_patient(self, input_files):
        """
        Used to predict new unseen data. Not used for the preprocessing of the training/test data
        :param input_files:
        :return:
        """
        from nnunet.preprocessing.preprocessing import GenericPreprocessor, PreprocessorFor2D
        if self.threeD:
            preprocessor = GenericPreprocessor(self.normalization_schemes, self.use_mask_for_norm,
                                               self.intensity_properties)
        else:
            preprocessor = PreprocessorFor2D(self.normalization_schemes, self.use_mask_for_norm,
                                             self.intensity_properties)

        d, s, properties = preprocessor.preprocess_test_case(input_files,
                                                             self.plans['plans_per_stage'][self.stage]['current_spacing'])
        return d, s, properties