`DenseFieldTransform.map()` distorts displacements near the edges of the field
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in nitransforms/nonlinear.py at the DenseFieldTransform.map() interpolation around lines 193-209, where absolute mapped positions are splined instead of the displacements themselves. Run the reproduction snippet from the issue to see the edge error, then check how the grid coordinates are added back after interpolation. Done means the constant 6 mm shift is recovered within the stated tolerance at every sample point, including the outer ones.
Written by the indexing model from the issue text.
Description
Off the voxel grid, map() interpolates the absolute mapped positions (grid coordinates plus displacements) with a cubic spline:
Reproduction
A constant 6mm shift should be recoverable to a reasonable tolerance:
import nibabel as nb
import numpy as np
from nitransforms.nonlinear import DenseFieldTransform
# 21^3 grid of 4 mm voxels spanning -40..40 mm; constant +6 mm x-shift
deltas = np.zeros((21, 21, 21, 3), dtype="float32")
deltas[..., 0] = 6.0
affine = nb.affines.from_matvec(np.eye(3) * 4, [-40] * 3)
xfm = DenseFieldTransform(nb.Nifti1Image(deltas, affine))
x = np.array([-39.5, -38.5, -30.5, -20.5, 0.5, 20.5, 30.5, 38.5, 39.5])
points = np.stack([x, np.full_like(x, 0.5), np.full_like(x, 0.5)], axis=1)
assert np.allclose(xfm.map(points) - points, [6, 0, 0], atol=1e-4)
Actual x shift:
>>> (xfm.map(points) - points)[:, 0]
array([5.60253403, 5.31986161, 5.95116826, 5.99918935, 5.99999812,
6.00081065, 6.04883174, 6.68013839, 6.39746597])
- Dominant language
- Python
- Stars
- 36
- Forks
- 18
- Avg merge
- 1h 24m
- Merged PRs (30d)
- 1
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nipy/nitransforms
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nipy/nitransforms#306 ·
-
Difficulty 3/5 Half a day Newbie friendliness 25/100
nipy/nitransforms#305 ·
-
`BSplineFieldTransform` ignores `order`Possibly taken @effigies claimed this 1 day ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 48/100
nipy/nitransforms#302 ·
-
`BSplineFieldTransform.to_field()` reuses the weights of its first referencePossibly taken @effigies claimed this 1 day ago. Open
Difficulty 3/5 Half a day Newbie friendliness 55/100
nipy/nitransforms#301 ·
-
`BSplineFieldTransform.to_field()` ignores the orientation of the reference gridPossibly taken @effigies claimed this 1 day ago. Open
Difficulty 3/5 Half a day Newbie friendliness 45/100
nipy/nitransforms#300 ·
All issues in nipy/nitransforms
Similar issues
-
eegprep-lean: set channel types from the Zarr group's channel_typePossibly taken @claude claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
sccn/eegprep#668 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
blacklanternsecurity/bbot#3679 ·
Maintainers usually reply within 2 days
-
Link Checker ReportOpenBot Type: Bug Type: Documentation
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
speakeasy-api/speakeasy#2159 ·
Maintainers usually reply within 1 day