jpdefrutos commited on
Commit
4b5777a
·
1 Parent(s): 7b8d670

Removed unused constants from main

Browse files

Called to package constants instead of declaring new ones in main (IMAGE_INPUT_SHAPE -> IMAGE_SHAPE)

DeepDeformationMapRegistration/main.py CHANGED
@@ -34,24 +34,6 @@ from importlib.util import find_spec
34
 
35
  LOGGER = logging.getLogger(__name__)
36
 
37
- MODELS_FILE = {'L': {'BL-N': './models/liver/bl_ncc.h5',
38
- 'BL-S': './models/liver/bl_ncc_ssim.h5',
39
- 'SG-ND': './models/liver/sg_ncc_dsc.h5',
40
- 'SD-NSD': './models/liver/sg_ncc_ssim_dsc.h5',
41
- 'UW-NSD': './models/liver/uw_ncc_ssim_dsc.h5',
42
- 'UW-NSDH': './models/liver/uw_ncc_ssim_dsc_hd.h5',
43
- },
44
- 'B': {'BL-N': './models/brain/bl_ncc.h5',
45
- 'BL-S': './models/brain/bl_ncc_ssim.h5',
46
- 'SG-ND': './models/brain/sg_ncc_dsc.h5',
47
- 'SD-NSD': './models/brain/sg_ncc_ssim_dsc.h5',
48
- 'UW-NSD': './models/brain/uw_ncc_ssim_dsc.h5',
49
- 'UW-NSDH': './models/brain/uw_ncc_ssim_dsc_hd.h5',
50
- }
51
- }
52
-
53
- IMAGE_INTPUT_SHAPE = np.asarray([128, 128, 128, 1])
54
-
55
 
56
  def rigidly_align_images(image_1: str, image_2: str) -> nib.Nifti1Image:
57
  """
@@ -280,7 +262,7 @@ def main():
280
 
281
  image_shape_crop = fixed_image.shape
282
  # 2.3 Resize the images to the expected input size
283
- zoom_factors = IMAGE_INTPUT_SHAPE / image_shape_crop
284
  fixed_image = zoom(fixed_image, zoom_factors)
285
  moving_image = zoom(moving_image, zoom_factors)
286
  fixed_image = min_max_norm(fixed_image)
@@ -328,7 +310,7 @@ def main():
328
  enc_features = [32, 64, 128, 256, 512, 1024] # const.ENCODER_FILTERS
329
  dec_features = enc_features[::-1] + [16, 16] # const.ENCODER_FILTERS[::-1]
330
  nb_features = [enc_features, dec_features]
331
- network = vxm.networks.VxmDense(inshape=IMAGE_INTPUT_SHAPE[:-1],
332
  nb_unet_features=nb_features,
333
  int_steps=0)
334
  network.load_weights(MODEL_FILE, by_name=True)
 
34
 
35
  LOGGER = logging.getLogger(__name__)
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  def rigidly_align_images(image_1: str, image_2: str) -> nib.Nifti1Image:
39
  """
 
262
 
263
  image_shape_crop = fixed_image.shape
264
  # 2.3 Resize the images to the expected input size
265
+ zoom_factors = C.IMAGE_SHAPE / image_shape_crop
266
  fixed_image = zoom(fixed_image, zoom_factors)
267
  moving_image = zoom(moving_image, zoom_factors)
268
  fixed_image = min_max_norm(fixed_image)
 
310
  enc_features = [32, 64, 128, 256, 512, 1024] # const.ENCODER_FILTERS
311
  dec_features = enc_features[::-1] + [16, 16] # const.ENCODER_FILTERS[::-1]
312
  nb_features = [enc_features, dec_features]
313
+ network = vxm.networks.VxmDense(inshape=C.IMAGE_SHAPE[:-1],
314
  nb_unet_features=nb_features,
315
  int_steps=0)
316
  network.load_weights(MODEL_FILE, by_name=True)
DeepDeformationMapRegistration/utils/constants.py CHANGED
@@ -30,7 +30,7 @@ PRED_IMG_GT = 1
30
  DISP_VECT_GT = 2
31
  DISP_VECT_LOC_GT = 3
32
 
33
- IMG_SIZE = 64 # Assumed a square image
34
  IMG_SHAPE = (IMG_SIZE, IMG_SIZE, IMG_SIZE, 1) # (IMG_SIZE, IMG_SIZE, 1)
35
  DISP_MAP_SHAPE = (IMG_SIZE, IMG_SIZE, IMG_SIZE, 3)
36
  BATCH_SHAPE = (None, IMG_SIZE, IMG_SIZE, IMG_SIZE, 2) # Expected batch shape by the network
 
30
  DISP_VECT_GT = 2
31
  DISP_VECT_LOC_GT = 3
32
 
33
+ IMG_SIZE = 128 # Assumed a square image
34
  IMG_SHAPE = (IMG_SIZE, IMG_SIZE, IMG_SIZE, 1) # (IMG_SIZE, IMG_SIZE, 1)
35
  DISP_MAP_SHAPE = (IMG_SIZE, IMG_SIZE, IMG_SIZE, 3)
36
  BATCH_SHAPE = (None, IMG_SIZE, IMG_SIZE, IMG_SIZE, 2) # Expected batch shape by the network