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.
If the bounding box of the target image goes outside the bounding box of the B-spline coefficient image, scipy will refuse to construct a design matrix. This is because the coordinates
x
(voxel indices translated into non-integral indices in the coefficient image's voxel space) may go below 0 or above the number of knots.This PR aims to work around this limitation without changing the logic on the grounds that we need the best approximation of the field at all locations within the target image. At the edges, the field is likely to get masked out anyway. This assumes that the fieldmap and target image are in register and the differences in their affines reflect real differences in FoV.
We have a default padding of 4 knots in each direction, which gets reduced to 2 by
BSpline.design_matrix
. This adds in a padding based on the min/max values ofx
. The padding is added tot
and then removed from the design matrix to ensure that the weights still correspond to the coefficients stored in the coefficient images.