|
|
|
|
|
from light_training.preprocessing.preprocessors.default_preprocessor_liver_2017 import DefaultPreprocessor |
|
|
import numpy as np |
|
|
import pickle |
|
|
import json |
|
|
|
|
|
|
|
|
def process_train(): |
|
|
|
|
|
|
|
|
base_dir = "/home/xingzhaohu/data/Liver_2017" |
|
|
|
|
|
preprocessor = DefaultPreprocessor(base_dir=base_dir) |
|
|
|
|
|
out_spacing = [1.0, 0.76757812, 0.76757812] |
|
|
output_dir = "./data/fullres/train/" |
|
|
|
|
|
with open("./data_analysis_result.txt", "r") as f: |
|
|
content = f.read().strip("\n") |
|
|
print(content) |
|
|
content = eval(content) |
|
|
foreground_intensity_properties_per_channel = content["intensity_statistics_per_channel"] |
|
|
|
|
|
preprocessor.run(output_spacing=out_spacing, |
|
|
output_dir=output_dir, |
|
|
all_labels=[1, 2], |
|
|
num_processes=16, |
|
|
foreground_intensity_properties_per_channel=foreground_intensity_properties_per_channel) |
|
|
|
|
|
def process_val(): |
|
|
|
|
|
|
|
|
base_dir = "./data/raw_data/Val" |
|
|
image_dir = "img" |
|
|
preprocessor = DefaultPreprocessor(base_dir=base_dir, |
|
|
image_dir=image_dir, |
|
|
label_dir=None, |
|
|
) |
|
|
|
|
|
out_spacing = [0.5, 0.70410156, 0.70410156] |
|
|
|
|
|
with open("./data_analysis_result.txt", "r") as f: |
|
|
content = f.read().strip("\n") |
|
|
print(content) |
|
|
content = eval(content) |
|
|
foreground_intensity_properties_per_channel = content["intensity_statistics_per_channel"] |
|
|
|
|
|
output_dir = "./data/fullres/val_test/" |
|
|
preprocessor.run(output_spacing=out_spacing, |
|
|
output_dir=output_dir, |
|
|
all_labels=[1, ], |
|
|
foreground_intensity_properties_per_channel=foreground_intensity_properties_per_channel, |
|
|
num_processes=16) |
|
|
|
|
|
def process_val_semi(): |
|
|
|
|
|
|
|
|
base_dir = "./data/raw_data/Val_semi_postprocess" |
|
|
image_dir = "img" |
|
|
preprocessor = DefaultPreprocessor(base_dir=base_dir, |
|
|
image_dir=image_dir, |
|
|
label_dir="gt", |
|
|
) |
|
|
|
|
|
out_spacing = [0.5, 0.70410156, 0.70410156] |
|
|
|
|
|
with open("./data_analysis_result.txt", "r") as f: |
|
|
content = f.read().strip("\n") |
|
|
print(content) |
|
|
content = eval(content) |
|
|
foreground_intensity_properties_per_channel = content["intensity_statistics_per_channel"] |
|
|
|
|
|
output_dir = "./data/fullres/val_semi_postprocess/" |
|
|
preprocessor.run(output_spacing=out_spacing, |
|
|
output_dir=output_dir, |
|
|
all_labels=[1, ], |
|
|
foreground_intensity_properties_per_channel=foreground_intensity_properties_per_channel) |
|
|
|
|
|
|
|
|
def plan(): |
|
|
base_dir = "/home/xingzhaohu/data/Liver_2017" |
|
|
|
|
|
preprocessor = DefaultPreprocessor(base_dir=base_dir, |
|
|
|
|
|
) |
|
|
|
|
|
preprocessor.run_plan() |
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|
|
|
|
|
|
|
|
process_train() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|