|
a |
|
b/config.py |
|
|
1 |
|
|
|
2 |
""" |
|
|
3 |
|
|
|
4 |
The required configurations for training phase ('prepare_Data.py', 'train.py'). |
|
|
5 |
|
|
|
6 |
""" |
|
|
7 |
|
|
|
8 |
cfg = dict() |
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
""" |
|
|
13 |
The coordinates to crop brain volumes. For example, a brain volume with the |
|
|
14 |
One can set the x0,x1,... by calculating none zero pixels through dataset. |
|
|
15 |
Note that the final three shapes must be divisible by the network downscale rate. |
|
|
16 |
""" |
|
|
17 |
cfg['crop_coord'] = {'x0':42, 'x1':194, |
|
|
18 |
'y0':29, 'y1':221, |
|
|
19 |
'z0':2, 'z1':146} |
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
""" |
|
|
24 |
The path to all brain volumes (ex: suppose we have a folder 'MICCAI_BraTS_2019_Data_Training' |
|
|
25 |
that contains two HGG and LGG folders so: |
|
|
26 |
data_dir='./MICCAI_BraTS_2019_Data_Training/*/*') |
|
|
27 |
""" |
|
|
28 |
cfg['data_dir'] = '/path/to/data/' |
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
""" |
|
|
33 |
The final data shapes of saved table file. |
|
|
34 |
""" |
|
|
35 |
cfg['table_data_shape'] = (cfg["crop_coord"]['z1']-cfg["crop_coord"]['z0'], |
|
|
36 |
cfg["crop_coord"]['y1']-cfg["crop_coord"]['y0'], |
|
|
37 |
cfg["crop_coord"]['x1']-cfg["crop_coord"]['x0']) |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
""" |
|
|
42 |
BraTS datasets contain 4 channels: (FLAIR, T1, T1ce, T2) |
|
|
43 |
""" |
|
|
44 |
cfg['data_channels'] = 4 |
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
""" |
|
|
49 |
The path to save table file + k-fold files |
|
|
50 |
""" |
|
|
51 |
cfg['save_data_dir'] = './data/' |
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
""" |
|
|
56 |
The path to save models + log files + tensorboards |
|
|
57 |
""" |
|
|
58 |
cfg['save_dir'] = './save/' |
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
""" |
|
|
63 |
k-fold cross-validation |
|
|
64 |
""" |
|
|
65 |
cfg['k_fold'] = 5 |
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
""" |
|
|
70 |
The defualt path of saved table. |
|
|
71 |
""" |
|
|
72 |
cfg['hdf5_dir'] = './data/data.hdf5' |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
""" |
|
|
77 |
The path to brain indexes of specific fold (a numpy file that was saved in ./data/ by default) |
|
|
78 |
""" |
|
|
79 |
cfg['brains_idx_dir'] = './data/fold0_idx.npy' |
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
""" |
|
|
84 |
'axial', 'sagittal' or 'coronal'. The 'view' has no effect in "prepare_data.py". |
|
|
85 |
All 2D slices and the model will be prepared with respect to 'view'. |
|
|
86 |
""" |
|
|
87 |
cfg['view'] = 'axial' |
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
""" |
|
|
92 |
The batch size for training and validating the model |
|
|
93 |
""" |
|
|
94 |
cfg['batch_size'] = 16 |
|
|
95 |
cfg['val_batch_size'] = 32 |
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
""" |
|
|
100 |
The augmentation parameters. |
|
|
101 |
""" |
|
|
102 |
cfg['hor_flip'] = True |
|
|
103 |
cfg['ver_flip'] = True |
|
|
104 |
cfg['rotation_range'] = 0 |
|
|
105 |
cfg['zoom_range'] = 0. |
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
""" |
|
|
110 |
The leraning rate and the number of epochs for training the model |
|
|
111 |
""" |
|
|
112 |
cfg['epochs'] = 100 |
|
|
113 |
cfg['lr'] = 0.008 |
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
""" |
|
|
118 |
If True, use process-based threading. "https://keras.io/models/model/" |
|
|
119 |
""" |
|
|
120 |
cfg['multiprocessing'] = False |
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
""" |
|
|
125 |
Maximum number of processes to spin up when using process-based threading. |
|
|
126 |
If unspecified, workers will default to 1. If 0, will execute the generator |
|
|
127 |
on the main thread. "https://keras.io/models/model/" |
|
|
128 |
""" |
|
|
129 |
cfg['workers'] = 1 |
|
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
""" |
|
|
134 |
Whether to use the proposed modifid UNet or the original UNet |
|
|
135 |
""" |
|
|
136 |
cfg['modified_unet'] = True |
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
""" |
|
|
141 |
The depth of the U-structure |
|
|
142 |
""" |
|
|
143 |
cfg['levels'] = 3 |
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
""" |
|
|
148 |
The number of channels of the first conv |
|
|
149 |
""" |
|
|
150 |
cfg['start_chs'] = 64 |
|
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
""" |
|
|
155 |
If specified, before training, the model weights will be loaded from this path otherwise |
|
|
156 |
the model will be trained from scratch. |
|
|
157 |
""" |
|
|
158 |
cfg['load_model_dir'] = None |
|
|
159 |
|
|
|
160 |
|