`BSplineFieldTransform.to_field()` ignores the orientation of the reference grid
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- data-engineering
Direzione di ricerca
The bug is in grid_bspline_weights, which places target voxels in the control-point grid from voxel sizes and origin alone, ignoring direction cosines. Start with BSplineFieldTransform.to_field() and trace how it calls grid_bspline_weights, then run the two reproduction snippets from the issue. Done means both assertions pass for the flipped (diag -3, 3, 3) and the 30-degree rotated target grids, with the existing tests still green.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
grid_bspline_weights places the target voxels in the control-point grid using only the voxel sizes and the target origin. It ignores the direction cosines of both grids. When the reference is flipped, permuted or rotated relative to the coefficients, to_field() evaluates the spline at the wrong locations.
Reproduction
import nibabel as nb
import numpy as np
from nitransforms.base import ImageGrid
from nitransforms.nonlinear import BSplineFieldTransform
def centered_grid(linear, shape):
"""Affine for a grid of given shape, centered at the origin, with given linear part"""
affine = nb.affines.from_matvec(linear, -linear @ (np.array(shape) - 1) / 2)
return nb.Nifti1Image(np.zeros(shape), affine)
# A 10 mm lattice of 10 x 10 x 10 knots, centered at the origin
knots = ImageGrid(centered_grid(np.eye(3) * 10, (10, 10, 10)))
# Set coefficient to RAS position, which is linear and so exactly representable
coeffs = knots.ndcoords.reshape(10, 10, 10, 3).astype("float32")
xfm = BSplineFieldTransform(nb.Nifti1Image(coeffs, knots.affine))
# 30mm FoV is well within spline support, no extrapolation needed
las_target = centered_grid(np.diag([-3.0, 3, 3]), (11, 11, 11))
field = xfm.to_field(reference=las_target)
assert np.allclose(field._deltas.reshape(-1, 3), ImageGrid(las_target).ndcoords, atol=1e-3)
Same failure with a rotated grid:
COS, SIN = np.cos(np.pi / 6), np.sin(np.pi / 6)
oblique_target = centered_grid(np.array([[COS, -SIN, 0], [SIN, COS, 0], [0, 0, 1]]) * 3, (11, 11, 11))
field = xfm.to_field(reference=oblique_target)
assert np.allclose(field._deltas.reshape(-1, 3), ImageGrid(oblique_target).ndcoords, atol=1e-3)
- Lingua principale
- Python
- Stelle
- 36
- Fork
- 18
- Merge medio
- 1h 24m
- PR unite (30g)
- 1
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nipy/nitransforms
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nipy/nitransforms#307 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nipy/nitransforms#306 ·
-
DenseFieldTransform bugsAperta
Difficoltà 3/5 Mezza giornata Idoneità per principianti 25/100
nipy/nitransforms#305 ·
-
`BSplineFieldTransform` ignores `order`Forse già presa @effigies l’ha presa 1 giorno fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
nipy/nitransforms#302 ·
-
`BSplineFieldTransform.to_field()` reuses the weights of its first referenceForse già presa @effigies l’ha presa 1 giorno fa. Aperta
Difficoltà 3/5 Mezza giornata Idoneità per principianti 55/100
nipy/nitransforms#301 ·
Tutte le issue di nipy/nitransforms
Issue simili
-
flaky: test_fire_returns_thread_per_http_entry_on_head waits 5 s per dispatch worker on busy shardsApertastatus/accepted type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
microsoft/apm#5309 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug vector-store
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
EverMind-AI/Raven#1413 ·
I maintainer di solito rispondono entro 1 giorno
-
Tests: parallel pyinstallcheck runs oversubscribe the machine through nested TBB and BLAS poolsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
ACCESS-NRI/containerised-environments-infra#143 ·
I maintainer di solito rispondono entro 2 giorni