-
Notifications
You must be signed in to change notification settings - Fork 197
dwipreproc: Rework odd axis dimension solution #1084
Description
Currently, if the SE-EPI image series provided to topup has one or more spatial axis with odd dimension, these images are cropped by dwipreproc; if this is not performed, topup crashes when it tries to downsample the images. However the resulting field is currently passed to eddy as-is (and this worked for my testing in the past). This situation now however results in eddy crashing with:
"Image Exception : #3 :: Attempted to add images/ROIs of different sizes"
So, a few things then:
-
Could simply perform a corresponding crop of the DWI input series as well, and this would probably work in most situations.
-
It would however be better to pad the images by duplicating the outermost slice (for each problematic axis), then crop those padded slices out after
eddyhas completed. -
More fundamentally though, this would suggest that at some point, the output field from
topupand the input DWIs toeddyare being concatenated and hence assumed to lie on the same grid. Therefore, if the two main inputs todwipreproc(i.e. the DWI and the-se_epioption) are not on the same image grid, cropping / padding axes only solves one of a number of problems.
The most general solution would be to usetopupto estimate the field, register the input totopupto the input toeddy, re-grid the estimated field to that of the input DWIs, then runeddy. This is basically the second option described for dwipreproc: First volume alignment issue #874. It is however made more difficult by the fact that the primary output fromtopup(i.e. the one thateddyactually uses) is parameterised as spline coefficients, and therefore resampling these spline coefficients based on a new voxel grid would be quite tricky.
What I thought may have been the best approach is:
-
If the DWIs have one or more axes with odd dimension, pad appropriately.
-
If provided separately, resample the SE-EPI images to the same voxel size & dimensions as the DWIs.
-
Run
topup. -
Perform rigid-body registration such that the corrected output from
topup, when simulated to have the same phase-encoding as the first volume in theeddyinput, is aligned with that first volume in theeddyinput. -
Run
eddy.
This however would only work if eddy were to honour the header transformation in the topup output field image (the one containing the spline coefficients). If it doesn't (as I suspect is the case, given that it appears to be concatenating this field with the DWIs), then this approach doesn't work.
So, thinking aloud, here's an alternative:
-
Pad DWIs for odd dimensions as before
-
Run
topupon the native SE-EPI data (padding odd dimensions if necessary) -
Simulate what the
topupcorrected output image would look like if it had the same phase encoding as the first b=0 volume in the DWIs, and perform the rigid-body registration -
Resample the SE-EPI images to the (potentially padded) DWI voxel grid, incorporating the rigid-body transformation estimated in the previous step
-
Run
topupa second time, on these re-gridded SE-EPI images. -
Run
eddyin the knowledge that the estimated field is both aligned with, and on the same image grid as, the DWIs. -
Remove padding slices if necessary.
🤒