# Preprocessing questions

**URL:** <https://community.mrtrix.org/t/preprocessing-questions/995>\
**Category:** Uncategorized\
**Created:** [June 23, 2017, 5:20pm UTC](https://community.mrtrix.org/t/preprocessing-questions/995 "2017-06-23T17:20:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![olie](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/o/c4cdca/32.png) [@olie](https://community.mrtrix.org/u/olie)\
**Post date:** [June 23, 2017, 5:20pm UTC](https://community.mrtrix.org/t/preprocessing-questions/995/1 "2017-06-23T17:20:35Z")

</div>

Dear All,

Here are some (very) basic/naive dwi preprocessing questions, please let me know if you have any thoughts on these.  
I have two sets acquired sequentially within the same scan session (each set contains 10 Xb=0 images acquired first in the respective set, then 60 dwi b=3000; 1st set PA, 2nd set AP encode direction, 2x2x2 mm resolution)

1. dwidenoise  
re influence of PE direction on noise, if any: should one apply denoising to each set separately then combine outputs, or combine both sets into a dwi.mif input then run dwidenoise?

2. dwipreproc  
as far as I know, fsl’s topup also corrects for intervolume motion for the b=0 images selected for distortion correction.  
Still, one could use both sets combined (dwi.mif) as input to dwipreproc with -rpe\_all, or rpe\_header flags, or use a mean b=0 (lowb.mif, 10x PA, 10XAP, resulted with dwiextract) for distortion correction, or more, use the 2-3 b=0 volumes in each set acquired closest in time to the dwi images (say lowb\_3.mif, im.8,9,10 from 1st set, and 8,9,10 from 2nd set) as advised at some point. Any preferences, and if so, what would be a simple quality check (including eyeballing the dwipreproc output)?

3. dwi-structural registration  
a. several posts on this forum have addressed this, and many experts here advocate registration of T1/aparc+aseg to the dwi, so that dwi remains ‘native’, while T1/aparc+aseg could be maintained in original resolution (see Kerstin’s commands here, [Registration of structural and diffusion weighted data](https://community.mrtrix.org/t/registration-of-structural-and-diffusion-weighted-data/203/4)), with transform to dwi space, usually resulting from 6 dof stored in the mif header. Could one use the same argument and transform dwi (after topup/eddy/dwipreproc) to T1 space, while keeping images at their original resolution, any issue with that (again, registration would here follow any motion/distortion correction)?  
b. for cost functions, I have seen correlation ration, mutual correlation, normalized mutual info, and BBR all used for this purpose, any clear winners?  
c. b=0 target image in registration, does this benefit from preparation, I have seen code examples like this (BIDS mrtrix connectome), but this is variably applied:  
dwiextract dwi.mif -bzero - | mrmath - mean - -axis 3 | mrcalc 1 - -div dwi\_mask.mif -mult - | mrconvert - - -stride -1,+2,+3 | mrhistmatch - T1\_BET’ + fsl\_suffix + ’ dwi\_pseudoT1.nii’)

4. dwimask output  
re: dilation for dwifod, I have seen 1 voxel (2 mm here) dilations in papers, is this what you recommend, if so how would you select n, as in  
maskfilter dwi\_mask.mif dwi\_mask\_dilated.mif -npass n.

Thank you for your prompt assist,

Octavian

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [June 27, 2017, 2:23am UTC](https://community.mrtrix.org/t/preprocessing-questions/995/2 "2017-06-27T02:23:55Z")

</div>

Hi Octavian,

> re influence of PE direction on noise, if any: should one apply denoising to each set separately then combine outputs, or combine both sets into a dwi.mif input then run `dwidenoise`?

Intuitively, concatenating the data feels like a better approach. However I do vaguely recall that there was some discussion around issues with the fitting of the MP distribution, where we were encountering problems if the processing kernel contained _too much_ data (either from a large spatial window, or a large number of volumes). But I don’t recall whether it was a fundamental issue, a software bug, or something else; hopefully @dchristiaens or @jdtournier can fill in.

> as far as I know, fsl’s `topup` also corrects for intervolume motion for the b=0 images selected for distortion correction.

Correct. It does however assume that the susceptibility field remains constant despite that motion, which is unfortunately not the case, but there’s not a whole lot we can do about that right now.

> Still, one could use both sets combined (dwi.mif) as input to `dwipreproc` with `-rpe_all`, or `rpe_header` flags, or use a mean b=0 (lowb.mif, 10x PA, 10XAP, resulted with `dwiextract`) for distortion correction …

If you do not manually define the _b_=0 images to be used for inhomogeneity field estimation using the `-se_epi` option, the script will itself execute `dwiextract` in order to access those volumes from the input DWI. So the outcome between these two approaches should be equivalent.

> … or more, use the 2-3 b=0 volumes in each set acquired closest in time to the dwi images (say lowb\_3.mif, im.8,9,10 from 1st set, and 8,9,10 from 2nd set) as advised at some point.

Using those _b_=0 images acquired closest in time to the DWIs is recommended not precisely due to being closest in time, but because rotation of the head between those volumes is likely to be smallest (and hence variation in the susceptibility field itself is minimised). But generally the _b_=0 images are interspersed between all of the DWIs, and hence no _b_=0 volume is particularly closer to “the DWIs” than any other, so you might as well use all of them. The primary motivation for that particular comment I think is that if you were to acquire a reversed phase-encode _b_=0 pair, then your DWIs, then 2 hours of other sequences, then finally another reversed phase-encode _b_=0 pair, you’d be better off discarding that final pair and only using the first pair.

> Any preferences, and if so, what would be a simple quality check (including eyeballing the `dwipreproc` output)?

Can’t really make any life-changing revelations here, other than to use the `-nocleanup` option and have a look at the intermediary images.

> Could one use the same argument and transform dwi (after `topup`/`eddy`/`dwipreproc`) to T1 space, while keeping images at their original resolution, any issue with that (again, registration would here follow any motion/distortion correction)?

Only issue is that it requires reorientation of the diffusion gradient vectors to account for the rotation component of the transformation being applied. `mrtransform` should now perform this rotation seamlessly when applying an estimated transform to a DWI series, making it easier than it used to be.

> _b_=0 target image in registration, does this benefit from preparation, I have seen code examples like this (BIDS mrtrix connectome), but this is variably applied:

That’s a very specific way of preparing for the rigid-body registration, which is based on [this method](http://www.sciencedirect.com/science/article/pii/S1053811915002451). I admittedly have not done extensive testing on the approach, nor on the performance of `mrregister` with images constructed in this way. Only comment I’ll throw in is that both _b_=0 and T1 images should ideally be B1 bias field corrected before applying this technique. Eventually [this method](https://www.researchgate.net/publication/307862882_Generating_a_T1-like_contrast_using_3-tissue_constrained_spherical_deconvolution_results_from_single-shell_or_multi-shell_diffusion_MR_data) will likely become a common approach to DWI-T1 registration, but it’s not yet available.

> re: dilation for `dwi2fod`, I have seen 1 voxel (2 mm here) dilations in papers, is this what you recommend, if so how would you select n

Depends on your application. When using ACT, I tend to apply a heavy dilation to guarantee that no valid streamline position in the 5TT image is devoid of diffusion model data. Indeed in this use case, providing a mask for `dwi2fod` isn’t really necessary at all, it’s just decreasing execution time slightly by omitting definite non-brain voxels, but false positives are far less detrimental than false negatives in such a mask. Without ACT, the extent of that mask can indeed influence the extent of streamlines propagation; I can’t really provide any advice there.

Rob

---

<div class="post-metadata">

**Author:** ![olie](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/o/c4cdca/32.png) [@olie](https://community.mrtrix.org/u/olie)\
**Post date:** [June 28, 2017, 9:02am UTC](https://community.mrtrix.org/t/preprocessing-questions/995/3 "2017-06-28T09:02:12Z")

</div>

Thank you, Rob, this is very helpful

---

<div class="post-metadata">

**Author:** ![Hamed](https://community.mrtrix.org/user_avatar/community.mrtrix.org/hamed/32/2871_2.png) [@Hamed](https://community.mrtrix.org/u/Hamed)\
**Post date:** [July 4, 2017, 9:13am UTC](https://community.mrtrix.org/t/preprocessing-questions/995/4 "2017-07-04T09:13:18Z")

</div>

Hi Rob

I have the same issue with the rev phase. I have 3 volumes (2 b0 and 1 b700) in AP and 102 (6 b0, 16 b700, 30 b1200, 50 b2800) volumes in PA with ~ 1 min interval between the 2 sets. What is the recommendation in this case given the possible subject movement between the 2 sets. Concatenate the 2 sets and then denoise or perform denoising for each set separately? Would denoising work for 3 volumes of Rev set? Also what would be the optimal -extent?

Thanks and cheers,  
Hamed

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [July 5, 2017, 12:09am UTC](https://community.mrtrix.org/t/preprocessing-questions/995/5 "2017-07-05T00:09:38Z")

</div>

Hi Hamed,

You won’t be able to run `dwidenoise` on the AP volumes alone; there simply won’t be enough image data within the spatial window for the algorithm to be applicable. I’d also throw away that single AP _b_=700 volume; it’s likely to only lead to confusion.

Subject motion between volumes is not a major concern for `dwidenoise`. The only requirement is that the noise level be approximately constant within the window; given the smoothness of the noise level relative to the magnitude of subject motion, I doubt this would cause an issue.

Where subject motion can be problematic is in `dwipreproc`: the current implementation is not ideal due to my misinterpretation of the interaction between `eddy` and `topup`. But you can solve the issue with a little manual manipulation. My suggestion would be:

- Generate an image with 4 volumes: The first two PA _b_=0 images, then the two AP _b_=0 images. This is used as the `-se_epi` input to `dwipreproc`.

- Run `dwidenoise` on just the PA images, then feed the result as the input to `dwipreproc`.

By ensuring that the first volume as input to `eddy` is also the first volume input to `topup`, the estimated inhomogeneity field should be used correctly.

I would not change the `-extent` parameter away from the default unless your acquisition is somehow exotic, or you have a definite justification for doing so.

Rob
