1dDW_Grad_o_Mat++ and DIFFPREP

Dear Afni experts,

about a while ago i was having issues running diffprep and fatproc on my dwi data. I tried using dtk and everything seems normal; the data makes sense. Is it possible to feed the siemens_64 gradient table to the 1dDW_Grad_o_Mat++ or DIFFPREP? just trying to explore if this would help.

Thanks,
-bit warrior

Hi, Bit-Warrior-

(DIFFPREP questions will have to go to the TORTOISE folks. I will just note that it is possible in v3.1.1 and onward to dwi/bvecs/bvals files directly into it, using option flags of those names.)

Can I please have some more details of what you are trying to do and precisely what isn’t working?

1dDW_Grad_o_Mat++ can have many types of bvec/grad/bmatrix and bval. The input flags start with “in” are:


-in_bvals     -in_col_matA  -in_col_matT  -in_col_vec   -in_row_vec

If you have a Siemens (or other) gradient table file in good standing, then you should be able to use likely either -in_col_vec or -in_row_vec, depending on whether it is column- or row-oriented, respectively. Do you want to multiple a b-value times it? Or something else? Perhaps you could copy+paste the specific grad table here (or at least a few lines) and describe what you want to do with it using 1dDW_Grad_o_Mat++?

–pt

Hey Taylor,

Thanks for the reply. I am following the issue I had in the past (from this thread https://afni.nimh.nih.gov/afni/community/board/read.php?1,158748,158753#msg-158753). After a series of failures i admit i got discouraged, so I switched to diffusion toolkit (its easier to run through the GUI). The results from the diffusion tookit were better (as in there is actual tracts that make sense now). I noticed that in diffusion toolkit you can select the machine and number of gradients to process the data (in my case siemens_64), and select a single b value (1100). I noticed that you feed the matT.dat file to the 1dDW_Grad_o_Mat++, and you get the rvec.dat, bval.dat which go to DIFFPREP. bval.dat had all values of ~1100 (except first one is 0, the rest are 1100 or 1100.01), and the rvec.dat . I assume that the rvec.dat is sort of the gradient table (in row format)

1dDW_Grad_o_Mat++
-in_col_matT $path_P_ss/${i}_dti_matT.dat
-unit_mag_out
-out_row_vec $odir/${i}_dti_rvec.dat
-out_row_bval_sep $odir/${i}_dti_bval.dat

# the NIFTI file must be unzipped
3dcopy                                                 \
    $path_P_ss/${i}_dti_filt.nii                    \
    $odir/${i}_dti_filt.nii
# finally, the main command itself

DIFFPREP                                               \
    --dwi         $odir/${i}_dti_filt.nii                         \
    --bvecs       $odir/${i}_dti_rvec.dat                    \
    --bvals       $odir/${i}_dti_bval.dat                    \
    --structural  $home_dir/$i/t1w/${i}_t1_axial.nii.gz \
    --phase       vertical                             \
    --will_be_drbuddied  0                             \
    --reg_settings example_registration_settings.dmc

siemens_64.txt first 6 lines:
1.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000
-0.026007, 0.649170, 0.760199
0.591136, -0.766176, 0.252058
-0.236071, -0.524158, 0.818247
-0.893021, -0.259006, 0.368008

rvec first 6 of each row:
0.000000 0.998437 -0.000098 -0.067471 -0.576719 0.280041
0.000000 0.000000 0.999998 0.648654 0.766650 0.524701
0.000000 -0.055894 -0.001816 -0.758087 0.282211 0.803907

So in my assumption that rvec should resemble the siemens_64 gradient table, i want to try feeding the table to diffprep or 1dDW_Grad_o_Mat++. Is my logic faulty?

Thanks,
-bit-warrior

Hi, Bit-Warrior-

Lots of things to unpack here.

  1. OK, I will address some features of DIFFPREP, but just usage. From their help file:

--dwi 
          Full path to the DWI NIFTI image to be corrected. Only provide this if a 
          LISTFILE is not provided. Bmatrix and phase parameters also need to be entered. 

     --bvecs 
          Full path to the Bvecs file. Only provide this if a LISTFILE is not provided. 
          DWI NIFTI and phase parameters also need to be entered. 

     --bvals 
          Full path to the Bvals file. Only provide this if a LISTFILE is not provided. 
          DWI NIFTI and phase parameters also need to be entered.

—> these are basically the 3 files that would be output by dcm2niix (or dcm2niix_afni, if you want the same thing distributed with AFNI). These files have the following specific format:
++ The DWI file is 4D NIFTI, having N volumes.
++ The “bvecs” file is 3 rows, each of N entries, for the x-, y- and z- components of the gradient. Each gradient should be stored here as a unit-magnitude value. This would be a “row”-gradient file, or row-vec file.
The “bvals” file is a single row of N bvalues. Typically, the first one (and possibly others) have a zero value. Others can/will be larger numbers like ~1000 (because typical units of DW factors are s/mm^2).

For more information/description on these things, the 1dDW_Grad_o_Mat++ help file has a number of comments/descriptions, and the following part FATCAT help in the AFNI documentation does, too:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/FATCAT/DealingWithGrads.html

  1. the TORTOISE-style bmatrix is 6 columns by N rows, with the order of columns described in both of the above documentations. The bmatrix info combines the gradient and bvalue (magnitude) information, storing essentially the bmatrix element values.

3a) Re. converting the Siemens grad table:
Thanks for putting that there. Note that the Siemens grad table mostly looks like a “column-wise” list of grads, but important it has commas (!) in it. That is different than what AFNI (or TORTOISE, or several other softwares) would be happy to read in. You would want to delete the commas (e.g., replace them with spaces), and then you could convert that to a row-wise gradient file, such as with:


1dDW_Grad_o_Mat++                                \
    -in_col_vec  gradfile_nocommas_cvec.dat      \
    -out_row_vec gradfile_nocommas_rvec.dat

The input has unit magnitude grads, and so does the output. The output would be your “bvecs” file.

3b) Note that the Siemens grad table does not appear to contain b-value information-- it just has unit-magnitude grads. Fine. You would have to provide a file of bvalues, which I guess you would have to know. Note that you likely have some b-values that are zero, and then many that are nonzero.

  1. You can read the above links for how the bvec and bval information combine. Something to note is taht sometimes the “reference scans” entries have a non-zero gradient value but a zero b-value. Other times, there is a non-zero bvalue, but the gradient components are all zero. Sometimes, both the bvalue is zero and all grad componetns are zero. Each of those cases describes having an un-weighted reference scan.

OK, please let me know if that has addressed everything.

–pt