Commit
·
ca1d395
1
Parent(s):
a7b71d6
Renamed the folder to SoA_methods to hold the evaluation script of other methods
Browse files
{ANTs → SoA_methods}/eval_ants.py
RENAMED
@@ -102,8 +102,8 @@ if __name__ == '__main__':
|
|
102 |
mov_centroids = vol_file['mov_centroids'][:]
|
103 |
|
104 |
# ndarray to ANTsImage
|
105 |
-
fix_img_ants = ants.make_image(fix_img.shape[:-1], np.squeeze(fix_img)) #
|
106 |
-
mov_img_ants = ants.make_image(mov_img.shape[:-1], np.squeeze(mov_img)) #
|
107 |
|
108 |
t0_syn = time.time()
|
109 |
reg_output_syn = ants.registration(fix_img_ants, mov_img_ants, 'SyN')
|
@@ -121,13 +121,13 @@ if __name__ == '__main__':
|
|
121 |
for reg_output in [reg_output_syn, reg_output_syncc]:
|
122 |
mov_to_fix_trf_list = reg_output[FWD_TRFS]
|
123 |
pred_img = reg_output[WARPED_MOV].numpy()
|
124 |
-
pred_img = pred_img[..., np.newaxis] #
|
125 |
|
126 |
fix_seg_ants = ants.make_image(fix_seg.shape, np.squeeze(fix_seg))
|
127 |
mov_seg_ants = ants.make_image(mov_seg.shape, np.squeeze(mov_seg))
|
128 |
pred_seg = ants.apply_transforms(fixed=fix_seg_ants, moving=mov_seg_ants,
|
129 |
transformlist=mov_to_fix_trf_list).numpy()
|
130 |
-
pred_seg = np.squeeze(pred_seg) #
|
131 |
with sess.as_default():
|
132 |
dice, hd, dice_macro = sess.run([dice_tf, hd_tf, dice_macro_tf],
|
133 |
{'fix_seg:0': fix_seg[np.newaxis, ...], # Batch axis
|
|
|
102 |
mov_centroids = vol_file['mov_centroids'][:]
|
103 |
|
104 |
# ndarray to ANTsImage
|
105 |
+
fix_img_ants = ants.make_image(fix_img.shape[:-1], np.squeeze(fix_img)) # SoA doesn't work fine with 1-ch images
|
106 |
+
mov_img_ants = ants.make_image(mov_img.shape[:-1], np.squeeze(mov_img)) # SoA doesn't work fine with 1-ch images
|
107 |
|
108 |
t0_syn = time.time()
|
109 |
reg_output_syn = ants.registration(fix_img_ants, mov_img_ants, 'SyN')
|
|
|
121 |
for reg_output in [reg_output_syn, reg_output_syncc]:
|
122 |
mov_to_fix_trf_list = reg_output[FWD_TRFS]
|
123 |
pred_img = reg_output[WARPED_MOV].numpy()
|
124 |
+
pred_img = pred_img[..., np.newaxis] # SoA doesn't work fine with 1-ch images
|
125 |
|
126 |
fix_seg_ants = ants.make_image(fix_seg.shape, np.squeeze(fix_seg))
|
127 |
mov_seg_ants = ants.make_image(mov_seg.shape, np.squeeze(mov_seg))
|
128 |
pred_seg = ants.apply_transforms(fixed=fix_seg_ants, moving=mov_seg_ants,
|
129 |
transformlist=mov_to_fix_trf_list).numpy()
|
130 |
+
pred_seg = np.squeeze(pred_seg) # SoA adds an extra axis which shouldn't be there
|
131 |
with sess.as_default():
|
132 |
dice, hd, dice_macro = sess.run([dice_tf, hd_tf, dice_macro_tf],
|
133 |
{'fix_seg:0': fix_seg[np.newaxis, ...], # Batch axis
|