Skip to content

Commit

Permalink
Change image_utils.py to work with nnunetv2 (#17)
Browse files Browse the repository at this point in the history
* Change `image_utils.py` to work with nnunetv2 predictions and ground truth labels with multi-class segmentations. (#17)
* Update supported Python versions to 3.8 - 3.11
* Increase version to 1.4.6

---------

Co-authored-by: Joeran Bosma <[email protected]>
  • Loading branch information
NataliaAlves13 and joeranbosma authored May 6, 2024
1 parent 9d0318c commit f35b470
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9']
python-version: ['3.8', '3.11']

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ platforms = unix, linux, osx, cygwin, win32
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11

[options]
packages =
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def run(self):
long_description = fh.read()

setuptools.setup(
version='1.4.5', # also update version in metrics.py -> version
version='1.4.6', # also update version in metrics.py -> version
author_email='[email protected]',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
5 changes: 4 additions & 1 deletion src/picai_eval/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def read_image(path: PathLike):
elif '.nii' in path or '.mha' in path or 'mhd' in path:
return sitk.GetArrayFromImage(sitk.ReadImage(path))
elif '.npz' in path:
return np.load(path)['softmax'].astype('float32')[1] # nnUnet format
# read the nnU-Net format
data = np.load(path)
data = data["softmax"] if "softmax" in data else data["probabilities"]
return data.astype("float32")[1]
else:
raise ValueError(f"Unexpected file path. Supported file formats: .nii(.gz), .mha, .npy and .npz. Got: {path}.")

Expand Down

0 comments on commit f35b470

Please sign in to comment.