Synb0 for dwifslpreproc: How?

Hi all,

I am currently analyzing a dataset (b=1000, 64dir, PE-dir=j-) without any RPE acquisitions and I am using Synb0-DISCO. This topic may cover both Synb0 and MRtrix, and I want to double-check whether I have done things correctly:

The steps for each subject:

  1. Denoise and Gibbs ringing removal, and then b0 extraction
  2. Provide acqparams.txt as: [0 -1 0 readout; 0 -1 0 0]
  3. Run Synb0-DISCO with OUTPUTS and INPUTS in the same main analysis folder
  4. dwifslpreproc dwi_denoised_unringed.mif dwi_preprocessed.mif -rpe_none -pe_dir j- -readout readout -eddy_options=" …/Synb0_outputs/topup"

Any comments?

Best,
Amir

Hi Amir

I’m not going to weigh in on the “correctness” of your approach, because I don’t know any better. But since I’ve also done some experiments with synb0-disco I thought I’d document my steps here for you so we can compare notes :slight_smile:

What I remember is that I had quite a bit of fiddling around to do to get the directions right, maybe due to the interactions of strides / pe dir? I have vague memories of distortion corrections applied the wrong way (so exaggerating the distortion) and struggling to reproduce results between dwifslpreproc, the topup outputs created by synb0-disco, and manually using topup.

Anyhow, this is the process I seem to have ended up with.

  1. :ballot_box_with_check: dwidenoise → mrdegibbs → INPUTS/b0.nii.gz (I don’t have a record of the exact way I extracted b0.nii.gz
  2. :ballot_box_with_check: same here
    cat synb0-disco/INPUTS/acqparams.txt
    0 -1 0 0.05225
    0 -1 0 0
    
  3. :ballot_box_with_check: (I had to run synb0-disco in singularity on an HCP cluster because of RAM limitations)
  4. This part I did differently, again not entirely sure why, but I opted to do both topup and eddy using the dwifslpreproc wrapper, so my commands look like this:
    $ mrconvert synb0-disco/OUTPUTS/b0_all.nii.gz synb0_out.mif -import_pe_table synb0-disco/INPUTS/acqparams.txt -strides '-1,+2,+3,+4'
    # where eddy_indices is as many 1s as volumes in degibbs.mif, 31 in my case
    $ cat eddy_indices.txt
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    $ mrconvert degibbs.mif eddy_in.mif  -import_pe_eddy synb0-disco/INPUTS/acqparams.txt eddy_indices.txt -strides '-1,+2,+3,+4'
    $ dwifslpreproc eddy_in.mif topup_eddy_done.mif -rpe_header -se_epi synb0_out.mif
    

Not particularly helpful in validating your approach I’m afraid, but I usually find it useful seeing what others have done. Good luck, and I’d be interested to hear about what you think of the results!

Fiona

2 Likes

Hi Fiona,

Thanks for your reply, and yes, I am having the same struggle as yours most possibly due to the interactions of strides between T1 and b0s. The pipeline I used generated topup_fieldcoeff.nii.gz with anterior-posterior being reversed (see below; look for the eyeballs in posterior!). I am not sure whether Left-Right was also distorted or not. This resulted in an extreme distortion in the preprocessing step.

So, what I did was to run fslreorient2std on both b0 and T1 in the INPUT folder, rerun Synb0 without any flags, and then pass the topup outputs to the dwifslpreproc.

The results are so far so good!

Amir

1 Like

Hi Fiona,

I am trying to replicate your pipeline for my current analyses, however for the command -import_pe_eddy, I don’t understand which information eddy_indices.txt holds and from which function this is the output. Is this related to the Synb0-DISCO pipeline, or pre-processing steps using MRtrix?

Best,
Bastiaan

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

1 Like

Thank you Fiona for your elaborate answer! It provides me with a deeper understanding of how the functions work. I managed to get everything set up and working appropriately. The EPI distortion correction looks great.

Best,
Bastiaan

1 Like