Skip to content

Commit a0935d9

Browse files
KumoLiuericspod
andauthored
Fix negative strides issue in NrrdReader (Project-MONAI#7809)
Fixes Project-MONAI#7798 ### Description Add copy to avoid negative strides when save spatial shape. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent 762b525 commit a0935d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

monai/data/image_reader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ def get_data(self, img: NrrdImage | list[NrrdImage]) -> tuple[np.ndarray, dict]:
13311331
header[MetaKeys.SPACE] = SpaceKeys.LPS # assuming LPS if not specified
13321332

13331333
header[MetaKeys.AFFINE] = header[MetaKeys.ORIGINAL_AFFINE].copy()
1334-
header[MetaKeys.SPATIAL_SHAPE] = header["sizes"]
1334+
header[MetaKeys.SPATIAL_SHAPE] = header["sizes"].copy()
13351335
[header.pop(k) for k in ("sizes", "space origin", "space directions")] # rm duplicated data in header
13361336

13371337
if self.channel_dim is None: # default to "no_channel" or -1

0 commit comments

Comments
 (0)