Conversation
- Check to see if both hears contain an echo time key-value, and give a warning if they differ (e.g. if one were to use a shorter TE for acquiring spin-echo EPI images just for estimating the inhomogeneity field, the technique employed here would no longer work, since topup would be estimating squared errors between those volumes and a b=0 volume from the DWIs). - If the DWIs and spin-echo EPI images are not defined on the same voxel grid, issue a warning, and re-sample the spin-echo EPI images onto the grid of the DWIs; this is necessary to enable concatenation of the first b=0 DWI volume at the start of the topup input.
This command calculates the inverse of a non-linear warp field.
Take the solution for achieving alignment between the inhomogeneity field estimated by topup and the corrections applied by eddy, which is unfortunately not applicable in all scenarios, and turn it into a command-line option. Solution is not yet tested. image.match(): Add option for maximum dimension to test. Grab some extra DICOM fields that may prove useful.
- Remove some errors introduced during the merging process. - Do some renaming of variables, to best separate the sources of data (i.e. 'dwi', 'se-epi') from the methods used (topup, eddy).
- In cases where the SE-EPI series has no phase-encoding contrast, and therefore the DWI b=0 volumes are merged with it, ensure that the appropriate components are and are not executed; e.g. check the TE / TR / flip angle, and check to see if DWI volume permitation is necessary (if the first b=0 volume is not the first volume), but don't perform an additional extraction of the first b=0 image. - Fix generation of mask from applytopup output depending on whether there is more than one phase-encoding direction present in the input DWIs. - image.match(): Apply less stringent threshold to translation component of transform matrix than that applied to the rotation component.
- Immediately exit if -align_seepi is provided but -se_epi is not. - In the situation where no -se_epi input is provided, it is still necessary to ensure that the first DWI volume provided to eddy is the first b=0 volume that was provided to topup. - Some tweaking of temporary image names to more accurately reflect flow of script, and some better running cleanup of temporary files.
Member
Author
|
Closes #1071. |
Member
Author
|
Took me a lot of attempts, but this finally passed testing... Merging as I've got multiple changes to |
Merged
This was referenced May 11, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
OK, here we go again... 😟
Related to #874, #1051, #1084.
An explicit option
-align_seepiis added to thedwipreprocscript, which instructs the script that the user wishes to enforce alignment between the inhomogeneity field as estimated bytopup, and the estimations & corrections performed byeddy. It does this by ensuring that the first volume in the series input totopupis precisely the same volume as the first volume in the series input toeddy.More specifics & addendums:
If the volumes within the
-se_epiinput do not contain any phase-encoding contrast, previously the script would immediately abort, as it was impossible to estimate the inhomogeneity field. Now, if this occurs and the-align_seepioption is provided, the script will concatenate the DWI b=0 volumes with the-se_epiinput, and re-check the requirement of phase-encoding contrast. This is to account for e.g. labs that acquire a single P>>A b=0 and then their A>>P DWIs; but also, if one is not going to acquire all DWIs with reversed phase-encoding, rather than e.g. acquiring one A>>P b=0, one P>>A b=0, then A>>P DWIs, for the same total acquisition time one could instead acquire ~ 5 P>>A b=0 images then A>>P DWIs, giving more data totopup. This is especially true for multi-band acquisitions due to the extra calibration time.If the first volume in the DWIs is not a b=0 (unlikely, but nevertheless possible), the DWI volumes are permuted such that the first b=0 volume becomes volume index 0, and then permuted back to their original order after
eddy. This is necessary due to thetopup/eddysilent mutual agreement regarding the reference space.If the
-se_epiinput image does not match the DWI voxel grid, it is immediately re-gridded to the DWI voxels. Even if the-align_seepioption is not used, it's still necessary for thetopupestimated field and the DWIs input toeddyto be defined on the same grid:eddyappears to perform some internal concatenation step between these data, and so errors out if they don't match. Reports here and here.If
-align_seepiis used, check header fields for information relating to TE, TR and flip angle, since these influence image contrast and may therefore invalidate the assumptions required for this option to work. Also capture these fields from DICOM import.topupcannot operate on images where one of the three spatial dimensions has an odd number of voxels; likely due to downsampling by a factor of 2 and experiencing a buffer overflow. Previously this was dealt with by cropping the image provided totopupby one voxel along relevant axes. However this removes image information, and stopped working wheneddystarted performing an internal concatenation step (since the DWIs were not also correspondingly cropped). This has been altered to not only manipulate both the DWI and SE-EPI images, but also to pad problematic axes with duplicate image information as opposed to cropping, and then crop the resulting series aftereddyhas completed. Therefore the image output by the script should always have the same size in the three spatial dimensions as the input image.warpinvert: New command, but not actually used (was going to be necessary for an alternativedwipreprocalignment approach).There's a bit of gymnastics going on, and a lot of possible code paths, so I'm not expecting that anyone's going to be able to spot issues from the code alone; but you never know.
I've tested it on a reasonable range of possible input data configurations, including presence & absence of the above confounds, and different
-rpe_*options. But ultimately it probably needs field testing...