Skip to content

Commit

Permalink
Merge pull request #14 from andreped/post-processing
Browse files Browse the repository at this point in the history
Improved morphological post-processing [no ci]
  • Loading branch information
andreped authored Apr 23, 2023
2 parents 3c4069c + d5b35fe commit 2e7d621
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.6
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.7

- name: Install dependencies
run: |
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install dependencies
run: |
pip install --upgrade pip
pip install wheel setuptools
- name: Build wheel
run: python setup.py bdist_wheel --universal

- name: Upload Python wheel
uses: actions/upload-artifact@v2
with:
name: Python wheel
path: ${{github.workspace}}/dist/lungtumormask-*.whl
if-no-files-found: error
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Software has been tested against Python `3.7-3.10`.

Stable latest release:
```
pip install https://github.com/VemundFredriksen/LungTumorMask/releases/download/v1.1.3/lungtumormask-1.1.3-py2.py3-none-any.whl
pip install https://github.com/VemundFredriksen/LungTumorMask/releases/download/v1.2.0/lungtumormask-1.2.0-py2.py3-none-any.whl
```

Or from source:
Expand Down
2 changes: 1 addition & 1 deletion lungtumormask/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main():
parser.add_argument('--lung-filter', action='store_true', help='whether to apply lungmask postprocessing.')
parser.add_argument('--threshold', metavar='threshold', type=float, default=0.5,
help='which threshold to use for assigning voxel-wise classes.')
parser.add_argument('--radius', metavar='radius', type=int, default=5,
parser.add_argument('--radius', metavar='radius', type=int, default=1,
help='which radius to use for morphological post-processing segmentation smoothing.')

argsin = sys.argv[1:]
Expand Down
5 changes: 3 additions & 2 deletions lungtumormask/dataprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
from monai.transforms import (Compose, LoadImaged, ToNumpyd, ThresholdIntensityd, AddChanneld, NormalizeIntensityd, SpatialCropd, DivisiblePadd, Spacingd, SqueezeDimd)
from tqdm import tqdm
from skimage.morphology import binary_closing, ball
from skimage.morphology import binary_closing, disk

def mask_lung(scan_path, batch_size=20):
model = lungmask.mask.get_model('unet', 'R231')
Expand Down Expand Up @@ -239,6 +239,7 @@ def post_process(left, right, preprocess_dump, lung_filter, threshold, radius):
stitched[preprocess_dump['lungmask'] == 0] = 0

# final post-processing - fix fragmentation
stitched = binary_closing(stitched, footprint=ball(radius=radius))
for i in range(stitched.shape[-1]):
stitched[..., i] = binary_closing(stitched[..., i], footprint=disk(radius=radius))

return stitched
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name="lungtumormask",
packages=find_packages(),
version='1.1.3',
version='1.2.0',
author="Svein Ole M Sevle, Vemund Fredriksen, and André Pedersen",
url="https://github.com/VemundFredriksen/LungTumorMask",
license="MIT",
Expand Down

0 comments on commit 2e7d621

Please sign in to comment.