-
Notifications
You must be signed in to change notification settings - Fork 1
/
UpdateRawMaskOverlayConfigs.py
35 lines (24 loc) · 1.32 KB
/
UpdateRawMaskOverlayConfigs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import configparser
import shutil
from configparser import ConfigParser
import os
def UpdateRawMaskOverlayConfigs():
config: ConfigParser = configparser.ConfigParser()
config.read("config.ini")
output_directory = config["Settings"]["output_directory"]
config["CrackSegmentation"]["mask_directory"] = output_directory + "/crackmask"
config["CrackSegmentation"]["mask_dir_Message"] = "mask_directory is auto-generated."
config["StainSegmentation"]["mask_directory"] = output_directory + "/stainmask"
config["StainSegmentation"]["mask_dir_Message"] = "mask_directory is auto-generated."
config["CrackOverlay"]["overlay_directory"] = output_directory + "/crackoverlay/images"
config["CrackOverlay"]["overlay_dir_Message"] = "overlay_directory is auto-generated."
config["StainOverlay"]["overlay_directory"] = output_directory + "/stainoverlay/images"
config["StainOverlay"]["overlay_dir_Message"] = "overlay_directory is auto-generated."
# Write the updated config file
with open("config.ini", "w") as configfile:
config.write(configfile)
# Copy the config.ini file to the run directory
config_file = os.path.join("config.ini")
if os.path.exists(config_file):
shutil.copy(config_file, os.path.join(output_directory, "updated_config.ini"))
UpdateRawMaskOverlayConfigs()