-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py.template
160 lines (142 loc) · 6.79 KB
/
settings.py.template
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# -*- coding: utf-8 -*-
""" settings """
import os
from monai import transforms as ts
from gtorch_utils.constants import DB
from gtorch_utils.datasets.segmentation.datasets.lits17.constants import LiTS17DBConfig
###############################################################################
# GENERAL CONFIG #
###############################################################################
BASE_PATH = os.getenv("HOME")
PROJECT_PATH = os.path.join(BASE_PATH, '<path to your project>')
###############################################################################
# ct82 #
###############################################################################
# NOTE: update the following line to reflect the locations of the datasets (created or to be created)
# set it to PROJECT_PATH if the datasets are or will be in the project root directory
CT82_SAVING_PATH = os.path.join(os.sep, '<path to your project>')
CT82_NEW_DB_NAME = 'CT-82-Pro' # processed CT82 dataset name
CT82_SIZE = (368, 368, -1) # [height, width, scans]
CT82_CROP_SHAPE = (32, 80, 80) # [scans, heigh, width]
CT82_NUM_CROPS = 1 # 2
CT82_TRANSFORMS = {
'train': ts.Compose([
ts.ToTensord(keys=['img', 'mask']),
ts.CropForegroundd(keys=['img', 'mask'], source_key='img', select_fn=lambda x: x > 0),
ts.RandAxisFlipd(keys=['img', 'mask'], prob=.5),
ts.RandAffined(
keys=['img', 'mask'],
prob=1.,
rotate_range=0.261799, # 15 degrees
translate_range=[0*CT82_SIZE[2], 0.1*CT82_SIZE[0], 0.1*CT82_SIZE[1]],
scale_range=((-0.3, 0.3), (-0.3, 0.3), (-0.3, 0.3)),
mode=["bilinear", "nearest"]
),
ts.RandCropByPosNegLabeld(
keys=['img', 'mask'],
label_key='mask',
spatial_size=CT82_CROP_SHAPE,
pos=.5, # .5,
neg=.5, # .5,
num_samples=CT82_NUM_CROPS,
),
]),
'valtest': ts.Compose([
ts.ToTensord(keys=['img', 'mask']),
ts.CropForegroundd(keys=['img', 'mask'], source_key='img', select_fn=lambda x: x > 0),
ts.RandCropByPosNegLabeld(
keys=['img', 'mask'],
label_key='mask',
spatial_size=CT82_CROP_SHAPE,
pos=1, # .5,
neg=0, # .5,
num_samples=CT82_NUM_CROPS,
),
])
}
CT82_NEW_DB_PATH = os.path.join(CT82_SAVING_PATH, CT82_NEW_DB_NAME)
# Don't mofify the suffixes DB.TRAIN, DB.VALIDATION and DB.TEST
CT82_TRAIN_PATH = os.path.join(CT82_NEW_DB_PATH, DB.TRAIN)
CT82_VAL_PATH = os.path.join(CT82_NEW_DB_PATH, DB.VALIDATION)
CT82_TEST_PATH = os.path.join(CT82_NEW_DB_PATH, DB.TEST)
###############################################################################
# LiTS17 #
###############################################################################
# NOTE: update the following line to reflect the locations of the datasets (created or to be created)
# set it to PROJECT_PATH if the datasets are or will be in the project root directory
LITS17_SAVING_PATH = os.path.join(os.sep, '<path to your project>')
LITS17_CONFIG = LiTS17DBConfig.LIVER # This variable is utilised on other modules
if LITS17_CONFIG == LiTS17DBConfig.LIVER:
# LITS17 Liver 1 32x80x80-crops dataset #######################################
LITS17_NEW_DB_NAME = 'LiTS17Liver-Pro' # processed lits17 liver dataset name
LITS17_SIZE = (368, 368, -1) # [height, width, scans]
LITS17_CROP_SHAPE = (32, 80, 80) # [scans, heigh, width]
LITS17_NUM_CROPS = 1
LITS17_TRANSFORMS = {
'train': ts.Compose([
ts.ToTensord(keys=['img', 'mask']),
ts.CropForegroundd(keys=['img', 'mask'], source_key='img', select_fn=lambda x: x > .5),
ts.RandAxisFlipd(keys=['img', 'mask'], prob=.5),
ts.RandAffined(
keys=['img', 'mask'],
prob=1.,
rotate_range=0.261799, # 15 degrees
# translate_range=[0.1*LITS17_SIZE[2], 0.1*LITS17_SIZE[0], 0.1*LITS17_SIZE[1]],
translate_range=[0*LITS17_SIZE[2], 0.1*LITS17_SIZE[0], 0.1*LITS17_SIZE[1]],
scale_range=((-0.3, 0.3), (-0.3, 0.3), (-0.3, 0.3)),
# scale_range=((-0.3, 0), (-0.3, 0), (-0.3, 0))
mode=["bilinear", "nearest"]
),
ts.RandCropByLabelClassesd(
keys=['img', 'mask'],
label_key='mask',
spatial_size=LITS17_CROP_SHAPE,
ratios=[.5, .5], # [0, 1],
num_classes=2,
num_samples=LITS17_NUM_CROPS,
image_key='img', # 'mask',
image_threshold=0.38, # 0,
),
]),
'valtest': ts.Compose([
ts.ToTensord(keys=['img', 'mask']),
ts.CropForegroundd(keys=['img', 'mask'], source_key='img', select_fn=lambda x: x > .5),
ts.RandCropByLabelClassesd(
keys=['img', 'mask'],
label_key='mask',
spatial_size=LITS17_CROP_SHAPE,
ratios=[0, 1],
num_classes=2,
num_samples=LITS17_NUM_CROPS,
image_key='mask',
image_threshold=0,
),
])
}
LITS17_NEW_DB_PATH = os.path.join(LITS17_SAVING_PATH, LITS17_NEW_DB_NAME)
# Don't mofify the suffixes DB.TRAIN, DB.VALIDATION and DB.TEST
LITS17_TRAIN_PATH = os.path.join(LITS17_NEW_DB_PATH, DB.TRAIN)
LITS17_VAL_PATH = os.path.join(LITS17_NEW_DB_PATH, DB.VALIDATION)
LITS17_TEST_PATH = os.path.join(LITS17_NEW_DB_PATH, DB.TEST)
else:
# LITS17 Lesion 16 32x160x160-crops dataset ###################################
LITS17_NEW_DB_NAME = 'LiTS17Lesion-Pro' # processed lits17 lesion dataset name
LITS17_NEW_CROP_DB_NAME = 'LiTS17Lesion-Pro-16PositiveCrops32x160x160' # crop lits17 lesion dataset name
LITS17_SIZE = (368, 368, -2) # [height, width, scans]
LITS17_CROP_SHAPE = (32, 160, 160)
LITS17_NUM_CROPS = 16
LITS17_TRANSFORMS = {
'train': ts.Compose([
ts.ToTensord(keys=['img', 'mask']),
ts.RandAxisFlipd(keys=['img', 'mask'], prob=.5),
]),
'valtest': ts.Compose([
ts.ToTensord(keys=['img', 'mask']),
])
}
LITS17_NEW_DB_PATH = os.path.join(LITS17_SAVING_PATH, LITS17_NEW_DB_NAME)
LITS17_NEW_CROP_DB_PATH = os.path.join(LITS17_SAVING_PATH, LITS17_NEW_CROP_DB_NAME)
# Don't mofify the suffixes DB.TRAIN, DB.VALIDATION and DB.TEST
LITS17_TRAIN_PATH = os.path.join(LITS17_NEW_CROP_DB_PATH, DB.TRAIN)
LITS17_VAL_PATH = os.path.join(LITS17_NEW_CROP_DB_PATH, DB.VALIDATION)
LITS17_TEST_PATH = os.path.join(LITS17_NEW_CROP_DB_PATH, DB.TEST)