Skip to content

Dwipreproc: -align_seepi option#1159

Merged
Lestropie merged 18 commits intodevfrom
dwipreproc_alignment
Oct 24, 2017
Merged

Dwipreproc: -align_seepi option#1159
Lestropie merged 18 commits intodevfrom
dwipreproc_alignment

Conversation

@Lestropie
Copy link
Member

OK, here we go again... 😟

Related to #874, #1051, #1084.

An explicit option -align_seepi is added to the dwipreproc script, which instructs the script that the user wishes to enforce alignment between the inhomogeneity field as estimated by topup, and the estimations & corrections performed by eddy. It does this by ensuring that the first volume in the series input to topup is precisely the same volume as the first volume in the series input to eddy.

More specifics & addendums:

  • If the volumes within the -se_epi input 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_seepi option is provided, the script will concatenate the DWI b=0 volumes with the -se_epi input, 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 to topup. 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 the topup / eddy silent mutual agreement regarding the reference space.

  • If the -se_epi input image does not match the DWI voxel grid, it is immediately re-gridded to the DWI voxels. Even if the -align_seepi option is not used, it's still necessary for the topup estimated field and the DWIs input to eddy to be defined on the same grid: eddy appears to perform some internal concatenation step between these data, and so errors out if they don't match. Reports here and here.

  • If -align_seepi is 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.

  • topup cannot 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 to topup by one voxel along relevant axes. However this removes image information, and stopped working when eddy started 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 after eddy has 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 alternative dwipreproc alignment 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...

Lestropie and others added 17 commits July 12, 2017 18:31
- 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.
@Lestropie
Copy link
Member Author

Closes #1071.

@Lestropie
Copy link
Member Author

Took me a lot of attempts, but this finally passed testing...

Merging as I've got multiple changes to dwipreproc stacking up, and this is unlikely to get more testing than I've already thrown at it by just sitting here. So I'm hoping to get all of the changes into dev, and then have our RAs giving all of the changes a good testing.

@Lestropie Lestropie merged commit 0b0b92d into dev Oct 24, 2017
@Lestropie Lestropie deleted the dwipreproc_alignment branch October 24, 2017 01:21
@Lestropie Lestropie mentioned this pull request Oct 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant