Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nnunet demo #40

Merged
merged 489 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
489 commits
Select commit Hold shift + click to select a range
6709767
Merge branch 'add_capabilities' of https://github.com/bhklab/imgtools…
Vishwesh4 Dec 8, 2021
8c2c3af
Merge branch 'add_capabilities' of https://github.com/bhklab/imgtools…
Vishwesh4 Dec 8, 2021
66a1ffd
Merge branch 'add_capabilities' of https://github.com/bhklab/imgtools…
Vishwesh4 Dec 8, 2021
6da65dd
uncommented one line pytest
Vishwesh4 Dec 8, 2021
f7cdcc5
uncommented one line pytest
Vishwesh4 Dec 8, 2021
3dc8cd3
uncommented one line pytest
Vishwesh4 Dec 8, 2021
3f87849
uncommented one line pytest
Vishwesh4 Dec 8, 2021
eb1822d
uncommented one line pytest
Vishwesh4 Dec 8, 2021
2b9d6d4
uncommented one line pytest
Vishwesh4 Dec 8, 2021
a517001
self.existing, dataset.csv fixed (#10)
skim2257 Dec 8, 2021
f2480c3
self.existing, dataset.csv fixed (#10)
skim2257 Dec 8, 2021
29118a6
Added dataset class which can load from nrrds or directly from the da…
Vishwesh4 Dec 9, 2021
2ae58c6
Added dataset class which can load from nrrds or directly from the da…
Vishwesh4 Dec 9, 2021
1cd8984
Added dataset class which can load from nrrds or directly from the da…
Vishwesh4 Dec 9, 2021
8eba88d
Create build-ci.yml
skim2257 Dec 9, 2021
5a0e945
Create build-ci.yml
skim2257 Dec 9, 2021
ff70c89
Update build-ci.yml
skim2257 Dec 9, 2021
33a1d60
Update build-ci.yml
skim2257 Dec 9, 2021
87fe30d
Update requirements.txt
skim2257 Dec 9, 2021
fcd6cb4
Update requirements.txt
skim2257 Dec 9, 2021
a27dc3c
bug fixes_1.0
Vishwesh4 Dec 9, 2021
d42919d
bug fixes_1.0
Vishwesh4 Dec 9, 2021
d255674
bug fixes_1.0
Vishwesh4 Dec 9, 2021
2aca001
test and autopipe fixed
Vishwesh4 Dec 9, 2021
cc2e552
test and autopipe fixed
Vishwesh4 Dec 9, 2021
9cc88b1
test and autopipe fixed
Vishwesh4 Dec 9, 2021
374041f
bug fixes 2
Vishwesh4 Dec 9, 2021
78385cf
bug fixes 2
Vishwesh4 Dec 9, 2021
e7f4b42
bug fixes 2
Vishwesh4 Dec 9, 2021
ad812ba
bug fixes 2
Vishwesh4 Dec 9, 2021
b38bbe5
bug fixes 2
Vishwesh4 Dec 9, 2021
90732d8
bug fixes 2
Vishwesh4 Dec 9, 2021
2daaf02
added visualizations and some more bug fixes
Vishwesh4 Dec 10, 2021
69d688f
added visualizations and some more bug fixes
Vishwesh4 Dec 10, 2021
735b26c
added visualizations and some more bug fixes
Vishwesh4 Dec 10, 2021
23e2c92
Create manual-test.yml
skim2257 Dec 10, 2021
d0b495c
Create manual-test.yml
skim2257 Dec 10, 2021
d0f1af1
Update build-ci.yml
skim2257 Dec 10, 2021
f77c367
Update build-ci.yml
skim2257 Dec 10, 2021
e82d3c8
Update manual-test.yml
skim2257 Dec 10, 2021
c17f6b5
Update manual-test.yml
skim2257 Dec 10, 2021
4aa54db
PR tests - macos/ubuntu failing (#13)
skim2257 Dec 10, 2021
47f3122
PR tests - macos/ubuntu failing (#13)
skim2257 Dec 10, 2021
ab236e5
fixed bugs regarding multiple connections, saving of metadata and loa…
Vishwesh4 Dec 10, 2021
a7c15fb
fixed bugs regarding multiple connections, saving of metadata and loa…
Vishwesh4 Dec 10, 2021
1528efc
fixed bugs regarding multiple connections, saving of metadata and loa…
Vishwesh4 Dec 10, 2021
43e3c6b
small bug fix
Vishwesh4 Dec 11, 2021
5e3d53c
small bug fix
Vishwesh4 Dec 11, 2021
7a27ee3
small bug fix
Vishwesh4 Dec 11, 2021
64a7701
added demo.py
Vishwesh4 Dec 11, 2021
636f89d
added demo.py
Vishwesh4 Dec 11, 2021
b644919
added demo.py
Vishwesh4 Dec 11, 2021
ea2aafd
Ready for
skim2257 Dec 13, 2021
9e5d03a
Ready for
skim2257 Dec 13, 2021
85855b7
Create main.yml (#15)
skim2257 Dec 13, 2021
700fbe6
Create main.yml (#15)
skim2257 Dec 13, 2021
180fe18
Changed dataset class returns
Vishwesh4 Dec 13, 2021
3b03431
Changed dataset class returns
Vishwesh4 Dec 13, 2021
3c6d7f5
Changed dataset class returns
Vishwesh4 Dec 13, 2021
42e4a1b
Merge branch 'master' of github.com:bhklab/imgtools
skim2257 Dec 13, 2021
5a5e3e3
Merge branch 'master' of github.com:bhklab/imgtools
skim2257 Dec 13, 2021
f169a7e
Merge branch 'master' of github.com:bhklab/imgtools
skim2257 Dec 13, 2021
c70d9c8
fix conflicts
skim2257 Dec 13, 2021
4136956
fix conflicts
skim2257 Dec 13, 2021
caad95a
fix conflicts
skim2257 Dec 13, 2021
3817bbb
fixed test autopipe
skim2257 Dec 13, 2021
c3fcdd8
fixed test autopipe
skim2257 Dec 13, 2021
63b9543
fixed test autopipe
skim2257 Dec 13, 2021
2cca578
merging new features (#16)
skim2257 Dec 13, 2021
539777c
merging new features (#16)
skim2257 Dec 13, 2021
c9fcbbe
fix path backslash issues
skim2257 Dec 13, 2021
0f1542e
fix path backslash issues
skim2257 Dec 13, 2021
d81a74d
fix path backslash issues
skim2257 Dec 13, 2021
a242475
fix
skim2257 Dec 13, 2021
d701d3f
fix
skim2257 Dec 13, 2021
c152b08
fix
skim2257 Dec 13, 2021
1e33924
fix path backslashes (#17)
skim2257 Dec 13, 2021
5c6f7b0
fix path backslashes (#17)
skim2257 Dec 13, 2021
034846d
Update main.yml
skim2257 Dec 13, 2021
c0bf276
Update main.yml
skim2257 Dec 13, 2021
12e0acb
Update main.yml
skim2257 Dec 13, 2021
f539726
Update main.yml
skim2257 Dec 13, 2021
ac3da86
Update README.md
skim2257 Dec 13, 2021
acf8cfb
Update README.md
skim2257 Dec 13, 2021
aa1a15f
Update main.yml (#18)
skim2257 Dec 13, 2021
9011025
Update main.yml (#18)
skim2257 Dec 13, 2021
c1930b7
Update README.md
skim2257 Dec 13, 2021
2a36b04
Update README.md
skim2257 Dec 13, 2021
853c127
Update README.md (#19)
skim2257 Dec 14, 2021
bde03e1
Update README.md (#19)
skim2257 Dec 14, 2021
7508ebe
Update README.md
skim2257 Dec 14, 2021
edb278f
Update README.md
skim2257 Dec 14, 2021
abfd4db
added tests for Dataset class
Vishwesh4 Dec 15, 2021
6025ba6
added tests for Dataset class
Vishwesh4 Dec 15, 2021
8d345fb
added tests for Dataset class
Vishwesh4 Dec 15, 2021
1f9c17c
added tests for Dataset class
Vishwesh4 Dec 15, 2021
d9b6cc3
added tests for Dataset class
Vishwesh4 Dec 15, 2021
7747a81
added tests for Dataset class
Vishwesh4 Dec 15, 2021
8c2a21b
Create LICENSE (#20)
skim2257 Dec 15, 2021
7ec143e
Create LICENSE (#20)
skim2257 Dec 15, 2021
da617df
Seg.nrrd quick fix
skim2257 Dec 15, 2021
7f3b5c6
Seg.nrrd quick fix
skim2257 Dec 15, 2021
7162d45
Minor bug fixes
Vishwesh4 Dec 15, 2021
a7e482d
Minor bug fixes
Vishwesh4 Dec 15, 2021
f18aa1b
Minor bug fixes
Vishwesh4 Dec 15, 2021
68ad7c0
Merge branch 'add_capabilities'
Vishwesh4 Dec 15, 2021
08265b1
Merge branch 'add_capabilities'
Vishwesh4 Dec 15, 2021
9931e15
Merge branch 'add_capabilities'
Vishwesh4 Dec 15, 2021
d55216a
test fix
Vishwesh4 Dec 15, 2021
6b8c112
test fix
Vishwesh4 Dec 15, 2021
2fad37e
test fix
Vishwesh4 Dec 15, 2021
1ec6966
Added demo
Vishwesh4 Dec 16, 2021
f9d8f9a
Added demo
Vishwesh4 Dec 16, 2021
48ea411
Added demo
Vishwesh4 Dec 16, 2021
ce8e287
Update setup.py (#23)
skim2257 Dec 17, 2021
836589b
Update setup.py (#23)
skim2257 Dec 17, 2021
9e24716
Update setup.py (#23)
skim2257 Dec 17, 2021
e35f91d
updated README
Dec 21, 2021
d57189a
updated README
Dec 21, 2021
0f04145
updated README
Dec 21, 2021
27494c0
Update README.md (#24)
skim2257 Jan 18, 2022
b25dc8d
Update README.md (#24)
skim2257 Jan 18, 2022
9aaf51b
Update README.md (#24)
skim2257 Jan 18, 2022
11971c8
preliminary MRI functionality (MR-RTSTRUCT pairs)
skim2257 Jan 18, 2022
d24cae9
preliminary MRI functionality (MR-RTSTRUCT pairs)
skim2257 Jan 18, 2022
3c01806
preliminary MRI functionality (MR-RTSTRUCT pairs)
skim2257 Jan 18, 2022
2ed78e5
Merge branch 'master' of github.com:bhklab/imgtools
skim2257 Jan 18, 2022
258a242
Merge branch 'master' of github.com:bhklab/imgtools
skim2257 Jan 18, 2022
eaad718
Merge branch 'master' of github.com:bhklab/imgtools
skim2257 Jan 18, 2022
65d66d2
Skim2257 quick fix (#26)
skim2257 Apr 26, 2022
5c78dbd
Skim2257 quick fix (#26)
skim2257 Apr 26, 2022
5e93381
Skim2257 quick fix (#26)
skim2257 Apr 26, 2022
8ac1dfd
quick fixes
skim2257 May 11, 2022
454bfde
quick fixes
skim2257 May 11, 2022
971e8d6
first commit
fishingguy456 May 13, 2022
ff42f8a
removed test files, changed gitignore
fishingguy456 May 13, 2022
c2d8c68
changed file directory structure for imageautooutput
fishingguy456 May 17, 2022
0cce0ee
Merge branch 'master' of github.com:bhklab/med-imagetools
skim2257 May 17, 2022
7a8285c
split mask up into each contour
fishingguy456 May 18, 2022
a9f093c
change kwargs in put for basesubjectwriter
fishingguy456 May 19, 2022
d0b516b
Co-authored-by: Sejin Kim <skim2257@users.noreply.github.com>
fishingguy456 May 19, 2022
358df05
still kinda failing...
skim2257 May 19, 2022
9a8ff65
brought back basesubjectwriter
fishingguy456 May 19, 2022
455c027
.imgtools directory
fishingguy456 May 24, 2022
e1e5d0d
changed absolute paths to relative paths
fishingguy456 May 25, 2022
042aa1f
changed os.path.join to pathlib.Path.as_posix()
fishingguy456 May 25, 2022
b19624d
starter pipeline, pathlib for tests
fishingguy456 May 26, 2022
9d5bc56
removed unused cv2 import
May 27, 2022
48c7f71
Merge branch 'kevin-branch' of github.com:bhklab/med-imagetools into …
May 27, 2022
36aab93
removed cv2 import
fishingguy456 May 27, 2022
9294c56
Merge branch 'kevin-branch' of https://github.com/bhklab/med-imagetoo…
fishingguy456 May 27, 2022
f6d997b
appened is deprecated, changed to concat
fishingguy456 May 27, 2022
5a6caa5
debug print
May 27, 2022
49c575a
removed debug print
fishingguy456 May 27, 2022
8dab6bc
added sparse mask class and generating function
fishingguy456 May 27, 2022
19b0ad5
testing out sparse mask
fishingguy456 May 30, 2022
7e96504
funky NaN problem
fishingguy456 May 31, 2022
915d769
commented sparse mask
May 31, 2022
461f1f4
Merge branch 'kevin-branch' of github.com:bhklab/med-imagetools into …
May 31, 2022
f0ebe6a
overwrite all subjects
fishingguy456 May 31, 2022
eb30814
space
Jun 1, 2022
62bb615
Merge branch 'kevin-branch' of github.com:bhklab/med-imagetools into …
Jun 1, 2022
ff3a115
overwrite false
fishingguy456 Jun 1, 2022
ef24263
Merge branch 'kevin-branch' of https://github.com/bhklab/med-imagetoo…
fishingguy456 Jun 1, 2022
c236408
metadata stuffs
fishingguy456 Jun 2, 2022
ae09827
metadata in dataset.csv
fishingguy456 Jun 3, 2022
51634e6
added modalities, num rtstruct and pixel size to metadata
fishingguy456 Jun 3, 2022
0042f14
metadata bugfix
fishingguy456 Jun 6, 2022
f43b45e
a
Jun 6, 2022
51da01b
Merge branch 'kevin-branch' of github.com:bhklab/med-imagetools into …
Jun 6, 2022
67449ca
fixed wrong variable names for metadata stuff
fishingguy456 Jun 6, 2022
aa36b2d
fixed pathlib float error
Jun 7, 2022
2ce5ade
relative paths and output folder paths for dataset.csv
fishingguy456 Jun 7, 2022
69f4ee7
put metadata stuff into a util file
fishingguy456 Jun 8, 2022
31d0411
deal with empty metadata
fishingguy456 Jun 8, 2022
a66925c
messing around with sparse mask
fishingguy456 Jun 9, 2022
6b54305
tried to save sparse mask, did some stuff with nnunet output format
fishingguy456 Jun 9, 2022
1407e1d
compliant with nnunet directory structure
fishingguy456 Jun 10, 2022
6bf5f4f
CLI Interface, argparse moved to utils
skim2257 Jun 10, 2022
437db52
fixed formatting problems with folder names
fishingguy456 Jun 10, 2022
9c266b3
Merge branch 'kevin-branch' of https://github.com/bhklab/med-imagetoo…
fishingguy456 Jun 10, 2022
15bab7b
train test split
fishingguy456 Jun 13, 2022
3ac4016
train size and random state optional
fishingguy456 Jun 13, 2022
f96833d
merge conflicts
skim2257 Jun 13, 2022
986e566
Merge branch 'kevin-branch' of github.com:bhklab/imgtools into kevin-…
skim2257 Jun 13, 2022
154819e
changed warnings to not interrupt
fishingguy456 Jun 13, 2022
1aec56d
changed to warnings.warn for generate_sparse_mask
fishingguy456 Jun 13, 2022
2c4f692
Merge branch 'kevin-branch' of github.com:bhklab/imgtools into kevin-…
skim2257 Jun 13, 2022
29bc242
merge
skim2257 Jun 13, 2022
0d16b02
resolving conflicts?
skim2257 Jun 13, 2022
f4f6d2d
args
fishingguy456 Jun 13, 2022
9ef837d
Merge branch 'kevin-branch' of https://github.com/bhklab/med-imagetoo…
fishingguy456 Jun 13, 2022
0479cb8
changes for roi names as a dict
fishingguy456 Jun 14, 2022
eeae5b7
added regex dictionary option for non nnunet runs
fishingguy456 Jun 15, 2022
d65c6d8
sparse mask global labelling for contour name: index
fishingguy456 Jun 15, 2022
effac09
got rid of file_name_convention stuff
fishingguy456 Jun 15, 2022
ab1e87b
conflicts resolved
skim2257 Jun 16, 2022
23b76e4
yaml thing
fishingguy456 Jun 16, 2022
2293242
added list capabilities for the roi names dictionary
fishingguy456 Jun 16, 2022
156553f
dataset.json for nnunet
fishingguy456 Jun 16, 2022
d2534c6
Merge branch 'kevin-branch' of github.com:bhklab/imgtools into kevin-…
skim2257 Jun 17, 2022
c8351e4
CLI "autonew"
skim2257 Jun 17, 2022
41630cd
changed all mutable defaults to None
fishingguy456 Jun 17, 2022
794f27d
Merge branch 'kevin-branch' of https://github.com/bhklab/med-imagetoo…
fishingguy456 Jun 17, 2022
d8ff8d7
moved autotest changes to autopipeline and addede a few CLI args
fishingguy456 Jun 17, 2022
a786724
getting ready for merge to live
skim2257 Jun 18, 2022
e51fe82
test_components, test_modalities works with new AutoPipeline
skim2257 Jun 19, 2022
b138fe2
overwrite changes and error fix for nan paths again
fishingguy456 Jun 20, 2022
13f90fd
Merge branch 'kevin-branch' of https://github.com/bhklab/med-imagetoo…
fishingguy456 Jun 20, 2022
c6a5f4d
fixed if statement
fishingguy456 Jun 21, 2022
7a47740
joblib parallel
Jun 21, 2022
269b66f
Merge branch 'kevin-branch' of github.com:bhklab/med-imagetools into …
Jun 21, 2022
abc0428
warnings for missing patients
fishingguy456 Jun 22, 2022
6729aa5
summary messages
fishingguy456 Jun 22, 2022
81d6795
updated, passing tests. Updated version to 0.4
skim2257 Jun 22, 2022
c5b2087
Merge branch 'kevin-branch' of github.com:bhklab/imgtools into kevin-…
skim2257 Jun 22, 2022
7bc3588
update test
skim2257 Jun 22, 2022
67ef10d
yaml path cli
fishingguy456 Jun 23, 2022
d0b34aa
Merge branch 'kevin-branch' of https://github.com/bhklab/med-imagetoo…
fishingguy456 Jun 23, 2022
fdeabd1
yaml error check
fishingguy456 Jun 23, 2022
4745da2
pandas error
fishingguy456 Jun 23, 2022
a9a297e
Fixed read_dicom_auto
skim2257 Jun 24, 2022
eb8fb65
skips series check if seris is None
skim2257 Jun 24, 2022
d355cf5
updated readme to reflect v0.4 changes
skim2257 Jun 24, 2022
84d607f
updated readme
skim2257 Jun 24, 2022
6a02036
minor change
fishingguy456 Jun 24, 2022
8bd0a0f
remove .idea
skim2257 Jun 24, 2022
cf18c39
remote .idea
skim2257 Jun 24, 2022
38ed924
Merge branch 'kevin-branch' of github.com:bhklab/imgtools into kevin-…
skim2257 Jun 24, 2022
7d5b46a
git ignore
fishingguy456 Jun 24, 2022
c1d61ee
Merge branch 'kevin-branch' of https://github.com/bhklab/med-imagetoo…
fishingguy456 Jun 24, 2022
cdf7df5
transpose for nnunet
fishingguy456 Jun 28, 2022
0d53000
skip if no mask for nnunet and nnunet folder names
fishingguy456 Jun 28, 2022
67dda7d
merges
Jun 28, 2022
0137879
bugs in nnunet folder stuff
fishingguy456 Jun 29, 2022
96579ab
Merge branch 'nnunet-demo' of https://github.com/bhklab/med-imagetool…
fishingguy456 Jun 29, 2022
7c0465a
rename nnunetutil (again)
fishingguy456 Jun 29, 2022
b1fa173
sorting the output streams
fishingguy456 Jun 29, 2022
7baeebd
shell script
fishingguy456 Jun 29, 2022
59a5110
shell script in autopipeline
fishingguy456 Jun 29, 2022
f47d3cb
bug
fishingguy456 Jun 29, 2022
9a522b7
forgot CopyInformation for nnunet
fishingguy456 Jun 29, 2022
e2b59f5
ignore deprecation warning
fishingguy456 Jun 29, 2022
546c550
moved sh file down one dir
fishingguy456 Jun 29, 2022
8e00df5
set -e for stopping execution if there is an error
fishingguy456 Jun 29, 2022
c08a379
broken checker for missing labels
fishingguy456 Jun 30, 2022
7249b23
train test fix for 1 patient
fishingguy456 Jul 4, 2022
486abd5
fix for broken self.existing_roi_names caused by joblib
fishingguy456 Jul 4, 2022
ca1e3d8
added autotest to gitignore
fishingguy456 Jul 5, 2022
55893a1
sorted list for train test split
fishingguy456 Jul 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9]



steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
pip install -e .
pip install -r requirements.txt
- name: Import checking
run: |
python -c "import imgtools"
57 changes: 57 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: master-tests

on:
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
python-version:
- 3.7
- 3.8
- 3.9

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest setuptools wheel twine
pip install -e .
pip install -r requirements.txt
- name: Import checking
run: |
python -c "import imgtools"
- name: Run pytest
run: |
pytest tests
- name: Build binary wheel and a source tarball
run: |
python setup.py install
python setup.py sdist bdist_wheel
- name: Build app (Windows)
if: success() && startsWith(matrix.os,'Windows')
env:
USERNAME: ${{ secrets.pypi_username }}
KEY: ${{ secrets.pypi_pw }}
run: |
python -m twine upload --skip-existing -u $env:USERNAME -p $env:KEY dist/*
- name: Build app (Ubuntu / macOS)
if: success() && startsWith(matrix.os, 'Windows') == false
env:
USERNAME: ${{ secrets.pypi_username }}
KEY: ${{ secrets.pypi_pw }}
run: |
python -m twine upload --skip-existing -u $USERNAME -p $KEY dist/*
43 changes: 43 additions & 0 deletions .github/workflows/manual-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: manual-test

on:
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
python-version:
- 3.7
- 3.8
- 3.9

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
pip install -e .
pip install -r requirements.txt
- name: Import checking
run: |
python -c "import imgtools"
- name: Run pytest
run: |
pytest tests
- name: Slack Notification
if: ${{always() && matrix.os == 'ubuntu-latest'}}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# test scripts
examples/adsf.py
examples/autotest.py
.idea

#vscode files
/.idea

#vscode files
/.idea

# data
data
examples/data/tcia_n*
Expand Down
134 changes: 109 additions & 25 deletions examples/autotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import glob
import pickle
import struct
from matplotlib.style import available
import numpy as np
import sys
import warnings
Expand Down Expand Up @@ -95,8 +96,30 @@ def __init__(self,
warn_on_error=warn_on_error)
self.overwrite = overwrite
# pipeline configuration
self.input_directory = pathlib.Path(input_directory).as_posix()
self.input_directory = pathlib.Path(input_directory).as_posix()
self.output_directory = pathlib.Path(output_directory).as_posix()
study_name = os.path.split(self.input_directory)[1]
if is_nnunet:
self.base_output_directory = self.output_directory
if not os.path.exists(pathlib.Path(self.output_directory, "nnUNet_preprocessed").as_posix()):
os.makedirs(pathlib.Path(self.output_directory, "nnUNet_preprocessed").as_posix())
if not os.path.exists(pathlib.Path(self.output_directory, "nnUNet_trained_models").as_posix()):
os.makedirs(pathlib.Path(self.output_directory, "nnUNet_trained_models").as_posix())
self.output_directory = pathlib.Path(self.output_directory, "nnUNet_raw_data_base",
"nnUNet_raw_data").as_posix()
if not os.path.exists(self.output_directory):
os.makedirs(self.output_directory)
all_nnunet_folders = glob.glob(pathlib.Path(self.output_directory, "*", " ").as_posix())
available_numbers = list(range(500, 1000))
for folder in all_nnunet_folders:
folder_name = os.path.split(os.path.split(folder)[0])[1]
if folder_name.startswith("Task") and folder_name[4:7].isnumeric() and int(folder_name[4:7]) in available_numbers:
available_numbers.remove(int(folder_name[4:7]))
if len(available_numbers) == 0:
raise Error("There are not enough task ID's for the nnUNet output. Please make sure that there is at least one task ID available between 500 and 999, inclusive")
task_folder_name = f"Task{available_numbers[0]}_{study_name}"
self.output_directory = pathlib.Path(self.output_directory, task_folder_name).as_posix()
self.task_id = available_numbers[0]
self.spacing = spacing
self.existing = [None] #self.existing_patients()
self.is_nnunet = is_nnunet
Expand All @@ -109,9 +132,12 @@ def __init__(self,
self.label_names = {}
self.ignore_missing_regex = ignore_missing_regex

if roi_yaml_path != "" and not read_yaml_label_names:
warnings.warn("The YAML will not be read since it has not been specified to read them. To use the file, run the CLI with --read_yaml_label_names")

roi_path = pathlib.Path(self.input_directory, "roi_names.yaml").as_posix() if roi_yaml_path == "" else roi_yaml_path
if read_yaml_label_names:
if os.path.exists(roi_yaml_path):
if os.path.exists(roi_path):
with open(roi_path, "r") as f:
try:
self.label_names = yaml.safe_load(f)
Expand Down Expand Up @@ -173,6 +199,7 @@ def __init__(self,
os.mkdir(pathlib.Path(self.output_directory,".temp").as_posix())

self.existing_roi_names = {"background": 0}
# self.existing_roi_names.update({k:i+1 for i, k in enumerate(self.label_names.keys())})

def glob_checker_nnunet(self, subject_id):
folder_names = ["imagesTr", "labelsTr", "imagesTs", "labelsTs"]
Expand Down Expand Up @@ -216,7 +243,7 @@ def process_one_subject(self, subject_id):
subject_modalities = set() # all the modalities that this subject has
num_rtstructs = 0

for i, colname in enumerate(self.output_streams):
for i, colname in enumerate(sorted(self.output_streams)): #CT comes before MR before PT before RTDOSE before RTSTRUCT
modality = colname.split("_")[0]
subject_modalities.add(modality) #set add

Expand Down Expand Up @@ -300,21 +327,41 @@ def process_one_subject(self, subject_id):
else:
raise ValueError("You need to pass a reference CT or PT/PET image to map contours to.")

if mask is None: #ignored the missing regex
return

if mask is None: #ignored the missing regex, and exit the loop
if self.is_nnunet:
image_test_path = pathlib.Path(self.output_directory, "imagesTs").as_posix()
image_train_path = pathlib.Path(self.output_directory, "imagesTr").as_posix()
if os.path.exists(image_test_path):
all_files = glob.glob(pathlib.Path(image_test_path, "*.nii.gz").as_posix())
# print(all_files)
for file in all_files:
if subject_id in os.path.split(file)[1]:
os.remove(file)
if os.path.exists(image_train_path):
all_files = glob.glob(pathlib.Path(image_train_path, "*.nii.gz").as_posix())
# print(all_files)
for file in all_files:
if subject_id in os.path.split(file)[1]:
os.remove(file)
warnings.warn(f"Patient {subject_id} is missing a complete image-label pair")
return
else:
break

for name in mask.roi_names.keys():
if name not in self.existing_roi_names.keys():
self.existing_roi_names[name] = len(self.existing_roi_names)
mask.existing_roi_names = self.existing_roi_names
# print(self.existing_roi_names,"alskdfj")

# save output
print(mask.GetSize())
mask_arr = np.transpose(sitk.GetArrayFromImage(mask))

if self.is_nnunet:
sparse_mask = mask.generate_sparse_mask().mask_array
sparse_mask = np.transpose(mask.generate_sparse_mask().mask_array)
sparse_mask = sitk.GetImageFromArray(sparse_mask) #convert the nparray to sitk image
sparse_mask.CopyInformation(image)
if "_".join(subject_id.split("_")[1::]) in self.train:
self.output(subject_id, sparse_mask, output_stream, nnunet_info=self.nnunet_info, label_or_image="labels") #rtstruct is label for nnunet
else:
Expand Down Expand Up @@ -379,24 +426,44 @@ def save_data(self):
subject_id = os.path.splitext(filename)[0]
with open(file,"rb") as f:
metadata = pickle.load(f)
self.output_df.loc[subject_id, list(metadata.keys())] = list(metadata.values())
np.warnings.filterwarnings('ignore', category=np.VisibleDeprecationWarning)
self.output_df.loc[subject_id, list(metadata.keys())] = list(metadata.values()) #subject id targets the rows with that subject id and it is reassigning all the metadata values by key
folder_renames = {}
for col in self.output_df.columns:
if col.startswith("folder"):
self.output_df[col] = self.output_df[col].apply(lambda x: x if not isinstance(x, str) else pathlib.Path(x).as_posix().split(self.input_directory)[1][1:]) # rel path, exclude the slash at the beginning
folder_renames[col] = f"input_{col}"
self.output_df.rename(columns=folder_renames, inplace=True) #append input_ to the column name
self.output_df.to_csv(self.output_df_path)
self.output_df.to_csv(self.output_df_path) #dataset.csv

shutil.rmtree(pathlib.Path(self.output_directory, ".temp").as_posix())
if self.is_nnunet:

if self.is_nnunet: #dataset.json for nnunet and .sh file to run to process it
imagests_path = pathlib.Path(self.output_directory, "imagesTs").as_posix()
images_test_location = imagests_path if os.path.exists(imagests_path) else None
# print(self.existing_roi_names)
generate_dataset_json(pathlib.Path(self.output_directory, "dataset.json").as_posix(),
pathlib.Path(self.output_directory, "imagesTr").as_posix(),
images_test_location,
tuple(self.nnunet_info["modalities"].keys()),
{v:k for k, v in self.existing_roi_names.items()},
os.path.split(self.input_directory)[1])
os.path.split(self.input_directory)[1])
_, child = os.path.split(self.output_directory)
shell_path = pathlib.Path(self.output_directory, child.split("_")[1]+".sh").as_posix()
if os.path.exists(shell_path):
os.remove(shell_path)
with open(shell_path, "w", newline="\n") as f:
output = "#!/bin/bash\n"
output += "set -e"
output += f'export nnUNet_raw_data_base="{self.base_output_directory}/nnUNet_raw_data_base"\n'
output += f'export nnUNet_preprocessed="{self.base_output_directory}/nnUNet_preprocessed"\n'
output += f'export RESULTS_FOLDER="{self.base_output_directory}/nnUNet_trained_models"\n\n'
output += f'nnUNet_plan_and_preprocess -t {self.task_id} --verify_dataset_integrity\n\n'
output += 'for (( i=0; i<5; i++ ))\n'
output += 'do\n'
output += f' nnUNet_train 3d_fullres nnUNetTrainerV2 {os.path.split(self.output_directory)[1]} $i --npz\n'
output += 'done'
f.write(output)


def run(self):
Expand All @@ -411,7 +478,11 @@ def run(self):
if subject_id.split("_")[1::] not in patient_ids:
patient_ids.append("_".join(subject_id.split("_")[1::]))
if self.is_nnunet:
self.train, self.test = train_test_split(patient_ids, train_size=self.train_size, random_state=self.random_state)
if self.train_size == 1:
self.train = patient_ids
self.test = []
else:
self.train, self.test = train_test_split(sorted(patient_ids), train_size=self.train_size, random_state=self.random_state)
else:
self.train, self.test = [], []
# Note that returning any SimpleITK object in process_one_subject is
Expand All @@ -420,16 +491,17 @@ def run(self):
print("Dataset already processed...")
shutil.rmtree(pathlib.Path(self.output_directory, ".temp").as_posix())
else:
Parallel(n_jobs=self.n_jobs, verbose=verbose)(
Parallel(n_jobs=self.n_jobs, verbose=verbose, require='sharedmem')(
delayed(self._process_wrapper)(subject_id) for subject_id in subject_ids)
# for subject_id in subject_ids:
# self._process_wrapper(subject_id)
self.save_data()
all_patient_names = glob.glob(pathlib.Path(self.input_directory, "*"," ").as_posix()[0:-1])
all_patient_names = [os.path.split(os.path.split(x)[0])[1] for x in all_patient_names]
for e in all_patient_names:
if e not in patient_ids:
warnings.warn(f"Patient {e} does not have proper DICOM references")
if not self.is_nnunet:
all_patient_names = glob.glob(pathlib.Path(self.input_directory, "*"," ").as_posix()[0:-1])
all_patient_names = [os.path.split(os.path.split(x)[0])[1] for x in all_patient_names]
for e in all_patient_names:
if e not in patient_ids:
warnings.warn(f"Patient {e} does not have proper DICOM references")


if __name__ == "__main__":
Expand All @@ -451,17 +523,29 @@ def run(self):
# overwrite=True,
# nnunet_info={"study name": "NSCLC-Radiomics-Interobserver1"})

pipeline = AutoPipeline(input_directory="C:/Users/qukev/BHKLAB/larynx/radcure",
output_directory="C:/Users/qukev/BHKLAB/larynx_output",
pipeline = AutoPipeline(input_directory="C:/Users/qukev/BHKLAB/hnscc_testing/HNSCC",
output_directory="C:/Users/qukev/BHKLAB/hnscc_testing_output",
modalities="CT,RTSTRUCT",
visualize=False,
overwrite=True,
# is_nnunet=True,
# train_size=0.5,
is_nnunet=True,
train_size=1,
# label_names={"GTV":"GTV.*", "Brainstem": "Brainstem.*"},
# read_yaml_label_names=True, # "GTV.*",
# ignore_missing_regex=True
)
read_yaml_label_names=True, # "GTV.*",
ignore_missing_regex=True,
roi_yaml_path="C:/Users/qukev/BHKLAB/roi_names.yaml")
# pipeline = AutoPipeline(input_directory="C:/Users/qukev/BHKLAB/larynx/radcure",
# output_directory="C:/Users/qukev/BHKLAB/larynx_output",
# modalities="CT,RTSTRUCT",
# visualize=False,
# overwrite=True,
# is_nnunet=True,
# train_size=1,
# # label_names={"GTV":"GTV.*", "Brainstem": "Brainstem.*"},
# read_yaml_label_names=True, # "GTV.*",
# ignore_missing_regex=True,
# roi_yaml_path="C:/Users/qukev/BHKLAB/roi_names.yaml"
# )

# pipeline = AutoPipeline(input_directory="C:/Users/qukev/BHKLAB/dataset/manifest-1598890146597/NSCLC-Radiomics-Interobserver1",
# output_directory="C:/Users/qukev/BHKLAB/autopipelineoutput",
Expand Down
Loading