Monday, October 7, 2013

The connection between Linus Pauling and fMRI

When I think of Linus Pauling, two things come to mind: his work on  the nature of the chemical bond (for which he was awarded the 1954 Nobel Prize in Chemistry) and, in his later years, his advocacy of Vitamin C. But Pauling is one of the great names of  20th century science. He contributed to a variety or domains and other connections can be made. His campaigning for a nuclear test ban won him a Nobel Peace prize. And his description of the molecular structure of blood -- of sickle cell anemia in particular -- is highly regarded.

 Pauling, in fact, had had a long interest in the properties of blood. In 1936 he published an important paper on the magnetic properties of hemoglobin [1]. Hemoglobin, which is a major component of blood, can be oxygenated or deoxygenated and it is due to this easy coupling and decoupling that it plays its key role as a carrier of oxygen. Pauling's experiments had shown that deoxyhemoglobin is paramagnetic (i.e.,  in layman's terms, has magnetic properties) and oxyhemoglobin is diamagnetic. The original paper is worth reading; I was struck by the clear, concise and objective manner in which these results are  presented.

Pauling did not envision an application at the time but from the mid-1960s on much work was done on engineering MR field gradients and studying the contrast they provided for different kinds of tissues. In 1990, Seiji Ogawa published a set of papers [2] showing that local inhomogeneities in the magnetic field were formed in response to  changing levels of deoxygenated blood and could be measured. This property became the basis of BOLD or blood oxygenation level dependent fMRI.

The connection  between neural activity and the MR signal  is roughly as follows: 

        increased local brain activity
               → increased blood flow 
                   → change (dilation) in size of blood vessel
                          → change (increase) in the deoxyhemoglobin concentration
                                → changes in the local magnetic field as measured by the MRI (T2*) signal. 

There is an excellent lecture on YouTube where Geoffrey Aguirre explains this. Another talk, this time by Christof Koch, also briefly mentions Pauling's paper.


References  
(1) The Magnetic Properties and Structure of Hemoglobin, Oxyhemoglobin and Carbonmonoxyhemoglobin.
Linus Pauling, Charles D. Coryell. Proc Natl Academy of Sciences. 1936 April; 22(4): 210–216.
(2) Brain magnetic resonance imaging with contrast dependent on blood oxygenation.
Seiji Ogawa et al.  Proceedings of the National Academy of Sciences. 1990; 87(24): 9868-9872.

Friday, May 24, 2013

Processing a diffusion phantom with FSL

This is a how-to style post intended for FSL users. It may also be of interest to a broader diffusion imaging audience.

In diffusion imaging, a carefully constructed diffusion phantom may be used as a ground truth reference to evaluate competing diffusion models and tractography algorithms. The phantom constructed for the 2009 MICCAI Fiber Cup challenge [1] is one such reference; it is a coronal slice model of fibers that cross, touch and split into different configurations and with different curvatures. The phantom dataset is now publicly available.
Fiber pathways in the diffusion phantom
Image credit: Fibercup paper [1]



  I recently processed the raw phantom dataset to evaluate some algorithms. These are some of my notes on how to preprocess the data on FSL through bedpostx. bedpostx is an FSL program that computes the distribution of diffusion parameters at each voxel. It generates all the files necessary to run the probabilistic tractography tool probtrackx.
  • The raw data for the phantom can be obtained from the Fiber Cup download page. There are 6 datasets (2 image resolutions each acquired at 3 different b-values). The data is stored in 4D NIfTI format and has already been preprocessed to correct for eddy currents and movements so one can run bedpostx directly.
  • In order to run bedpostx, you need the bvals and bvecs gradient files, as well as the input data file and the nodif_brain_mask.
    • data.nii is the 4D phantom image file.
    • bvals is an ASCII text file of b-values corresponding to the gradient directions; the b-values are listed as a single row.
    • bvecs are the gradient vectors; the file format has 3 rows which correspond to the x-, y- and z-values of the gradient directions.
    • nodif_brain_mask.nii.gz is a 3D binary mask file; the file is generated using the FSL bet (or bet2) command.

Sample commands for the dwi-1500.nii dataset (3x3x3 mm resolution, b=1500):
  1. Download the 3x3x3 dwi-b1500.nii file from the Fibercup download page. Rename the file data.nii.
  2. Download the diffusion_directions_corrected.txt file. This is a file of coordinates with 130 entries. The first 65 lines (baseline + 64 directions) are repeated (65 x 2 = 130) since two passes were taken. This was most probably done to average over noise.
    This file, which I have renamed bvecs.tmp, needs to be formatted into the bvecs file so that the x-, y- and z-columns are transposed as rows (see 5 below for sample code).
  3. To generate the bvals file note that there should be 130 values since the number of entries should correspond to the number of gradients. The first value is 0 (for b0); the next 64 values should be 1500 (for b=1500); the final 65 values are a repeat of the first 65. This is the unix command-line perl code I used to create this file:
    perl -e 'print "0\t", "1500\t" x 64, "0\t", "1500\t" x 64' > bvals
  4. The nodif_brain_mask file is generated using the following BET (brain extraction tool) command:
    bet2 data.nii nodif_brain_mask.nii -m -n -f 0.15
    The -m flag specifies a binary mask; the -f flag is the mask threshold.
  5. Run dtifit, an FSL command that fits a diffusion tensor model at each voxel.
    dtifit -k data.nii -m nodif_brain_mask.nii.gz -o out -r bvecs -b bvals
    This extra step, suggested by my colleague Julio Duarte, can be used to check the directions in the bvecs file. This is done by viewing the output file out_V1.nii.gz on FSLview and verifying that the primary fiber direction at each voxel aligns with the phantom's.




    Here we see that the horizontal x-direction is aligned with the phantom but the vertical y-direction needs to be replaced by -y. 








    To correct this I used the following command-line perl code to regenerate the bvecs file:
    perl -ane 'print "$F[0] "' bvecs.tmp > bvecs
    perl -e 'print "\n"' >> bvecs
    perl -ane 'print $F[1]*-1," " ' bvecs.tmp >> bvecs
    perl -e 'print "\n"' >> bvecs
    perl -ane 'print "$F[2] "' bvecs.tmp >> bvecs
    perl -e 'print "\n"' >> bvecs

    If we re-run dtifit, we will see that the primary vectors align with the phantom's fiber pathways.

  6. Run bedpostx using the directory where the data, bvals, bvecs and nodif_brain_mask files are located:
    bedpostx ./ 
  7. As an optional final check compare the bedpostx vector output (dyads*.nii) to the dtifit output (out_V1.nii). 


The bedpostx dyads1 output (blue arrows) is overlaid on the dtifit out_V1 (red lines) vectors. We can see that they align with each other.









Reference
[1] Quantitative evaluation of 10 tractography algorithms on a realistic diffusion MR phantom. Fillard P, Descoteaux M, Goh A, Gouttard S, Jeurissen B, Malcolm J, Ramirez-Manzanares A, Reisert M, Sakaie K, Tensaouti F, Yo T, Mangin JF, Poupon C. Neuroimage 2011; 56(1):220-34.

Some resources
Takuya Hayashi has a program to swap the bvec values.  (Note: I have not verified that it works.)

Tuesday, April 23, 2013

The see-through brain


A group at Stanford led by Karl Deisseroth have pioneered a chemical process that leaves brain (and other) tissue intact but optically transparent. The procedure, aptly named CLARITY, exposes internal structure by replacing the opaque lipid layers that surround cells with a transparent shape-preserving hydro-gel. Neurons, glia, genes and other molecules of interest can then be selectively highlighted in this transparent brain by molecular markers. The results are spectacular and reminiscent of swimming among the jellyfish.

This is a link to Nature which published the article. The accompanying set of video clips is compelling; in one frame, a single nerve projection is traced out among a tangle of other neurons. The technique will provide a boost for the field of connectomics; researchers who would otherwise have to reconstruct neural wiring from small piece-meal sections of brain will be able to view whole-brain connections in one glance.

Update August 10 2013:   A short clip of Karl Deisseroth on CLARITY.