# Synb0 for dwifslpreproc: How?

**URL:** https://community.mrtrix.org/t/synb0-for-dwifslpreproc-how/6386
**Category:** Uncategorized
**Created:** [February 9, 2023, 3:16pm UTC](https://community.mrtrix.org/t/synb0-for-dwifslpreproc-how/6386 "2023-02-09T15:16:14Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![fionaEyoung](https://community.mrtrix.org/user_avatar/community.mrtrix.org/fionaeyoung/32/3826_2.png) [@fionaEyoung](https://community.mrtrix.org/u/fionaEyoung)
#### Post date: [April 26, 2024, 12:31pm UTC](https://community.mrtrix.org/t/synb0-for-dwifslpreproc-how/6386/5 "2024-04-26T12:31:04Z")

</div>

Hi Bastian

It’s been some time since I did this (and I don’t have the files to hand unfortunately) but I believe the key is in the comment line in that code snippet

> [@fionaEyoung](#):
>
> `# where eddy_indices is as many 1s as volumes in degibbs.mif, 31 in my case`

This isn’t the output from any function, it’s simply a text file I wrote manually, and is just a list of n 1s where n is the size of the 4th dimension in your input DWI file.

> **Here is some background that might make things clearer**
>
> I’ll take a step back. (And note, this is just the pipeline I came up with; there’s not necessarily an established “correct” way to use Synb0-disco and MRtrix together.)
> 
> Synb0 takes your (EPI distorted) b\_0 image, plus you aligned T1 image, and attempts to generate a perfect, hypothetical, undistorted b\_0 image corresponding to the impossible acqparams `0 -1 0 0` (i.e. readout=0, infinite pixel bandwidth).
> 
> Topup takes two input EPI images with different acqparams (usually _different PE directions_ but same readout time) to estimate the susceptibility field, which is in turn used to un-distort all the other DWI volumes. The trick of Synb0 is that, since we don’t have an RPE pair, we instead use this fake infinte bandwidth image as the second topup input, the difference between the two being in the _readout time_ (instead of the PE directions).
> 
> Having generated the fake second undistorted EPI image (`synb0-disco/OUTPUTS/b0_all.nii.gz`), the synb0 program will additionally run topup for you using `b0_all.nii.gz` as input, and then apply the estimated susceptibility field to the entire input series using `applytopup`. _This is the bit that I found didn’t work with my images, because of funky stride and PE-dir interactions, and where my pipeline differs from Amir’s_. The topup and applytopup results produced by synb0 did not properly undistort my images, as discussed above.  
> So instead, I directly took the generated undistorted b\_0 image (paired with the original input distorted b\_0, hence the filename `b0_all`) and ran topup and eddy manually using `dwifslpreproc`.

`dwifslpreproc` can use input options like `-rpe_pair` and `-pe_dir ap` to figure out the PE direction and readout info to feed to topup, which for the usual application is fine.  
But because we have a funky input with same PE and different readout times we have to encode this information in the header (analogous to the embedded DW gradient tables feature of `.mif` images) and tell `dwifslpreproc` we’ve done this with the `-rpe_header` flag (the only viable option out of the [compulsory `-rpe_*` options](https://mrtrix.readthedocs.io/en/latest/reference/commands/dwifslpreproc.html#options-for-specifying-the-acquisition-phase-encoding-design-note-that-one-of-the-rpe-options-must-be-provided)). This was already done for the paired b0 in the first step (`mrconvert ...`). We also need to include the PE information in the input DWI series (i.e. the whole acquisition we want to de-distort).

There are two ways of embedding the PE table using `mrconvert`, see here: [mrconvert - Options for exporting phase-encode tables](https://mrtrix.readthedocs.io/en/latest/reference/commands/mrconvert.html#options-for-exporting-phase-encode-tables). I opted for the

- -import\_pe\_eddy config indices import phase-encoding information from an EDDY-style config / index file pair

version. See the Eddy documentation ([2.3.3 “running eddy”](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy/UsersGuide#Running_eddy-1)) for information on the index file. I created the file `eddy_indices.txt` to indicate that every image (n=31 in my case) in the input series (`eddy_in.mif`) was acquired with PE parameters corresponding to line 1 of `acqparams.txt`.  
You could alternatively construct a PE table file `pe_table.txt` which would consist of the first line of `acqparams.txt` repeated n times and embed it using `-import_pe_table pe_table.txt` instead.

## TLDR

> [@Bastiaan\_van\_Tol](#):
>
> I don’t understand which information eddy\_indices.txt holds and from which function this is the output.

`eddy_indices.txt` is a manually constructed file containing a list of indices (starting from 1, not 0) indicating, for every volume in the input DWI series (`degibbs.mif` in the code snipped above), which line in the corresponding `acqparams.txt` file describes the phase encoding parameters for that volume. In this case, they’re all the same, because the original acquisition only used one phase encoding direction / readout time configuration, namely `0 -1 0 0.05225`.

This file is used to embed phase encoding information in the `.mif` headers, information used by `dwifslpreproc` to correctly apply topup using the synb0 generated undistorted b0 file.

Hope that helps!  
Fiona

---

_[View the full topic](https://community.mrtrix.org/t/synb0-for-dwifslpreproc-how/6386)._
