diff --git a/.flake8 b/.flake8 index bfead2c..3c7ab46 100644 --- a/.flake8 +++ b/.flake8 @@ -1,2 +1,3 @@ [flake8] max-line-length = 79 +extend-ignore = W503 diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index e6cc139..ffb42f5 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -8,22 +8,15 @@ template: | $CHANGES categories: - title: 🚀 Features - labels: - - breaking - - enhancement + labels: [breaking, enhancement] - title: 🐛 Bug Fixes - labels: - - bug + labels: [bug] - title: 🧰 Maintenance - labels: - - maintenance - - test + labels: [maintenance, test] - title: 📝 Documentation - labels: - - documentation + labels: [documentation] -exclude-labels: - - skip_changelog +exclude-labels: [skip_changelog] change-template: '- $TITLE @$AUTHOR (#$NUMBER)' change-title-escapes: \<*_& # You can add # and @ to disable mentions, and add ` to disable code blocks. @@ -33,13 +26,7 @@ version-resolver: # labels: # - 'breaking' minor: - labels: - - breaking - - enhancement + labels: [breaking, enhancement] patch: - labels: - - maintenance - - bug - - test - - documentation + labels: [maintenance, bug, test, documentation] default: patch diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 234d86b..b3e2354 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -91,9 +91,9 @@ jobs: # with: # python-version: '3.9' - # #---------------------------------------------- - # # ----- install & configure poetry ----- - # #---------------------------------------------- + # #---------------------------------------------- + # # ----- install & configure poetry ----- + # #---------------------------------------------- # - name: Install Poetry # uses: snok/install-poetry@v1 # with: diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index ac472f9..ffe18b2 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -3,13 +3,9 @@ name: Lint workflow on: push: - branches: - - '*' - - '!push-action/*' + branches: ['*', '!push-action/*'] pull_request: - branches: - - '*' - - '!push-action/*' + branches: ['*', '!push-action/*'] jobs: quality: diff --git a/.gitignore b/.gitignore index 46c0d93..262cf90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ # Local poetry config poetry.toml +**/__pycache__ diff --git a/labelmerge/workflow/scripts/labelmerge.py b/labelmerge/workflow/scripts/labelmerge.py index c146344..94d82c2 100644 --- a/labelmerge/workflow/scripts/labelmerge.py +++ b/labelmerge/workflow/scripts/labelmerge.py @@ -16,7 +16,7 @@ def load_atlas(atlas_path: PathLike): """Loading relevant atlas data""" atlas = nib.load(atlas_path) - data = atlas.get_fdata().astype(np.ushort) + data = atlas.get_fdata().astype(np.int_) header = atlas.header affine = atlas.affine @@ -58,6 +58,15 @@ def split_labels( if drops is None: drops = [] unique_vals = np.unique(atlas[atlas > 0]) + all_labels: pd.Series[int] = metadata["index"] + if not set(unique_vals) <= set(all_labels): + unlabeled_vals = ", ".join( + str(val) for val in set(unique_vals) - set(all_labels) + ) + raise MetadataError( + f"Labels with indices {unlabeled_vals} from {prefix}atlas not " + "found in metadata table" + ) normal_ds = xr.Dataset( dict( [ @@ -73,7 +82,7 @@ def split_labels( dict( [ assemble_mask(atlas, metadata, label, prefix) - for label in unique_vals + for label in all_labels if label in exceptions ] )