andreped commited on
Commit
4f28aaa
·
1 Parent(s): b569da5

Working on demo - not finished yet

Browse files
DeepDeformationMapRegistration/main.py CHANGED
@@ -338,7 +338,7 @@ def main():
338
  else:
339
  np.savez_compressed(os.path.join(os.path.join(args.outputdir, 'debug'), 'displacement_map.npz'), disp_map)
340
 
341
- LOGGER.info('Predicted image and displacement map saved in: '.format(args.outputdir))
342
  LOGGER.info(f'Displacement map prediction time: {time_disp_map_end - time_disp_map_start} s')
343
  LOGGER.info(f'Predicted image time: {time_pred_img_end - time_pred_img_start} s')
344
 
 
338
  else:
339
  np.savez_compressed(os.path.join(os.path.join(args.outputdir, 'debug'), 'displacement_map.npz'), disp_map)
340
 
341
+ LOGGER.info(f'Predicted image and displacement map saved in: '.format(args.outputdir))
342
  LOGGER.info(f'Displacement map prediction time: {time_disp_map_end - time_disp_map_start} s')
343
  LOGGER.info(f'Predicted image time: {time_pred_img_end - time_pred_img_start} s')
344
 
demo/src/compute.py CHANGED
@@ -1,3 +1,6 @@
1
- def run_model(input_path):
2
- from lungtumormask import mask
3
- mask.mask(input_path, "./prediction.nii.gz", lung_filter=True, threshold=0.5, radius=1, batch_size=1)
 
 
 
 
1
+ import subprocess as sp
2
+
3
+
4
+ def run_model(fixed_path, moving_path, output_path):
5
+ sp.check_call(["ddmr", "--fixed", fixed_path, "--moving", moving_path, \
6
+ "-o", output_path, "-a", "B", "--model", "BL-NS", "--original-resolution"])
demo/src/gui.py CHANGED
@@ -2,7 +2,7 @@ import os
2
 
3
  import gradio as gr
4
 
5
- from .inference import run_model
6
  from .utils import load_ct_to_numpy
7
  from .utils import load_pred_volume_to_numpy
8
  from .utils import nifti_to_glb
@@ -16,7 +16,8 @@ class WebUI:
16
  share: int = 1,
17
  ):
18
  # global states
19
- self.images = []
 
20
  self.pred_images = []
21
 
22
  # @TODO: This should be dynamically set based on chosen volume size
@@ -26,21 +27,9 @@ class WebUI:
26
  self.cwd = cwd
27
  self.share = share
28
 
29
- self.class_name = "meningioma" # default
30
  self.class_names = {
31
- "meningioma": "MRI_Meningioma",
32
- "low-grade": "MRI_LGGlioma",
33
- "metastasis": "MRI_Metastasis",
34
- "high-grade": "MRI_GBM",
35
- "brain": "MRI_Brain",
36
- }
37
-
38
- self.result_names = {
39
- "meningioma": "Tumor",
40
- "low-grade": "Tumor",
41
- "metastasis": "Tumor",
42
- "high-grade": "Tumor",
43
- "brain": "Brain",
44
  }
45
 
46
  # define widgets not to be rendered immediantly, but later on
@@ -112,8 +101,7 @@ class WebUI:
112
  model_selector = gr.Dropdown(
113
  list(self.class_names.keys()),
114
  label="Task",
115
- info="Which task to perform - one model for"
116
- "each brain tumor type and brain extraction",
117
  multiselect=False,
118
  size="sm",
119
  )
@@ -135,8 +123,8 @@ class WebUI:
135
  with gr.Row():
136
  gr.Examples(
137
  examples=[
138
- os.path.join(self.cwd, "RegLib_C01_1.nii"),
139
- os.path.join(self.cwd, "RegLib_C01_2.nii"),
140
  ],
141
  inputs=file_output,
142
  outputs=file_output,
 
2
 
3
  import gradio as gr
4
 
5
+ from .compute import run_model
6
  from .utils import load_ct_to_numpy
7
  from .utils import load_pred_volume_to_numpy
8
  from .utils import nifti_to_glb
 
16
  share: int = 1,
17
  ):
18
  # global states
19
+ self.fixed_images = []
20
+ self.moving_images = []
21
  self.pred_images = []
22
 
23
  # @TODO: This should be dynamically set based on chosen volume size
 
27
  self.cwd = cwd
28
  self.share = share
29
 
 
30
  self.class_names = {
31
+ "B": "Brain",
32
+ "L": "Liver"
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
 
35
  # define widgets not to be rendered immediantly, but later on
 
101
  model_selector = gr.Dropdown(
102
  list(self.class_names.keys()),
103
  label="Task",
104
+ info="Which task to perform registration for",
 
105
  multiselect=False,
106
  size="sm",
107
  )
 
123
  with gr.Row():
124
  gr.Examples(
125
  examples=[
126
+ os.path.join(self.cwd, "ixi_image.nii.gz"),
127
+ os.path.join(self.cwd, "ixi_image2.nii.gz"),
128
  ],
129
  inputs=file_output,
130
  outputs=file_output,