andreped commited on
Commit
d949fe4
·
1 Parent(s): 3c4069c

Swapped 3D with 2D closing operation [no ci]

Browse files
lungtumormask/__main__.py CHANGED
@@ -16,7 +16,7 @@ def main():
16
  parser.add_argument('--lung-filter', action='store_true', help='whether to apply lungmask postprocessing.')
17
  parser.add_argument('--threshold', metavar='threshold', type=float, default=0.5,
18
  help='which threshold to use for assigning voxel-wise classes.')
19
- parser.add_argument('--radius', metavar='radius', type=int, default=5,
20
  help='which radius to use for morphological post-processing segmentation smoothing.')
21
 
22
  argsin = sys.argv[1:]
 
16
  parser.add_argument('--lung-filter', action='store_true', help='whether to apply lungmask postprocessing.')
17
  parser.add_argument('--threshold', metavar='threshold', type=float, default=0.5,
18
  help='which threshold to use for assigning voxel-wise classes.')
19
+ parser.add_argument('--radius', metavar='radius', type=int, default=1,
20
  help='which radius to use for morphological post-processing segmentation smoothing.')
21
 
22
  argsin = sys.argv[1:]
lungtumormask/dataprocessing.py CHANGED
@@ -8,7 +8,7 @@ import torch
8
  import numpy as np
9
  from monai.transforms import (Compose, LoadImaged, ToNumpyd, ThresholdIntensityd, AddChanneld, NormalizeIntensityd, SpatialCropd, DivisiblePadd, Spacingd, SqueezeDimd)
10
  from tqdm import tqdm
11
- from skimage.morphology import binary_closing, ball
12
 
13
  def mask_lung(scan_path, batch_size=20):
14
  model = lungmask.mask.get_model('unet', 'R231')
@@ -239,6 +239,7 @@ def post_process(left, right, preprocess_dump, lung_filter, threshold, radius):
239
  stitched[preprocess_dump['lungmask'] == 0] = 0
240
 
241
  # final post-processing - fix fragmentation
242
- stitched = binary_closing(stitched, footprint=ball(radius=radius))
 
243
 
244
  return stitched
 
8
  import numpy as np
9
  from monai.transforms import (Compose, LoadImaged, ToNumpyd, ThresholdIntensityd, AddChanneld, NormalizeIntensityd, SpatialCropd, DivisiblePadd, Spacingd, SqueezeDimd)
10
  from tqdm import tqdm
11
+ from skimage.morphology import binary_closing, disk
12
 
13
  def mask_lung(scan_path, batch_size=20):
14
  model = lungmask.mask.get_model('unet', 'R231')
 
239
  stitched[preprocess_dump['lungmask'] == 0] = 0
240
 
241
  # final post-processing - fix fragmentation
242
+ for i in range(stitched.shape[-1]):
243
+ stitched[..., i] = binary_closing(stitched[..., i], footprint=disk(radius=radius))
244
 
245
  return stitched