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
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). 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. 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”) 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
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