Fdt diffusion analysis
For CBU data.
These are just notes of work in progress by MatthewBrett.
FDT documentation: http://www.fmrib.ox.ac.uk/fsl/fdt/index.html
FDT FAQ entries: http://www.fmrib.ox.ac.uk/fslfaq/#title_fdt
Extracting the bvals, bvecs values from Siemens data
See: http://wiki.na-mic.org/Wiki/index.php/NAMIC_Wiki:DTI:DICOM_for_DWI_and_DTI
Note that the B gradient=0 has no direction information.
So, for the example dataset I have been playing with, you can fetch the diffusion directions from the DICOM headers, by getting the DICOM file names from a diffusion dataset into the matlab string matrix input_files, and doing something like:
hdr = spm_dicom_headers(input_files); n = length(hdr); bvals = zeros(n, 1); bvecs = zeros(n, 3); for i = 1:n H = hdr{i}; bvals(i) = str2num(H.CSAImageHeaderInfo(7).item(1).val); if bvals(i) == 0 % no gradient continue end d_info = H.CSAImageHeaderInfo(22).item; for D = 1:3 bvecs(i,D)= str2num(d_info(D).val); end end
I've implemented this as cbu_diffusion_params.m in the SPM common directory at the CBU.
We then have to write out the gradient values and directions in a format that FDT understands - see dtifit documentation in the FDT pages: http://www.fmrib.ox.ac.uk/fsl/fdt/index.html.
bvals
All one one line, one value per DWI acquisition, appears to be exponential format separated by 3 spaces per value, and needs new line at end of file. For example:
0.0000000e+00 0.0000000e+00 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 0.0000000e+00 0.0000000e+00 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 1.0000000e+03 0.0000000e+00l
(Note new line at end of file).
bvecs
One line per direction (one line for X direction, one line for Y direction, one line for Z direction). New line at end of each. Need to include zeros for no diffusion gradient acquisitions. E.G:
0 0.0000000e+00 7.6937618e-01 9.9999924e-01 4.0214920e-02 1.9526217e-01 5.1096926e-01 6.4449110e-01 1.1639260e-01 4.1472436e-01 6.8663556e-01 3.8949705e-01 5.0524772e-01 1.1717751e-01 7.6094012e-01 7.8334360e-01 4.4028061e-01 2.0589133e-01 1.3436626e-01 2.7000378e-01 4.4543086e-01 2.1816264e-01 3.6644717e-01 1.9651463e-01 5.6797954e-01 4.2364378e-01 4.8425159e-01 4.8837442e-01 7.1876309e-01 9.3607570e-02 1.7722160e-01 0 0.0000000e+00 5.1711309e-01 7.5808487e-01 8.0234240e-01 1.9735010e-02 3.3516758e-01 6.3448454e-01 8.1168960e-02 1.0445113e-01 2.6766319e-01 6.7016636e-01 1.5391958e-01 4.1367573e-01 8.8398617e-01 2.1753901e-01 9.3271228e-01 6.9488384e-01 8.8211118e-01 6.9509295e-01 8.7347998e-01 7.5283496e-01 8.8371946e-01 8.8840244e-01 5.5232725e-01 9.3679074e-01 9.4961311e-01 6.4277964e-01 3.4381087e-01 9.9971116e-01 9.9821503e-01 4.6606173e-01 1.3874523e-01 0 0 0.0000000e+00 6.6306062e-01 1.6707810e-02 -9.9903292e-01 7.6591725e-01 7.7929365e-01 -7.8747432e-01 -9.9961185e-01 -8.8677651e-01 3.4283814e-01 -4.8693386e-01 8.8074278e-01 -8.8352002e-01 -7.8999910e-02 2.6876947e-01 2.5290552e-01 9.3262713e-01 -3.3491810e-01 3.2593888e-01 7.5894353e-01 -2.6638000e-03 -9.4866592e-01 9.9998147e-01 -7.8726452e-01 -7.2459950e-01 -6.4709189e-01 -1.7825689e-01 5.5582022e-01 8.8285078e-01 4.8544349e-01 0 0.0000000e+00 4.7983043e-01 -4.9330514e-01 -6.0886478e-01 -4.8934133e-01 9.3013284e-01 -3.1901719e-01 -1.8293329e-01 -6.6242333e-01 -8.8671109e-01 -4.2004243e-01 -7.2580995e-01 -9.4553600e-02 4.6713278e-01 6.6282962e-01 3.7641775e-01 -6.4060372e-01 -4.9143385e-01 1.4877920e-02 -1.6054820e-01 5.4879866e-01 -2.8861432e-01 1.8916095e-01 1.5049253e-01 6.7304890e-02 -3.1584415e-01 7.6457665e-01 -4.3058758e-01 -1.6450303e-01 1.8210187e-01 5.8200226e-01 1.4422617e-01 0 0 -0.0000000e+00 -9.1990930e-02 -1.9943366e-01 -2.0091641e-01 -6.4443377e-01 -4.1432263e-01 6.7578430e-02 1.6516763e-01 2.8580159e-01 -6.7159887e-01 8.0699374e-01 -9.5227750e-02 4.9569470e-01 6.7437421e-01 5.9513629e-01 -8.8444514e-01 -3.5758470e-01 9.5384852e-01 9.2785410e-01 5.1541002e-01 9.9621754e-01 -7.6163460e-02 -3.8346860e-02 -3.1251438e-01 5.7925205e-01 -6.2195169e-01 8.7736329e-01 4.6313598e-01 5.0186008e-01 -8.7919767e-01 0 -0.0000000e+00 7.3648370e-01 -4.7117809e-01 -1.5994303e-01 -8.9454291e-01 2.5013402e-01 -7.3192133e-01 -9.9999922e-01 7.6833373e-01 -4.2679184e-01 6.4381118e-01 -6.9968571e-01 -9.2735292e-01 2.0101452e-01 7.4389858e-01 -1.6854941e-01 3.8316412e-01 1.4291280e-01 -7.4610714e-01 -5.0130672e-01 -4.1486259e-01 4.1927689e-01 -4.6369242e-01 8.4400121e-01 3.9742244e-01 -1.9628767e-01 2.0568982e-01 -8.5816073e-01 1.1648077e-01 1.0225989e-01 -6.9578104e-01 -1.0000000e+00 0
Y direction appears to be flipped in our acquisitions
The Y direction from our Siemens acquisitions seems to be inverted (so Tim Behrens tells me). We will have to work out why this is. For the moment, I've put an ugly hack into the script to write out bvecs, that just flips the Y direction.