-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: Interpolation of B-Spline grid on the target EPI grid #294
Conversation
np.cross(ctrl_nii.affine[:-1, :-1].T, target_nii.affine[:-1, :-1].T), | ||
axis=1, | ||
), 0, atol=1e-3): | ||
raise RuntimeError("Image's and B-Spline's grids are not aligned.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coords[axis] = np.arange(sample_shape[axis], dtype=dtype) | ||
|
||
# Calculate the index component of samples w.r.t. B-Spline knots along current axis | ||
ijk_samples = (target_to_grid @ coords)[axis] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line addresses the problem stated in #289 in just one shot.
That's why at "fit" time, when the estimated fieldmap is applied to generate reportlets (and validate everything), the interpolation works (and yields the same output of topup, saving some details). But when it reaches the correction of the EPI, the B-Spline grid is still a grid, but it's not aligned with the EPI grid.
5e4bfd9
to
687ae2d
Compare
Cython improvement:
|
I have split this PR into smaller ones (#302, #301, #304, and #303). Since I had not managed to resolve the rotation issue, I'm going to open a fresh branch with the Cython code finally resolving this issue. (I believe that, in the presence of this rotation, there's no way around calculating the b-spline for all combinations of voxels and control points in three dimensions, and hence, Cython) |
@effigies, same test, with
So basically the same as our |
Could be worth pushing the cython implementation upstream into scipy? |
that'd be interesting :) I'm not sure I have the bandwidth:
so, happy to consider it if we find it necessary to go around our problems, but I don't know how much workload we will be able to take on. |
BTW:
(for some weird reason, |
I believe Anyway, agreed that it could be a deep rabbit hole and we should not block any of our process on it. I wonder if just posting your implementation as an issue on scipy could start the ball rolling and somebody else might eventually pick it up and do the integration work. |
This is something I can definitely do. I will try to first finish up the sdcflows problem and then think of how to make it more widely available. |
This PR fixes #289 and will address #218, although no solution (computationally tractable) has been found yet.