`BSplineFieldTransform` ignores `order`

Open
#302 0 comments 0 reactions 0 assignees View on GitHub

@effigies is already working on this.

Since Nov 22, 2026.

  • #304 by @effigies — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
numpy, python
Domain
data

Research direction

Start in nitransforms/nonlinear.py at BSplineFieldTransform, which stores order but evaluates cubic regardless; trace where map builds the spline coefficients and where the interpolation order is actually passed (likely scipy.ndimage.map_coordinates/spline_filter). Read the toy reproduction in the issue first and run it to confirm cubic and quartic agree today. Done means the evaluation honours odd orders, even orders raise a clear error, and existing cubic behaviour and tests still pass.

Written by the indexing model from the issue text.

Description

BSplineFieldTransform stores order but always evaluates a cubic spline. order only enters __eq__, so transforms that map every point the same way compare unequal. An unsupported order should raise rather than fall back to cubic.

Really, we should error on even values and support odd values. TIL that even-ordered splines are a thing. I've only ever seen odd, but NdBSpline appears to support even orders.

Reproduction

import nibabel as nb
import numpy as np
from nitransforms.nonlinear import BSplineFieldTransform

rng = np.random.default_rng(0)
coeffs = nb.Nifti1Image(rng.normal(size=(10, 10, 10, 3)).astype("float32"), np.eye(4))
cubic = BSplineFieldTransform(coeffs)
quartic = BSplineFieldTransform(coeffs, order=4)
points = rng.uniform(2, 7, size=(5, 3))

assert cubic != quartic
assert not np.allclose(cubic.map(points), quartic.map(points))
Dominant language
Python
Stars
36
Forks
18
Avg merge
1h 24m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nipy/nitransforms

All issues in nipy/nitransforms

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.