andreped commited on
Commit
2e7d621
·
unverified ·
2 Parent(s): 3c4069c d5b35fe

Merge pull request #14 from andreped/post-processing

Browse files
.github/workflows/build.yml CHANGED
@@ -14,10 +14,10 @@ jobs:
14
  runs-on: ubuntu-20.04
15
  steps:
16
  - uses: actions/checkout@v1
17
- - name: Set up Python 3.6
18
  uses: actions/setup-python@v2
19
  with:
20
- python-version: 3.6
21
 
22
  - name: Install dependencies
23
  run: |
 
14
  runs-on: ubuntu-20.04
15
  steps:
16
  - uses: actions/checkout@v1
17
+ - name: Set up Python 3.7
18
  uses: actions/setup-python@v2
19
  with:
20
+ python-version: 3.7
21
 
22
  - name: Install dependencies
23
  run: |
.github/workflows/release.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '*'
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ubuntu-20.04
15
+ steps:
16
+ - uses: actions/checkout@v1
17
+ - name: Set up Python 3.7
18
+ uses: actions/setup-python@v2
19
+ with:
20
+ python-version: 3.7
21
+
22
+ - name: Install dependencies
23
+ run: |
24
+ pip install --upgrade pip
25
+ pip install wheel setuptools
26
+
27
+ - name: Build wheel
28
+ run: python setup.py bdist_wheel --universal
29
+
30
+ - name: Upload Python wheel
31
+ uses: actions/upload-artifact@v2
32
+ with:
33
+ name: Python wheel
34
+ path: ${{github.workspace}}/dist/lungtumormask-*.whl
35
+ if-no-files-found: error
README.md CHANGED
@@ -17,7 +17,7 @@ Software has been tested against Python `3.7-3.10`.
17
 
18
  Stable latest release:
19
  ```
20
- pip install https://github.com/VemundFredriksen/LungTumorMask/releases/download/v1.1.3/lungtumormask-1.1.3-py2.py3-none-any.whl
21
  ```
22
 
23
  Or from source:
 
17
 
18
  Stable latest release:
19
  ```
20
+ pip install https://github.com/VemundFredriksen/LungTumorMask/releases/download/v1.2.0/lungtumormask-1.2.0-py2.py3-none-any.whl
21
  ```
22
 
23
  Or from source:
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
setup.py CHANGED
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
3
  setup(
4
  name="lungtumormask",
5
  packages=find_packages(),
6
- version='1.1.3',
7
  author="Svein Ole M Sevle, Vemund Fredriksen, and André Pedersen",
8
  url="https://github.com/VemundFredriksen/LungTumorMask",
9
  license="MIT",
 
3
  setup(
4
  name="lungtumormask",
5
  packages=find_packages(),
6
+ version='1.2.0',
7
  author="Svein Ole M Sevle, Vemund Fredriksen, and André Pedersen",
8
  url="https://github.com/VemundFredriksen/LungTumorMask",
9
  license="MIT",