Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #282 +/- ##
=======================================
Coverage 96.74% 96.74%
=======================================
Files 16 16
Lines 1994 1994
Branches 267 267
=======================================
Hits 1929 1929
Misses 41 41
Partials 24 24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6926d3c to
1428106
Compare
effigies
reviewed
Sep 5, 2025
Comment on lines
+333
to
+354
| @pytest.mark.xfail(reason="gh-281: applying a single 3D transform to 4D data") | ||
| def test_apply_single_3d_on_4d(): | ||
| """Apply one 3D transform across all timepoints of a 4D dataset.""" | ||
| nvols = 5 | ||
| data = np.zeros((10, 5, 5, nvols), dtype=np.float32) | ||
| for i in range(nvols): | ||
| data[i + 1, 2, 2, i] = i + 1 | ||
|
|
||
| img = nb.Nifti1Image(data, np.eye(4)) | ||
|
|
||
| mat = np.eye(4) | ||
| mat[0, 3] = -1.0 | ||
| ref = nb.Nifti1Image(np.zeros((10, 5, 5), dtype=np.uint8), np.eye(4)) | ||
| xfm = nitl.Affine(mat, reference=ref) | ||
|
|
||
| moved = apply(xfm, img, order=0) | ||
| moved_data = np.asanyarray(moved.dataobj) | ||
|
|
||
| assert moved_data.shape == data.shape | ||
| for i in range(nvols): | ||
| assert moved_data[i + 2, 2, 2, i] == i + 1 | ||
| assert moved_data[i + 1, 2, 2, i] == 0 |
Member
There was a problem hiding this comment.
At present, this could fail because checking the values after applying the transform is wrong. I think a much simpler test is:
Suggested change
| @pytest.mark.xfail(reason="gh-281: applying a single 3D transform to 4D data") | |
| def test_apply_single_3d_on_4d(): | |
| """Apply one 3D transform across all timepoints of a 4D dataset.""" | |
| nvols = 5 | |
| data = np.zeros((10, 5, 5, nvols), dtype=np.float32) | |
| for i in range(nvols): | |
| data[i + 1, 2, 2, i] = i + 1 | |
| img = nb.Nifti1Image(data, np.eye(4)) | |
| mat = np.eye(4) | |
| mat[0, 3] = -1.0 | |
| ref = nb.Nifti1Image(np.zeros((10, 5, 5), dtype=np.uint8), np.eye(4)) | |
| xfm = nitl.Affine(mat, reference=ref) | |
| moved = apply(xfm, img, order=0) | |
| moved_data = np.asanyarray(moved.dataobj) | |
| assert moved_data.shape == data.shape | |
| for i in range(nvols): | |
| assert moved_data[i + 2, 2, 2, i] == i + 1 | |
| assert moved_data[i + 1, 2, 2, i] == 0 | |
| @pytest.mark.xfail(reason="gh-281: applying a single 3D transform to 4D data", strict=True) | |
| def test_apply_single_3d_on_4d(): | |
| """Apply one 3D transform across all timepoints of a 4D dataset.""" | |
| img4d = nb.Nifti1Image(np.zeros((2, 3, 4, 5), np.eye(4)) | |
| ref3d = img4d.slicer[..., 0] | |
| xfm = nitl.Affine(np.eye(4)) | |
| # Just a smoke test. When this passes, we should validate the values. | |
| apply(xfm, img, reference=ref3d) |
I'm adding strict=True so that the test doesn't just sit around XPASSing when we should start validating values after that point.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
pytest nitransforms/tests/test_resampling.py::test_apply_single_3d_on_4d -qhttps://chatgpt.com/codex/tasks/task_e_689f54b6c3bc8330a3230878ab5c4454