@@ -784,6 +784,40 @@ def get_index_by_patient_number_old(plist, df1, seed_n = 42, mode = 'random', co
784
784
785
785
# Plot prediction result
786
786
def plot_prediction_result (data , labels , preds , logged = None , chunk_size = 80 , save_path = None , arrangement = ['d1' , 'd1-l1' , 'd1-p1' , 'd1-ph' , 'd1-l1-ph' , 'd1-p1-ph' ], ** kwargs ):
787
+ """
788
+ Plots a comparison figure with arrangement.
789
+
790
+ Parameters
791
+ ----------
792
+ N : data numbers
793
+ C : channels
794
+ H : Height
795
+ W : Width
796
+ D : Depth
797
+
798
+ data : a numpy array
799
+ (N, C, H, W, D) array, image data
800
+
801
+ labels : a numpy array
802
+ (N, C, H, W, D) array, label data
803
+
804
+ preds : a numpy array
805
+ (N, C, H, W, D) array, preds data
806
+
807
+ chunk_size : the number of data for one png file.
808
+
809
+ save_path : png save path.
810
+
811
+ arrangement : a list of strings
812
+ e.g.
813
+ 'd1' means data channel 1
814
+ 'd1-l2' means overlaying label channel 2 on data channel 1
815
+ 'd1-p1-ph' means the height is what has the widest prediction area, pred channel 1 overlayed on data channel 1
816
+
817
+ If you set arrangement to ['d1', 'd1-l1', 'd1-p1', 'd1-ph', 'd1-l1-ph', 'd1-p1-ph'], the figure will be (samples, 6) plot.
818
+
819
+
820
+ """
787
821
ca = arange (0 , len (data ), chunk_size )
788
822
789
823
for i in range (len (ca )):
@@ -1066,15 +1100,37 @@ def show_mri(img, label, pred = None, logged = None, arrangement = ['d1', 'd1-l1
1066
1100
height = None , cmap = 'Greys_r' , data_order = ['x_test' , 'y_test' , 'y_pred' , 'x_test' , 'y_pred' ], nums = None ,
1067
1101
thresh = 0.5 , save_path = None , pad = 5 , subplot_adjust_left = 0.33 , max_samples = 1000 , img_types = None , initial_num = 1 , ** kwargs ):
1068
1102
"""
1069
- Paramters
1070
- ---------
1071
- arrangement : a list.
1072
- e.g. ['d1', 'd2', 'd1-l1', 'd1-ph', 'd1-ph-p1']
1073
- d1 = data - channel 1
1074
- l2 = label - channel 2
1075
- p2 = pred - channel 2
1076
- ph = height based on prediction(not label)
1077
-
1103
+
1104
+ Parameters
1105
+ ----------
1106
+ N : data numbers
1107
+ C : channels
1108
+ H : Height
1109
+ W : Width
1110
+ D : Depth
1111
+
1112
+ data : a numpy array
1113
+ (N, C, H, W, D) array, image data
1114
+
1115
+ labels : a numpy array
1116
+ (N, C, H, W, D) array, label data
1117
+
1118
+ preds : a numpy array
1119
+ (N, C, H, W, D) array, preds data
1120
+
1121
+ chunk_size : the number of data for one png file.
1122
+
1123
+ save_path : png save path.
1124
+
1125
+ arrangement : a list of strings
1126
+ e.g.
1127
+ 'd1' means data channel 1
1128
+ 'd1-l2' means overlaying label channel 2 on data channel 1
1129
+ 'd1-p1-ph' means the height is what has the widest prediction area, pred channel 1 overlayed on data channel 1
1130
+
1131
+ If you set arrangement to ['d1', 'd1-l1', 'd1-p1', 'd1-ph', 'd1-l1-ph', 'd1-p1-ph'], the figure will be (samples, 6) plot.
1132
+
1133
+
1078
1134
"""
1079
1135
1080
1136
# Set paramters
@@ -1254,14 +1310,14 @@ def truncate_trainset_size(*args, batch_size):
1254
1310
1255
1311
1256
1312
def make_model (build_model , input_shape , output_channels , n_gpu , test_mode = True , seed_number = 42 ):
1257
- tf .set_random_seed (seed_number )
1313
+ tf .random . set_seed (seed_number )
1258
1314
np .random .seed (seed_number )
1259
1315
logger .info (f"{ seed_number } was set to seed number, and seed of tensorflow and numpy was set to the number." )
1260
1316
1261
- model , template_model , opt , lg , lv , dc = build_model (input_shape = input_shape ,
1317
+ model , opt , lg , lv , dc = build_model (input_shape = input_shape ,
1262
1318
output_channels = output_channels , n_gpu = n_gpu , test_mode = True )
1263
1319
1264
- return model , template_model , opt , lg , lv , dc
1320
+ return model , opt , lg , lv , dc
1265
1321
1266
1322
1267
1323
def set_callbacks (model , save_dir , fold_number = None , min_delta = 0.01 , patience = 10 , baseline = None , a0 = 1e-5 , lr_schedule_total_epoch = 300 ,
0 commit comments